You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.h 36 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. //
  2. // Copyright 2017 The Abseil Authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // -----------------------------------------------------------------------------
  17. // File: config.h
  18. // -----------------------------------------------------------------------------
  19. //
  20. // This header file defines a set of macros for checking the presence of
  21. // important compiler and platform features. Such macros can be used to
  22. // produce portable code by parameterizing compilation based on the presence or
  23. // lack of a given feature.
  24. //
  25. // We define a "feature" as some interface we wish to program to: for example,
  26. // a library function or system call. A value of `1` indicates support for
  27. // that feature; any other value indicates the feature support is undefined.
  28. //
  29. // Example:
  30. //
  31. // Suppose a programmer wants to write a program that uses the 'mmap()' system
  32. // call. The Abseil macro for that feature (`ABSL_HAVE_MMAP`) allows you to
  33. // selectively include the `mmap.h` header and bracket code using that feature
  34. // in the macro:
  35. //
  36. // #include "absl/base/config.h"
  37. //
  38. // #ifdef ABSL_HAVE_MMAP
  39. // #include "sys/mman.h"
  40. // #endif //ABSL_HAVE_MMAP
  41. //
  42. // ...
  43. // #ifdef ABSL_HAVE_MMAP
  44. // void *ptr = mmap(...);
  45. // ...
  46. // #endif // ABSL_HAVE_MMAP
  47. #ifndef ABSL_BASE_CONFIG_H_
  48. #define ABSL_BASE_CONFIG_H_
  49. // Included for the __GLIBC__ macro (or similar macros on other systems).
  50. #include <limits.h>
  51. #ifdef __cplusplus
  52. // Included for __GLIBCXX__, _LIBCPP_VERSION
  53. #include <cstddef>
  54. #endif // __cplusplus
  55. // ABSL_INTERNAL_CPLUSPLUS_LANG
  56. //
  57. // MSVC does not set the value of __cplusplus correctly, but instead uses
  58. // _MSVC_LANG as a stand-in.
  59. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  60. //
  61. // However, there are reports that MSVC even sets _MSVC_LANG incorrectly at
  62. // times, for example:
  63. // https://github.com/microsoft/vscode-cpptools/issues/1770
  64. // https://reviews.llvm.org/D70996
  65. //
  66. // For this reason, this symbol is considered INTERNAL and code outside of
  67. // Abseil must not use it.
  68. #if defined(_MSVC_LANG)
  69. #define ABSL_INTERNAL_CPLUSPLUS_LANG _MSVC_LANG
  70. #elif defined(__cplusplus)
  71. #define ABSL_INTERNAL_CPLUSPLUS_LANG __cplusplus
  72. #endif
  73. #if defined(__APPLE__)
  74. // Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED,
  75. // __IPHONE_8_0.
  76. #include <Availability.h>
  77. #include <TargetConditionals.h>
  78. #endif
  79. #include "absl/base/options.h"
  80. #include "absl/base/policy_checks.h"
  81. // Abseil long-term support (LTS) releases will define
  82. // `ABSL_LTS_RELEASE_VERSION` to the integer representing the date string of the
  83. // LTS release version, and will define `ABSL_LTS_RELEASE_PATCH_LEVEL` to the
  84. // integer representing the patch-level for that release.
  85. //
  86. // For example, for LTS release version "20300401.2", this would give us
  87. // ABSL_LTS_RELEASE_VERSION == 20300401 && ABSL_LTS_RELEASE_PATCH_LEVEL == 2
  88. //
  89. // These symbols will not be defined in non-LTS code.
  90. //
  91. // Abseil recommends that clients live-at-head. Therefore, if you are using
  92. // these symbols to assert a minimum version requirement, we recommend you do it
  93. // as
  94. //
  95. // #if defined(ABSL_LTS_RELEASE_VERSION) && ABSL_LTS_RELEASE_VERSION < 20300401
  96. // #error Project foo requires Abseil LTS version >= 20300401
  97. // #endif
  98. //
  99. // The `defined(ABSL_LTS_RELEASE_VERSION)` part of the check excludes
  100. // live-at-head clients from the minimum version assertion.
  101. //
  102. // See https://abseil.io/about/releases for more information on Abseil release
  103. // management.
  104. //
  105. // LTS releases can be obtained from
  106. // https://github.com/abseil/abseil-cpp/releases.
  107. #define ABSL_LTS_RELEASE_VERSION 20220623
  108. #define ABSL_LTS_RELEASE_PATCH_LEVEL 1
  109. // Helper macro to convert a CPP variable to a string literal.
  110. #define ABSL_INTERNAL_DO_TOKEN_STR(x) #x
  111. #define ABSL_INTERNAL_TOKEN_STR(x) ABSL_INTERNAL_DO_TOKEN_STR(x)
  112. // -----------------------------------------------------------------------------
  113. // Abseil namespace annotations
  114. // -----------------------------------------------------------------------------
  115. // ABSL_NAMESPACE_BEGIN/ABSL_NAMESPACE_END
  116. //
  117. // An annotation placed at the beginning/end of each `namespace absl` scope.
  118. // This is used to inject an inline namespace.
  119. //
  120. // The proper way to write Abseil code in the `absl` namespace is:
  121. //
  122. // namespace absl {
  123. // ABSL_NAMESPACE_BEGIN
  124. //
  125. // void Foo(); // absl::Foo().
  126. //
  127. // ABSL_NAMESPACE_END
  128. // } // namespace absl
  129. //
  130. // Users of Abseil should not use these macros, because users of Abseil should
  131. // not write `namespace absl {` in their own code for any reason. (Abseil does
  132. // not support forward declarations of its own types, nor does it support
  133. // user-provided specialization of Abseil templates. Code that violates these
  134. // rules may be broken without warning.)
  135. #if !defined(ABSL_OPTION_USE_INLINE_NAMESPACE) || \
  136. !defined(ABSL_OPTION_INLINE_NAMESPACE_NAME)
  137. #error options.h is misconfigured.
  138. #endif
  139. // Check that ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor ""
  140. #if defined(__cplusplus) && ABSL_OPTION_USE_INLINE_NAMESPACE == 1
  141. #define ABSL_INTERNAL_INLINE_NAMESPACE_STR \
  142. ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME)
  143. static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must "
  144. "not be empty.");
  145. static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must "
  146. "be changed to a new, unique identifier name.");
  147. #endif
  148. #if ABSL_OPTION_USE_INLINE_NAMESPACE == 0
  149. #define ABSL_NAMESPACE_BEGIN
  150. #define ABSL_NAMESPACE_END
  151. #define ABSL_INTERNAL_C_SYMBOL(x) x
  152. #elif ABSL_OPTION_USE_INLINE_NAMESPACE == 1
  153. #define ABSL_NAMESPACE_BEGIN \
  154. inline namespace ABSL_OPTION_INLINE_NAMESPACE_NAME \
  155. {
  156. #define ABSL_NAMESPACE_END }
  157. #define ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v) x##_##v
  158. #define ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, v) \
  159. ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v)
  160. #define ABSL_INTERNAL_C_SYMBOL(x) \
  161. ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, ABSL_OPTION_INLINE_NAMESPACE_NAME)
  162. #else
  163. #error options.h is misconfigured.
  164. #endif
  165. // -----------------------------------------------------------------------------
  166. // Compiler Feature Checks
  167. // -----------------------------------------------------------------------------
  168. // ABSL_HAVE_BUILTIN()
  169. //
  170. // Checks whether the compiler supports a Clang Feature Checking Macro, and if
  171. // so, checks whether it supports the provided builtin function "x" where x
  172. // is one of the functions noted in
  173. // https://clang.llvm.org/docs/LanguageExtensions.html
  174. //
  175. // Note: Use this macro to avoid an extra level of #ifdef __has_builtin check.
  176. // http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html
  177. #ifdef __has_builtin
  178. #define ABSL_HAVE_BUILTIN(x) __has_builtin(x)
  179. #else
  180. #define ABSL_HAVE_BUILTIN(x) 0
  181. #endif
  182. #ifdef __has_feature
  183. #define ABSL_HAVE_FEATURE(f) __has_feature(f)
  184. #else
  185. #define ABSL_HAVE_FEATURE(f) 0
  186. #endif
  187. // Portable check for GCC minimum version:
  188. // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
  189. #if defined(__GNUC__) && defined(__GNUC_MINOR__)
  190. #define ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(x, y) \
  191. (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
  192. #else
  193. #define ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(x, y) 0
  194. #endif
  195. #if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
  196. #define ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(x, y) \
  197. (__clang_major__ > (x) || __clang_major__ == (x) && __clang_minor__ >= (y))
  198. #else
  199. #define ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(x, y) 0
  200. #endif
  201. // ABSL_HAVE_TLS is defined to 1 when __thread should be supported.
  202. // We assume __thread is supported on Linux or Asylo when compiled with Clang or
  203. // compiled against libstdc++ with _GLIBCXX_HAVE_TLS defined.
  204. #ifdef ABSL_HAVE_TLS
  205. #error ABSL_HAVE_TLS cannot be directly set
  206. #elif (defined(__linux__) || defined(__ASYLO__)) && \
  207. (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
  208. #define ABSL_HAVE_TLS 1
  209. #endif
  210. // ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
  211. //
  212. // Checks whether `std::is_trivially_destructible<T>` is supported.
  213. //
  214. // Notes: All supported compilers using libc++ support this feature, as does
  215. // gcc >= 4.8.1 using libstdc++, and Visual Studio.
  216. #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
  217. #error ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set
  218. #elif defined(_LIBCPP_VERSION) || defined(_MSC_VER) || \
  219. (!defined(__clang__) && defined(__GLIBCXX__) && \
  220. ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(4, 8))
  221. #define ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1
  222. #endif
  223. // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
  224. //
  225. // Checks whether `std::is_trivially_default_constructible<T>` and
  226. // `std::is_trivially_copy_constructible<T>` are supported.
  227. // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
  228. //
  229. // Checks whether `std::is_trivially_copy_assignable<T>` is supported.
  230. // Notes: Clang with libc++ supports these features, as does gcc >= 7.4 with
  231. // libstdc++, or gcc >= 8.2 with libc++, and Visual Studio (but not NVCC).
  232. #if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
  233. #error ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set
  234. #elif defined(ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE)
  235. #error ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set
  236. #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \
  237. (!defined(__clang__) && \
  238. ((ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(7, 4) && defined(__GLIBCXX__)) || \
  239. (ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(8, 2) && \
  240. defined(_LIBCPP_VERSION)))) || \
  241. (defined(_MSC_VER) && !defined(__NVCC__))
  242. #define ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1
  243. #define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
  244. #endif
  245. // ABSL_HAVE_THREAD_LOCAL
  246. //
  247. // Checks whether C++11's `thread_local` storage duration specifier is
  248. // supported.
  249. #ifdef ABSL_HAVE_THREAD_LOCAL
  250. #error ABSL_HAVE_THREAD_LOCAL cannot be directly set
  251. #elif defined(__APPLE__)
  252. // Notes:
  253. // * Xcode's clang did not support `thread_local` until version 8, and
  254. // even then not for all iOS < 9.0.
  255. // * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator
  256. // targeting iOS 9.x.
  257. // * Xcode 10 moves the deployment target check for iOS < 9.0 to link time
  258. // making ABSL_HAVE_FEATURE unreliable there.
  259. //
  260. #if ABSL_HAVE_FEATURE(cxx_thread_local) && \
  261. !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
  262. #define ABSL_HAVE_THREAD_LOCAL 1
  263. #endif
  264. #else // !defined(__APPLE__)
  265. #define ABSL_HAVE_THREAD_LOCAL 1
  266. #endif
  267. // There are platforms for which TLS should not be used even though the compiler
  268. // makes it seem like it's supported (Android NDK < r12b for example).
  269. // This is primarily because of linker problems and toolchain misconfiguration:
  270. // Abseil does not intend to support this indefinitely. Currently, the newest
  271. // toolchain that we intend to support that requires this behavior is the
  272. // r11 NDK - allowing for a 5 year support window on that means this option
  273. // is likely to be removed around June of 2021.
  274. // TLS isn't supported until NDK r12b per
  275. // https://developer.android.com/ndk/downloads/revision_history.html
  276. // Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in
  277. // <android/ndk-version.h>. For NDK < r16, users should define these macros,
  278. // e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11.
  279. #if defined(__ANDROID__) && defined(__clang__)
  280. #if __has_include(<android/ndk-version.h>)
  281. #include <android/ndk-version.h>
  282. #endif // __has_include(<android/ndk-version.h>)
  283. #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \
  284. defined(__NDK_MINOR__) && \
  285. ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))
  286. #undef ABSL_HAVE_TLS
  287. #undef ABSL_HAVE_THREAD_LOCAL
  288. #endif
  289. #endif // defined(__ANDROID__) && defined(__clang__)
  290. // ABSL_HAVE_INTRINSIC_INT128
  291. //
  292. // Checks whether the __int128 compiler extension for a 128-bit integral type is
  293. // supported.
  294. //
  295. // Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is
  296. // supported, but we avoid using it in certain cases:
  297. // * On Clang:
  298. // * Building using Clang for Windows, where the Clang runtime library has
  299. // 128-bit support only on LP64 architectures, but Windows is LLP64.
  300. // * On Nvidia's nvcc:
  301. // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions
  302. // actually support __int128.
  303. #ifdef ABSL_HAVE_INTRINSIC_INT128
  304. #error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
  305. #elif defined(__SIZEOF_INT128__)
  306. #if (defined(__clang__) && !defined(_WIN32)) || \
  307. (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
  308. (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
  309. #define ABSL_HAVE_INTRINSIC_INT128 1
  310. #elif defined(__CUDACC__)
  311. // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a
  312. // string explaining that it has been removed starting with CUDA 9. We use
  313. // nested #ifs because there is no short-circuiting in the preprocessor.
  314. // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined.
  315. #if __CUDACC_VER__ >= 70000
  316. #define ABSL_HAVE_INTRINSIC_INT128 1
  317. #endif // __CUDACC_VER__ >= 70000
  318. #endif // defined(__CUDACC__)
  319. #endif // ABSL_HAVE_INTRINSIC_INT128
  320. // ABSL_HAVE_EXCEPTIONS
  321. //
  322. // Checks whether the compiler both supports and enables exceptions. Many
  323. // compilers support a "no exceptions" mode that disables exceptions.
  324. //
  325. // Generally, when ABSL_HAVE_EXCEPTIONS is not defined:
  326. //
  327. // * Code using `throw` and `try` may not compile.
  328. // * The `noexcept` specifier will still compile and behave as normal.
  329. // * The `noexcept` operator may still return `false`.
  330. //
  331. // For further details, consult the compiler's documentation.
  332. #ifdef ABSL_HAVE_EXCEPTIONS
  333. #error ABSL_HAVE_EXCEPTIONS cannot be directly set.
  334. #elif ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(3, 6)
  335. // Clang >= 3.6
  336. #if ABSL_HAVE_FEATURE(cxx_exceptions)
  337. #define ABSL_HAVE_EXCEPTIONS 1
  338. #endif // ABSL_HAVE_FEATURE(cxx_exceptions)
  339. #elif defined(__clang__)
  340. // Clang < 3.6
  341. // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro
  342. #if defined(__EXCEPTIONS) && ABSL_HAVE_FEATURE(cxx_exceptions)
  343. #define ABSL_HAVE_EXCEPTIONS 1
  344. #endif // defined(__EXCEPTIONS) && ABSL_HAVE_FEATURE(cxx_exceptions)
  345. // Handle remaining special cases and default to exceptions being supported.
  346. #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \
  347. !(ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(5, 0) && \
  348. !defined(__cpp_exceptions)) && \
  349. !(defined(_MSC_VER) && !defined(_CPPUNWIND))
  350. #define ABSL_HAVE_EXCEPTIONS 1
  351. #endif
  352. // -----------------------------------------------------------------------------
  353. // Platform Feature Checks
  354. // -----------------------------------------------------------------------------
  355. // Currently supported operating systems and associated preprocessor
  356. // symbols:
  357. //
  358. // Linux and Linux-derived __linux__
  359. // Android __ANDROID__ (implies __linux__)
  360. // Linux (non-Android) __linux__ && !__ANDROID__
  361. // Darwin (macOS and iOS) __APPLE__
  362. // Akaros (http://akaros.org) __ros__
  363. // Windows _WIN32
  364. // NaCL __native_client__
  365. // AsmJS __asmjs__
  366. // WebAssembly __wasm__
  367. // Fuchsia __Fuchsia__
  368. //
  369. // Note that since Android defines both __ANDROID__ and __linux__, one
  370. // may probe for either Linux or Android by simply testing for __linux__.
  371. // ABSL_HAVE_MMAP
  372. //
  373. // Checks whether the platform has an mmap(2) implementation as defined in
  374. // POSIX.1-2001.
  375. #ifdef ABSL_HAVE_MMAP
  376. #error ABSL_HAVE_MMAP cannot be directly set
  377. #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
  378. defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
  379. defined(__asmjs__) || defined(__wasm__) || defined(__Fuchsia__) || \
  380. defined(__sun) || defined(__ASYLO__) || defined(__myriad2__) || \
  381. defined(__HAIKU__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
  382. defined(__QNX__)
  383. #define ABSL_HAVE_MMAP 1
  384. #endif
  385. // ABSL_HAVE_PTHREAD_GETSCHEDPARAM
  386. //
  387. // Checks whether the platform implements the pthread_(get|set)schedparam(3)
  388. // functions as defined in POSIX.1-2001.
  389. #ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
  390. #error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
  391. #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
  392. defined(_AIX) || defined(__ros__) || defined(__OpenBSD__) || \
  393. defined(__NetBSD__)
  394. #define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
  395. #endif
  396. // ABSL_HAVE_SCHED_GETCPU
  397. //
  398. // Checks whether sched_getcpu is available.
  399. #ifdef ABSL_HAVE_SCHED_GETCPU
  400. #error ABSL_HAVE_SCHED_GETCPU cannot be directly set
  401. #elif defined(__linux__)
  402. #define ABSL_HAVE_SCHED_GETCPU 1
  403. #endif
  404. // ABSL_HAVE_SCHED_YIELD
  405. //
  406. // Checks whether the platform implements sched_yield(2) as defined in
  407. // POSIX.1-2001.
  408. #ifdef ABSL_HAVE_SCHED_YIELD
  409. #error ABSL_HAVE_SCHED_YIELD cannot be directly set
  410. #elif defined(__linux__) || defined(__ros__) || defined(__native_client__)
  411. #define ABSL_HAVE_SCHED_YIELD 1
  412. #endif
  413. // ABSL_HAVE_SEMAPHORE_H
  414. //
  415. // Checks whether the platform supports the <semaphore.h> header and sem_init(3)
  416. // family of functions as standardized in POSIX.1-2001.
  417. //
  418. // Note: While Apple provides <semaphore.h> for both iOS and macOS, it is
  419. // explicitly deprecated and will cause build failures if enabled for those
  420. // platforms. We side-step the issue by not defining it here for Apple
  421. // platforms.
  422. #ifdef ABSL_HAVE_SEMAPHORE_H
  423. #error ABSL_HAVE_SEMAPHORE_H cannot be directly set
  424. #elif defined(__linux__) || defined(__ros__)
  425. #define ABSL_HAVE_SEMAPHORE_H 1
  426. #endif
  427. // ABSL_HAVE_ALARM
  428. //
  429. // Checks whether the platform supports the <signal.h> header and alarm(2)
  430. // function as standardized in POSIX.1-2001.
  431. #ifdef ABSL_HAVE_ALARM
  432. #error ABSL_HAVE_ALARM cannot be directly set
  433. #elif defined(__GOOGLE_GRTE_VERSION__)
  434. // feature tests for Google's GRTE
  435. #define ABSL_HAVE_ALARM 1
  436. #elif defined(__GLIBC__)
  437. // feature test for glibc
  438. #define ABSL_HAVE_ALARM 1
  439. #elif defined(_MSC_VER)
  440. // feature tests for Microsoft's library
  441. #elif defined(__MINGW32__)
  442. // mingw32 doesn't provide alarm(2):
  443. // https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h
  444. // mingw-w64 provides a no-op implementation:
  445. // https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c
  446. #elif defined(__EMSCRIPTEN__)
  447. // emscripten doesn't support signals
  448. #elif defined(__Fuchsia__)
  449. // Signals don't exist on fuchsia.
  450. #elif defined(__native_client__)
  451. #else
  452. // other standard libraries
  453. #define ABSL_HAVE_ALARM 1
  454. #endif
  455. // ABSL_IS_LITTLE_ENDIAN
  456. // ABSL_IS_BIG_ENDIAN
  457. //
  458. // Checks the endianness of the platform.
  459. //
  460. // Notes: uses the built in endian macros provided by GCC (since 4.6) and
  461. // Clang (since 3.2); see
  462. // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html.
  463. // Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error.
  464. #if defined(ABSL_IS_BIG_ENDIAN)
  465. #error "ABSL_IS_BIG_ENDIAN cannot be directly set."
  466. #endif
  467. #if defined(ABSL_IS_LITTLE_ENDIAN)
  468. #error "ABSL_IS_LITTLE_ENDIAN cannot be directly set."
  469. #endif
  470. #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  471. #define ABSL_IS_LITTLE_ENDIAN 1
  472. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
  473. __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  474. #define ABSL_IS_BIG_ENDIAN 1
  475. #elif defined(_WIN32)
  476. #define ABSL_IS_LITTLE_ENDIAN 1
  477. #else
  478. #error "absl endian detection needs to be set up for your compiler"
  479. #endif
  480. // macOS < 10.13 and iOS < 11 don't let you use <any>, <optional>, or <variant>
  481. // even though the headers exist and are publicly noted to work, because the
  482. // libc++ shared library shipped on the system doesn't have the requisite
  483. // exported symbols. See https://github.com/abseil/abseil-cpp/issues/207 and
  484. // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
  485. //
  486. // libc++ spells out the availability requirements in the file
  487. // llvm-project/libcxx/include/__config via the #define
  488. // _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS.
  489. //
  490. // Unfortunately, Apple initially mis-stated the requirements as macOS < 10.14
  491. // and iOS < 12 in the libc++ headers. This was corrected by
  492. // https://github.com/llvm/llvm-project/commit/7fb40e1569dd66292b647f4501b85517e9247953
  493. // which subsequently made it into the XCode 12.5 release. We need to match the
  494. // old (incorrect) conditions when built with old XCode, but can use the
  495. // corrected earlier versions with new XCode.
  496. #if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \
  497. ((_LIBCPP_VERSION >= 11000 && /* XCode 12.5 or later: */ \
  498. ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
  499. __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
  500. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
  501. __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 110000) || \
  502. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
  503. __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 40000) || \
  504. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
  505. __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 110000))) || \
  506. (_LIBCPP_VERSION < 11000 && /* Pre-XCode 12.5: */ \
  507. ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
  508. __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \
  509. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
  510. __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
  511. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
  512. __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
  513. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
  514. __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))))
  515. #define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
  516. #else
  517. #define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
  518. #endif
  519. // ABSL_HAVE_STD_ANY
  520. //
  521. // Checks whether C++17 std::any is available by checking whether <any> exists.
  522. #ifdef ABSL_HAVE_STD_ANY
  523. #error "ABSL_HAVE_STD_ANY cannot be directly set."
  524. #endif
  525. #ifdef __has_include
  526. #if __has_include(<any>) && defined(__cplusplus) && __cplusplus >= 201703L && \
  527. !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  528. #define ABSL_HAVE_STD_ANY 1
  529. #endif
  530. #endif
  531. // ABSL_HAVE_STD_OPTIONAL
  532. //
  533. // Checks whether C++17 std::optional is available.
  534. #ifdef ABSL_HAVE_STD_OPTIONAL
  535. #error "ABSL_HAVE_STD_OPTIONAL cannot be directly set."
  536. #endif
  537. #ifdef __has_include
  538. #if __has_include(<optional>) && defined(__cplusplus) && \
  539. __cplusplus >= 201703L && !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  540. #define ABSL_HAVE_STD_OPTIONAL 1
  541. #endif
  542. #endif
  543. // ABSL_HAVE_STD_VARIANT
  544. //
  545. // Checks whether C++17 std::variant is available.
  546. #ifdef ABSL_HAVE_STD_VARIANT
  547. #error "ABSL_HAVE_STD_VARIANT cannot be directly set."
  548. #endif
  549. #ifdef __has_include
  550. #if __has_include(<variant>) && defined(__cplusplus) && \
  551. __cplusplus >= 201703L && !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  552. #define ABSL_HAVE_STD_VARIANT 1
  553. #endif
  554. #endif
  555. // ABSL_HAVE_STD_STRING_VIEW
  556. //
  557. // Checks whether C++17 std::string_view is available.
  558. #ifdef ABSL_HAVE_STD_STRING_VIEW
  559. #error "ABSL_HAVE_STD_STRING_VIEW cannot be directly set."
  560. #endif
  561. #ifdef __has_include
  562. #if __has_include(<string_view>) && defined(__cplusplus) && \
  563. __cplusplus >= 201703L
  564. #define ABSL_HAVE_STD_STRING_VIEW 1
  565. #endif
  566. #endif
  567. // For MSVC, `__has_include` is supported in VS 2017 15.3, which is later than
  568. // the support for <optional>, <any>, <string_view>, <variant>. So we use
  569. // _MSC_VER to check whether we have VS 2017 RTM (when <optional>, <any>,
  570. // <string_view>, <variant> is implemented) or higher. Also, `__cplusplus` is
  571. // not correctly set by MSVC, so we use `_MSVC_LANG` to check the language
  572. // version.
  573. // TODO(zhangxy): fix tests before enabling aliasing for `std::any`.
  574. #if defined(_MSC_VER) && _MSC_VER >= 1910 && \
  575. ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || \
  576. (defined(__cplusplus) && __cplusplus > 201402))
  577. // #define ABSL_HAVE_STD_ANY 1
  578. #define ABSL_HAVE_STD_OPTIONAL 1
  579. #define ABSL_HAVE_STD_VARIANT 1
  580. #define ABSL_HAVE_STD_STRING_VIEW 1
  581. #endif
  582. // ABSL_USES_STD_ANY
  583. //
  584. // Indicates whether absl::any is an alias for std::any.
  585. #if !defined(ABSL_OPTION_USE_STD_ANY)
  586. #error options.h is misconfigured.
  587. #elif ABSL_OPTION_USE_STD_ANY == 0 || \
  588. (ABSL_OPTION_USE_STD_ANY == 2 && !defined(ABSL_HAVE_STD_ANY))
  589. #undef ABSL_USES_STD_ANY
  590. #elif ABSL_OPTION_USE_STD_ANY == 1 || \
  591. (ABSL_OPTION_USE_STD_ANY == 2 && defined(ABSL_HAVE_STD_ANY))
  592. #define ABSL_USES_STD_ANY 1
  593. #else
  594. #error options.h is misconfigured.
  595. #endif
  596. // ABSL_USES_STD_OPTIONAL
  597. //
  598. // Indicates whether absl::optional is an alias for std::optional.
  599. #if !defined(ABSL_OPTION_USE_STD_OPTIONAL)
  600. #error options.h is misconfigured.
  601. #elif ABSL_OPTION_USE_STD_OPTIONAL == 0 || \
  602. (ABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(ABSL_HAVE_STD_OPTIONAL))
  603. #undef ABSL_USES_STD_OPTIONAL
  604. #elif ABSL_OPTION_USE_STD_OPTIONAL == 1 || \
  605. (ABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(ABSL_HAVE_STD_OPTIONAL))
  606. #define ABSL_USES_STD_OPTIONAL 1
  607. #else
  608. #error options.h is misconfigured.
  609. #endif
  610. // ABSL_USES_STD_VARIANT
  611. //
  612. // Indicates whether absl::variant is an alias for std::variant.
  613. #if !defined(ABSL_OPTION_USE_STD_VARIANT)
  614. #error options.h is misconfigured.
  615. #elif ABSL_OPTION_USE_STD_VARIANT == 0 || \
  616. (ABSL_OPTION_USE_STD_VARIANT == 2 && !defined(ABSL_HAVE_STD_VARIANT))
  617. #undef ABSL_USES_STD_VARIANT
  618. #elif ABSL_OPTION_USE_STD_VARIANT == 1 || \
  619. (ABSL_OPTION_USE_STD_VARIANT == 2 && defined(ABSL_HAVE_STD_VARIANT))
  620. #define ABSL_USES_STD_VARIANT 1
  621. #else
  622. #error options.h is misconfigured.
  623. #endif
  624. // ABSL_USES_STD_STRING_VIEW
  625. //
  626. // Indicates whether absl::string_view is an alias for std::string_view.
  627. #if !defined(ABSL_OPTION_USE_STD_STRING_VIEW)
  628. #error options.h is misconfigured.
  629. #elif ABSL_OPTION_USE_STD_STRING_VIEW == 0 || \
  630. (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
  631. !defined(ABSL_HAVE_STD_STRING_VIEW))
  632. #undef ABSL_USES_STD_STRING_VIEW
  633. #elif ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
  634. (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
  635. defined(ABSL_HAVE_STD_STRING_VIEW))
  636. #define ABSL_USES_STD_STRING_VIEW 1
  637. #else
  638. #error options.h is misconfigured.
  639. #endif
  640. // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION
  641. // SEH exception from emplace for variant<SomeStruct> when constructing the
  642. // struct can throw. This defeats some of variant_test and
  643. // variant_exception_safety_test.
  644. #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG)
  645. #define ABSL_INTERNAL_MSVC_2017_DBG_MODE
  646. #endif
  647. // ABSL_INTERNAL_MANGLED_NS
  648. // ABSL_INTERNAL_MANGLED_BACKREFERENCE
  649. //
  650. // Internal macros for building up mangled names in our internal fork of CCTZ.
  651. // This implementation detail is only needed and provided for the MSVC build.
  652. //
  653. // These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is
  654. // the mangled spelling of the `absl` namespace, and
  655. // ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing
  656. // the proper count to skip past the CCTZ fork namespace names. (This number
  657. // is one larger when there is an inline namespace name to skip.)
  658. #if defined(_MSC_VER)
  659. #if ABSL_OPTION_USE_INLINE_NAMESPACE == 0
  660. #define ABSL_INTERNAL_MANGLED_NS "absl"
  661. #define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5"
  662. #else
  663. #define ABSL_INTERNAL_MANGLED_NS \
  664. ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) \
  665. "@absl"
  666. #define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6"
  667. #endif
  668. #endif
  669. // ABSL_DLL
  670. //
  671. // When building Abseil as a DLL, this macro expands to `__declspec(dllexport)`
  672. // so we can annotate symbols appropriately as being exported. When used in
  673. // headers consuming a DLL, this macro expands to `__declspec(dllimport)` so
  674. // that consumers know the symbol is defined inside the DLL. In all other cases,
  675. // the macro expands to nothing.
  676. #if defined(_MSC_VER)
  677. #if defined(ABSL_BUILD_DLL)
  678. #define ABSL_DLL __declspec(dllexport)
  679. #elif defined(ABSL_CONSUME_DLL)
  680. #define ABSL_DLL __declspec(dllimport)
  681. #else
  682. #define ABSL_DLL
  683. #endif
  684. #else
  685. #define ABSL_DLL
  686. #endif // defined(_MSC_VER)
  687. // ABSL_HAVE_MEMORY_SANITIZER
  688. //
  689. // MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of
  690. // a compiler instrumentation module and a run-time library.
  691. #ifdef ABSL_HAVE_MEMORY_SANITIZER
  692. #error "ABSL_HAVE_MEMORY_SANITIZER cannot be directly set."
  693. #elif !defined(__native_client__) && ABSL_HAVE_FEATURE(memory_sanitizer)
  694. #define ABSL_HAVE_MEMORY_SANITIZER 1
  695. #endif
  696. // ABSL_HAVE_THREAD_SANITIZER
  697. //
  698. // ThreadSanitizer (TSan) is a fast data race detector.
  699. #ifdef ABSL_HAVE_THREAD_SANITIZER
  700. #error "ABSL_HAVE_THREAD_SANITIZER cannot be directly set."
  701. #elif defined(__SANITIZE_THREAD__)
  702. #define ABSL_HAVE_THREAD_SANITIZER 1
  703. #elif ABSL_HAVE_FEATURE(thread_sanitizer)
  704. #define ABSL_HAVE_THREAD_SANITIZER 1
  705. #endif
  706. // ABSL_HAVE_ADDRESS_SANITIZER
  707. //
  708. // AddressSanitizer (ASan) is a fast memory error detector.
  709. #ifdef ABSL_HAVE_ADDRESS_SANITIZER
  710. #error "ABSL_HAVE_ADDRESS_SANITIZER cannot be directly set."
  711. #elif defined(__SANITIZE_ADDRESS__)
  712. #define ABSL_HAVE_ADDRESS_SANITIZER 1
  713. #elif ABSL_HAVE_FEATURE(address_sanitizer)
  714. #define ABSL_HAVE_ADDRESS_SANITIZER 1
  715. #endif
  716. // ABSL_HAVE_HWADDRESS_SANITIZER
  717. //
  718. // Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan
  719. // memory error detector which can use CPU features like ARM TBI, Intel LAM or
  720. // AMD UAI.
  721. #ifdef ABSL_HAVE_HWADDRESS_SANITIZER
  722. #error "ABSL_HAVE_HWADDRESS_SANITIZER cannot be directly set."
  723. #elif defined(__SANITIZE_HWADDRESS__)
  724. #define ABSL_HAVE_HWADDRESS_SANITIZER 1
  725. #elif ABSL_HAVE_FEATURE(hwaddress_sanitizer)
  726. #define ABSL_HAVE_HWADDRESS_SANITIZER 1
  727. #endif
  728. // ABSL_HAVE_LEAK_SANITIZER
  729. //
  730. // LeakSanitizer (or lsan) is a detector of memory leaks.
  731. // https://clang.llvm.org/docs/LeakSanitizer.html
  732. // https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
  733. //
  734. // The macro ABSL_HAVE_LEAK_SANITIZER can be used to detect at compile-time
  735. // whether the LeakSanitizer is potentially available. However, just because the
  736. // LeakSanitizer is available does not mean it is active. Use the
  737. // always-available run-time interface in //absl/debugging/leak_check.h for
  738. // interacting with LeakSanitizer.
  739. #ifdef ABSL_HAVE_LEAK_SANITIZER
  740. #error "ABSL_HAVE_LEAK_SANITIZER cannot be directly set."
  741. #elif defined(LEAK_SANITIZER)
  742. // GCC provides no method for detecting the presense of the standalone
  743. // LeakSanitizer (-fsanitize=leak), so GCC users of -fsanitize=leak should also
  744. // use -DLEAK_SANITIZER.
  745. #define ABSL_HAVE_LEAK_SANITIZER 1
  746. // Clang standalone LeakSanitizer (-fsanitize=leak)
  747. #elif ABSL_HAVE_FEATURE(leak_sanitizer)
  748. #define ABSL_HAVE_LEAK_SANITIZER 1
  749. #elif defined(ABSL_HAVE_ADDRESS_SANITIZER)
  750. // GCC or Clang using the LeakSanitizer integrated into AddressSanitizer.
  751. #define ABSL_HAVE_LEAK_SANITIZER 1
  752. #endif
  753. // ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  754. //
  755. // Class template argument deduction is a language feature added in C++17.
  756. #ifdef ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  757. #error "ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION cannot be directly set."
  758. #elif defined(__cpp_deduction_guides)
  759. #define ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
  760. #endif
  761. // ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
  762. //
  763. // Prior to C++17, static constexpr variables defined in classes required a
  764. // separate definition outside of the class body, for example:
  765. //
  766. // class Foo {
  767. // static constexpr int kBar = 0;
  768. // };
  769. // constexpr int Foo::kBar;
  770. //
  771. // In C++17, these variables defined in classes are considered inline variables,
  772. // and the extra declaration is redundant. Since some compilers warn on the
  773. // extra declarations, ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL can be used
  774. // conditionally ignore them:
  775. //
  776. // #ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
  777. // constexpr int Foo::kBar;
  778. // #endif
  779. #if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  780. ABSL_INTERNAL_CPLUSPLUS_LANG < 201703L
  781. #define ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
  782. #endif
  783. // `ABSL_INTERNAL_HAS_RTTI` determines whether abseil is being compiled with
  784. // RTTI support.
  785. #ifdef ABSL_INTERNAL_HAS_RTTI
  786. #error ABSL_INTERNAL_HAS_RTTI cannot be directly set
  787. #elif !defined(__GNUC__) || defined(__GXX_RTTI)
  788. #define ABSL_INTERNAL_HAS_RTTI 1
  789. #endif // !defined(__GNUC__) || defined(__GXX_RTTI)
  790. // ABSL_INTERNAL_HAVE_SSE is used for compile-time detection of SSE support.
  791. // See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
  792. // which architectures support the various x86 instruction sets.
  793. #ifdef ABSL_INTERNAL_HAVE_SSE
  794. #error ABSL_INTERNAL_HAVE_SSE cannot be directly set
  795. #elif defined(__SSE__)
  796. #define ABSL_INTERNAL_HAVE_SSE 1
  797. #elif defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)
  798. // MSVC only defines _M_IX86_FP for x86 32-bit code, and _M_IX86_FP >= 1
  799. // indicates that at least SSE was targeted with the /arch:SSE option.
  800. // All x86-64 processors support SSE, so support can be assumed.
  801. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  802. #define ABSL_INTERNAL_HAVE_SSE 1
  803. #endif
  804. // ABSL_INTERNAL_HAVE_SSE2 is used for compile-time detection of SSE2 support.
  805. // See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
  806. // which architectures support the various x86 instruction sets.
  807. #ifdef ABSL_INTERNAL_HAVE_SSE2
  808. #error ABSL_INTERNAL_HAVE_SSE2 cannot be directly set
  809. #elif defined(__SSE2__)
  810. #define ABSL_INTERNAL_HAVE_SSE2 1
  811. #elif defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
  812. // MSVC only defines _M_IX86_FP for x86 32-bit code, and _M_IX86_FP >= 2
  813. // indicates that at least SSE2 was targeted with the /arch:SSE2 option.
  814. // All x86-64 processors support SSE2, so support can be assumed.
  815. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  816. #define ABSL_INTERNAL_HAVE_SSE2 1
  817. #endif
  818. // ABSL_INTERNAL_HAVE_SSSE3 is used for compile-time detection of SSSE3 support.
  819. // See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
  820. // which architectures support the various x86 instruction sets.
  821. //
  822. // MSVC does not have a mode that targets SSSE3 at compile-time. To use SSSE3
  823. // with MSVC requires either assuming that the code will only every run on CPUs
  824. // that support SSSE3, otherwise __cpuid() can be used to detect support at
  825. // runtime and fallback to a non-SSSE3 implementation when SSSE3 is unsupported
  826. // by the CPU.
  827. #ifdef ABSL_INTERNAL_HAVE_SSSE3
  828. #error ABSL_INTERNAL_HAVE_SSSE3 cannot be directly set
  829. #elif defined(__SSSE3__)
  830. #define ABSL_INTERNAL_HAVE_SSSE3 1
  831. #endif
  832. // ABSL_INTERNAL_HAVE_ARM_NEON is used for compile-time detection of NEON (ARM
  833. // SIMD).
  834. #ifdef ABSL_INTERNAL_HAVE_ARM_NEON
  835. #error ABSL_INTERNAL_HAVE_ARM_NEON cannot be directly set
  836. #elif defined(__ARM_NEON)
  837. #define ABSL_INTERNAL_HAVE_ARM_NEON 1
  838. #endif
  839. #endif // ABSL_BASE_CONFIG_H_