Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #pragma once
  2. // clang-format off
  3. /**
  4. * Header checks
  5. */
  6. #if __has_include(<sys/mman.h>)
  7. #define HAVE_SYS_MMAN_H 1
  8. #endif
  9. #if __has_include(<sys/random.h>)
  10. #define HAVE_SYS_RANDOM_H 1
  11. #endif
  12. #if __has_include(<intrin.h>)
  13. #define HAVE_INTRIN_H 1
  14. #endif
  15. #if __has_include(<sys/auxv.h>)
  16. #define HAVE_SYS_AUXV_H 1
  17. #endif
  18. /**
  19. * Architectural checks for intrinsics
  20. */
  21. #if __has_include(<mmintrin.h>) && __MMX__
  22. #define HAVE_MMINTRIN_H 1
  23. #endif
  24. #if __has_include(<emmintrin.h>) && __SSE2__
  25. #define HAVE_EMMINTRIN_H 1
  26. #endif
  27. #if __SSE3__
  28. #if __has_include(<pmmintrin.h>)
  29. #define HAVE_PMMINTRIN_H 1
  30. #endif
  31. #if __has_include(<tmmintrin.h>)
  32. #define HAVE_TMMINTRIN_H 1
  33. #endif
  34. #endif
  35. #if __has_include(<smmintrin.h>) && __SSE4_1__
  36. #define HAVE_SMMINTRIN_H
  37. #endif
  38. #if __has_include(<immintrin.h>)
  39. #if __AVX__
  40. #define HAVE_AVXINTRIN_H
  41. #endif
  42. #if __AVX2__
  43. #define HAVE_AVX2INTRIN_H
  44. #endif
  45. #if __AVX512F__
  46. #if defined(__clang__) && __clang_major__ < 4
  47. // AVX512 may be broken
  48. #elif defined(__GNUC__) && __GNUC__ < 6
  49. // ''
  50. #else
  51. #define HAVE_AVX512FINTRIN_H
  52. #endif
  53. #endif
  54. #endif
  55. #if __has_include(<wmmintrin.h>) && __AES__
  56. #define HAVE_WMMINTRIN_H 1
  57. #endif
  58. #if __RDRND__
  59. #define HAVE_RDRAND
  60. #endif
  61. /**
  62. * Detect mman APIs
  63. */
  64. #if __has_include(<sys/mman.h>)
  65. #define HAVE_MMAP 1
  66. #define HAVE_MPROTECT 1
  67. #define HAVE_MLOCK 1
  68. #if defined(_DEFAULT_SOURCE) || defined(_BSD_SOURCE)
  69. #define HAVE_MADVISE 1
  70. #endif
  71. #endif
  72. #if __has_include(<sys/random.h>)
  73. #define HAVE_GETRANDOM 1
  74. #endif
  75. /**
  76. * POSIX-Only stuff
  77. */
  78. #if __has_include(<unistd.h>)
  79. #if defined(_DEFAULT_SOURCE)
  80. #define HAVE_GETENTROPY 1
  81. #endif
  82. /**
  83. * Default POSIX APIs
  84. */
  85. #define HAVE_POSIX_MEMALIGN 1
  86. #define HAVE_GETPID 1
  87. #define HAVE_NANOSLEEP 1
  88. /**
  89. * Language/library features from C11
  90. */
  91. #if __STDC_VERSION__ >= 201112L
  92. #define HAVE_MEMSET_S 1
  93. #endif
  94. #if __linux__
  95. #define HAVE_EXPLICIT_BZERO 1
  96. #endif
  97. #endif
  98. /**
  99. * Miscellaneous
  100. */
  101. #if __has_include(<pthread.h>)
  102. #define HAVE_PTHREAD 1
  103. #endif
  104. #if __has_include(<sys/param.h>)
  105. #include <sys/param.h>
  106. #if __BYTE_ORDER == __BIG_ENDIAN
  107. #define NATIVE_BIG_ENDIAN 1
  108. #elif __BYTE_ORDER == __LITTLE_ENDIAN
  109. #define NATIVE_LITTLE_ENDIAN 1
  110. #else
  111. #error "Unknown endianness for this platform."
  112. #endif
  113. #elif defined(_MSVC)
  114. // At time of writing, MSVC only targets little-endian.
  115. #define NATIVE_LITTLE_ENDIAN 1
  116. #else
  117. #error "Unknown endianness for this platform."
  118. #endif
  119. #define CONFIGURED 1