config.h 37 KB

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