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

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