config.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  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 (`Y_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 "y_absl/base/config.h"
  37. //
  38. // #ifdef Y_ABSL_HAVE_MMAP
  39. // #include "sys/mman.h"
  40. // #endif //Y_ABSL_HAVE_MMAP
  41. //
  42. // ...
  43. // #ifdef Y_ABSL_HAVE_MMAP
  44. // void *ptr = mmap(...);
  45. // ...
  46. // #endif // Y_ABSL_HAVE_MMAP
  47. #ifndef Y_ABSL_BASE_CONFIG_H_
  48. #define Y_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. // Y_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 Y_ABSL_INTERNAL_CPLUSPLUS_LANG _MSVC_LANG
  70. #elif defined(__cplusplus)
  71. #define Y_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 "y_absl/base/options.h"
  80. #include "y_absl/base/policy_checks.h"
  81. // Abseil long-term support (LTS) releases will define
  82. // `Y_ABSL_LTS_RELEASE_VERSION` to the integer representing the date string of the
  83. // LTS release version, and will define `Y_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. // Y_ABSL_LTS_RELEASE_VERSION == 20300401 && Y_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(Y_ABSL_LTS_RELEASE_VERSION) && Y_ABSL_LTS_RELEASE_VERSION < 20300401
  96. // #error Project foo requires Abseil LTS version >= 20300401
  97. // #endif
  98. //
  99. // The `defined(Y_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 Y_ABSL_LTS_RELEASE_VERSION 20230802
  108. #define Y_ABSL_LTS_RELEASE_PATCH_LEVEL 1
  109. // Helper macro to convert a CPP variable to a string literal.
  110. #define Y_ABSL_INTERNAL_DO_TOKEN_STR(x) #x
  111. #define Y_ABSL_INTERNAL_TOKEN_STR(x) Y_ABSL_INTERNAL_DO_TOKEN_STR(x)
  112. // -----------------------------------------------------------------------------
  113. // Abseil namespace annotations
  114. // -----------------------------------------------------------------------------
  115. // Y_ABSL_NAMESPACE_BEGIN/Y_ABSL_NAMESPACE_END
  116. //
  117. // An annotation placed at the beginning/end of each `namespace y_absl` scope.
  118. // This is used to inject an inline namespace.
  119. //
  120. // The proper way to write Abseil code in the `y_absl` namespace is:
  121. //
  122. // namespace y_absl {
  123. // Y_ABSL_NAMESPACE_BEGIN
  124. //
  125. // void Foo(); // y_absl::Foo().
  126. //
  127. // Y_ABSL_NAMESPACE_END
  128. // } // namespace y_absl
  129. //
  130. // Users of Abseil should not use these macros, because users of Abseil should
  131. // not write `namespace y_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(Y_ABSL_OPTION_USE_INLINE_NAMESPACE) || \
  136. !defined(Y_ABSL_OPTION_INLINE_NAMESPACE_NAME)
  137. #error options.h is misconfigured.
  138. #endif
  139. // Check that Y_ABSL_OPTION_INLINE_NAMESPACE_NAME is neither "head" nor ""
  140. #if defined(__cplusplus) && Y_ABSL_OPTION_USE_INLINE_NAMESPACE == 1
  141. #define Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR \
  142. Y_ABSL_INTERNAL_TOKEN_STR(Y_ABSL_OPTION_INLINE_NAMESPACE_NAME)
  143. static_assert(Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0',
  144. "options.h misconfigured: Y_ABSL_OPTION_INLINE_NAMESPACE_NAME must "
  145. "not be empty.");
  146. static_assert(Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
  147. Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' ||
  148. Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' ||
  149. Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' ||
  150. Y_ABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0',
  151. "options.h misconfigured: Y_ABSL_OPTION_INLINE_NAMESPACE_NAME must "
  152. "be changed to a new, unique identifier name.");
  153. #endif
  154. #if Y_ABSL_OPTION_USE_INLINE_NAMESPACE == 0
  155. #define Y_ABSL_NAMESPACE_BEGIN
  156. #define Y_ABSL_NAMESPACE_END
  157. #define Y_ABSL_INTERNAL_C_SYMBOL(x) x
  158. #elif Y_ABSL_OPTION_USE_INLINE_NAMESPACE == 1
  159. #define Y_ABSL_NAMESPACE_BEGIN \
  160. inline namespace Y_ABSL_OPTION_INLINE_NAMESPACE_NAME {
  161. #define Y_ABSL_NAMESPACE_END }
  162. #define Y_ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v) x##_##v
  163. #define Y_ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, v) \
  164. Y_ABSL_INTERNAL_C_SYMBOL_HELPER_2(x, v)
  165. #define Y_ABSL_INTERNAL_C_SYMBOL(x) \
  166. Y_ABSL_INTERNAL_C_SYMBOL_HELPER_1(x, Y_ABSL_OPTION_INLINE_NAMESPACE_NAME)
  167. #else
  168. #error options.h is misconfigured.
  169. #endif
  170. // -----------------------------------------------------------------------------
  171. // Compiler Feature Checks
  172. // -----------------------------------------------------------------------------
  173. // Y_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 Y_ABSL_HAVE_BUILTIN(x) __has_builtin(x)
  184. #else
  185. #define Y_ABSL_HAVE_BUILTIN(x) 0
  186. #endif
  187. #ifdef __has_feature
  188. #define Y_ABSL_HAVE_FEATURE(f) __has_feature(f)
  189. #else
  190. #define Y_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 Y_ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(x, y) \
  196. (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
  197. #else
  198. #define Y_ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(x, y) 0
  199. #endif
  200. #if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
  201. #define Y_ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(x, y) \
  202. (__clang_major__ > (x) || __clang_major__ == (x) && __clang_minor__ >= (y))
  203. #else
  204. #define Y_ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(x, y) 0
  205. #endif
  206. // Y_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 Y_ABSL_HAVE_TLS
  210. #error Y_ABSL_HAVE_TLS cannot be directly set
  211. #elif (defined(__linux__) || defined(__ASYLO__)) && \
  212. (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
  213. #define Y_ABSL_HAVE_TLS 1
  214. #endif
  215. // Y_ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
  216. //
  217. // Checks whether `std::is_trivially_destructible<T>` is supported.
  218. #ifdef Y_ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
  219. #error Y_ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set
  220. #define Y_ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1
  221. #endif
  222. // Y_ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
  223. //
  224. // Checks whether `std::is_trivially_default_constructible<T>` and
  225. // `std::is_trivially_copy_constructible<T>` are supported.
  226. #ifdef Y_ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
  227. #error Y_ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set
  228. #else
  229. #define Y_ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1
  230. #endif
  231. // Y_ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
  232. //
  233. // Checks whether `std::is_trivially_copy_assignable<T>` is supported.
  234. #ifdef Y_ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
  235. #error Y_ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot be directly set
  236. #else
  237. #define Y_ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
  238. #endif
  239. // Y_ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
  240. //
  241. // Checks whether `std::is_trivially_copyable<T>` is supported.
  242. #ifdef Y_ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
  243. #error Y_ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
  244. #define Y_ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
  245. #endif
  246. // Y_ABSL_HAVE_THREAD_LOCAL
  247. //
  248. // Checks whether C++11's `thread_local` storage duration specifier is
  249. // supported.
  250. #ifdef Y_ABSL_HAVE_THREAD_LOCAL
  251. #error Y_ABSL_HAVE_THREAD_LOCAL cannot be directly set
  252. #elif defined(__APPLE__)
  253. // Notes:
  254. // * Xcode's clang did not support `thread_local` until version 8, and
  255. // even then not for all iOS < 9.0.
  256. // * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator
  257. // targeting iOS 9.x.
  258. // * Xcode 10 moves the deployment target check for iOS < 9.0 to link time
  259. // making Y_ABSL_HAVE_FEATURE unreliable there.
  260. //
  261. #if Y_ABSL_HAVE_FEATURE(cxx_thread_local) && \
  262. !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
  263. #define Y_ABSL_HAVE_THREAD_LOCAL 1
  264. #endif
  265. #else // !defined(__APPLE__)
  266. #define Y_ABSL_HAVE_THREAD_LOCAL 1
  267. #endif
  268. // There are platforms for which TLS should not be used even though the compiler
  269. // makes it seem like it's supported (Android NDK < r12b for example).
  270. // This is primarily because of linker problems and toolchain misconfiguration:
  271. // Abseil does not intend to support this indefinitely. Currently, the newest
  272. // toolchain that we intend to support that requires this behavior is the
  273. // r11 NDK - allowing for a 5 year support window on that means this option
  274. // is likely to be removed around June of 2021.
  275. // TLS isn't supported until NDK r12b per
  276. // https://developer.android.com/ndk/downloads/revision_history.html
  277. // Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in
  278. // <android/ndk-version.h>. For NDK < r16, users should define these macros,
  279. // e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11.
  280. #if defined(__ANDROID__) && defined(__clang__)
  281. #if __has_include(<android/ndk-version.h>)
  282. #include <android/ndk-version.h>
  283. #endif // __has_include(<android/ndk-version.h>)
  284. #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \
  285. defined(__NDK_MINOR__) && \
  286. ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))
  287. #undef Y_ABSL_HAVE_TLS
  288. #undef Y_ABSL_HAVE_THREAD_LOCAL
  289. #endif
  290. #endif // defined(__ANDROID__) && defined(__clang__)
  291. // Y_ABSL_HAVE_INTRINSIC_INT128
  292. //
  293. // Checks whether the __int128 compiler extension for a 128-bit integral type is
  294. // supported.
  295. //
  296. // Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is
  297. // supported, but we avoid using it in certain cases:
  298. // * On Clang:
  299. // * Building using Clang for Windows, where the Clang runtime library has
  300. // 128-bit support only on LP64 architectures, but Windows is LLP64.
  301. // * On Nvidia's nvcc:
  302. // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions
  303. // actually support __int128.
  304. #ifdef Y_ABSL_HAVE_INTRINSIC_INT128
  305. #error Y_ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
  306. #elif defined(__SIZEOF_INT128__)
  307. #if (defined(__clang__) && !defined(_WIN32)) || \
  308. (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
  309. (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
  310. #define Y_ABSL_HAVE_INTRINSIC_INT128 1
  311. #elif defined(__CUDACC__)
  312. // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a
  313. // string explaining that it has been removed starting with CUDA 9. We use
  314. // nested #ifs because there is no short-circuiting in the preprocessor.
  315. // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined.
  316. #if __CUDACC_VER__ >= 70000
  317. #define Y_ABSL_HAVE_INTRINSIC_INT128 1
  318. #endif // __CUDACC_VER__ >= 70000
  319. #endif // defined(__CUDACC__)
  320. #endif // Y_ABSL_HAVE_INTRINSIC_INT128
  321. // Y_ABSL_HAVE_EXCEPTIONS
  322. //
  323. // Checks whether the compiler both supports and enables exceptions. Many
  324. // compilers support a "no exceptions" mode that disables exceptions.
  325. //
  326. // Generally, when Y_ABSL_HAVE_EXCEPTIONS is not defined:
  327. //
  328. // * Code using `throw` and `try` may not compile.
  329. // * The `noexcept` specifier will still compile and behave as normal.
  330. // * The `noexcept` operator may still return `false`.
  331. //
  332. // For further details, consult the compiler's documentation.
  333. #ifdef Y_ABSL_HAVE_EXCEPTIONS
  334. #error Y_ABSL_HAVE_EXCEPTIONS cannot be directly set.
  335. #elif Y_ABSL_INTERNAL_HAVE_MIN_CLANG_VERSION(3, 6)
  336. // Clang >= 3.6
  337. #if Y_ABSL_HAVE_FEATURE(cxx_exceptions)
  338. #define Y_ABSL_HAVE_EXCEPTIONS 1
  339. #endif // Y_ABSL_HAVE_FEATURE(cxx_exceptions)
  340. #elif defined(__clang__)
  341. // Clang < 3.6
  342. // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro
  343. #if defined(__EXCEPTIONS) && Y_ABSL_HAVE_FEATURE(cxx_exceptions)
  344. #define Y_ABSL_HAVE_EXCEPTIONS 1
  345. #endif // defined(__EXCEPTIONS) && Y_ABSL_HAVE_FEATURE(cxx_exceptions)
  346. // Handle remaining special cases and default to exceptions being supported.
  347. #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \
  348. !(Y_ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(5, 0) && \
  349. !defined(__cpp_exceptions)) && \
  350. !(defined(_MSC_VER) && !defined(_CPPUNWIND))
  351. #define Y_ABSL_HAVE_EXCEPTIONS 1
  352. #endif
  353. // -----------------------------------------------------------------------------
  354. // Platform Feature Checks
  355. // -----------------------------------------------------------------------------
  356. // Currently supported operating systems and associated preprocessor
  357. // symbols:
  358. //
  359. // Linux and Linux-derived __linux__
  360. // Android __ANDROID__ (implies __linux__)
  361. // Linux (non-Android) __linux__ && !__ANDROID__
  362. // Darwin (macOS and iOS) __APPLE__
  363. // Akaros (http://akaros.org) __ros__
  364. // Windows _WIN32
  365. // NaCL __native_client__
  366. // AsmJS __asmjs__
  367. // WebAssembly __wasm__
  368. // Fuchsia __Fuchsia__
  369. //
  370. // Note that since Android defines both __ANDROID__ and __linux__, one
  371. // may probe for either Linux or Android by simply testing for __linux__.
  372. // Y_ABSL_HAVE_MMAP
  373. //
  374. // Checks whether the platform has an mmap(2) implementation as defined in
  375. // POSIX.1-2001.
  376. #ifdef Y_ABSL_HAVE_MMAP
  377. #error Y_ABSL_HAVE_MMAP cannot be directly set
  378. #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
  379. defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
  380. defined(__asmjs__) || defined(__wasm__) || defined(__Fuchsia__) || \
  381. defined(__sun) || defined(__ASYLO__) || defined(__myriad2__) || \
  382. defined(__HAIKU__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
  383. defined(__QNX__) || defined(__VXWORKS__) || defined(__hexagon__)
  384. #define Y_ABSL_HAVE_MMAP 1
  385. #endif
  386. // Y_ABSL_HAVE_PTHREAD_GETSCHEDPARAM
  387. //
  388. // Checks whether the platform implements the pthread_(get|set)schedparam(3)
  389. // functions as defined in POSIX.1-2001.
  390. #ifdef Y_ABSL_HAVE_PTHREAD_GETSCHEDPARAM
  391. #error Y_ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
  392. #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
  393. defined(_AIX) || defined(__ros__) || defined(__OpenBSD__) || \
  394. defined(__NetBSD__) || defined(__VXWORKS__)
  395. #define Y_ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
  396. #endif
  397. // Y_ABSL_HAVE_SCHED_GETCPU
  398. //
  399. // Checks whether sched_getcpu is available.
  400. #ifdef Y_ABSL_HAVE_SCHED_GETCPU
  401. #error Y_ABSL_HAVE_SCHED_GETCPU cannot be directly set
  402. #elif defined(__linux__)
  403. #define Y_ABSL_HAVE_SCHED_GETCPU 1
  404. #endif
  405. // Y_ABSL_HAVE_SCHED_YIELD
  406. //
  407. // Checks whether the platform implements sched_yield(2) as defined in
  408. // POSIX.1-2001.
  409. #ifdef Y_ABSL_HAVE_SCHED_YIELD
  410. #error Y_ABSL_HAVE_SCHED_YIELD cannot be directly set
  411. #elif defined(__linux__) || defined(__ros__) || defined(__native_client__) || \
  412. defined(__VXWORKS__)
  413. #define Y_ABSL_HAVE_SCHED_YIELD 1
  414. #endif
  415. // Y_ABSL_HAVE_SEMAPHORE_H
  416. //
  417. // Checks whether the platform supports the <semaphore.h> header and sem_init(3)
  418. // family of functions as standardized in POSIX.1-2001.
  419. //
  420. // Note: While Apple provides <semaphore.h> for both iOS and macOS, it is
  421. // explicitly deprecated and will cause build failures if enabled for those
  422. // platforms. We side-step the issue by not defining it here for Apple
  423. // platforms.
  424. #ifdef Y_ABSL_HAVE_SEMAPHORE_H
  425. #error Y_ABSL_HAVE_SEMAPHORE_H cannot be directly set
  426. #elif defined(__linux__) || defined(__ros__) || defined(__VXWORKS__)
  427. #define Y_ABSL_HAVE_SEMAPHORE_H 1
  428. #endif
  429. // Y_ABSL_HAVE_ALARM
  430. //
  431. // Checks whether the platform supports the <signal.h> header and alarm(2)
  432. // function as standardized in POSIX.1-2001.
  433. #ifdef Y_ABSL_HAVE_ALARM
  434. #error Y_ABSL_HAVE_ALARM cannot be directly set
  435. #elif defined(__GOOGLE_GRTE_VERSION__)
  436. // feature tests for Google's GRTE
  437. #define Y_ABSL_HAVE_ALARM 1
  438. #elif defined(__GLIBC__)
  439. // feature test for glibc
  440. #define Y_ABSL_HAVE_ALARM 1
  441. #elif defined(_MSC_VER)
  442. // feature tests for Microsoft's library
  443. #elif defined(__MINGW32__)
  444. // mingw32 doesn't provide alarm(2):
  445. // https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h
  446. // mingw-w64 provides a no-op implementation:
  447. // https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c
  448. #elif defined(__EMSCRIPTEN__)
  449. // emscripten doesn't support signals
  450. #elif defined(__Fuchsia__)
  451. // Signals don't exist on fuchsia.
  452. #elif defined(__native_client__)
  453. // Signals don't exist on hexagon/QuRT
  454. #elif defined(__hexagon__)
  455. #else
  456. // other standard libraries
  457. #define Y_ABSL_HAVE_ALARM 1
  458. #endif
  459. // Y_ABSL_IS_LITTLE_ENDIAN
  460. // Y_ABSL_IS_BIG_ENDIAN
  461. //
  462. // Checks the endianness of the platform.
  463. //
  464. // Notes: uses the built in endian macros provided by GCC (since 4.6) and
  465. // Clang (since 3.2); see
  466. // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html.
  467. // Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error.
  468. #if defined(Y_ABSL_IS_BIG_ENDIAN)
  469. #error "Y_ABSL_IS_BIG_ENDIAN cannot be directly set."
  470. #endif
  471. #if defined(Y_ABSL_IS_LITTLE_ENDIAN)
  472. #error "Y_ABSL_IS_LITTLE_ENDIAN cannot be directly set."
  473. #endif
  474. #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  475. __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  476. #define Y_ABSL_IS_LITTLE_ENDIAN 1
  477. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
  478. __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  479. #define Y_ABSL_IS_BIG_ENDIAN 1
  480. #elif defined(_WIN32)
  481. #define Y_ABSL_IS_LITTLE_ENDIAN 1
  482. #else
  483. #error "y_absl endian detection needs to be set up for your compiler"
  484. #endif
  485. // macOS < 10.13 and iOS < 12 don't support <any>, <optional>, or <variant>
  486. // because the libc++ shared library shipped on the system doesn't have the
  487. // requisite exported symbols. See
  488. // https://github.com/abseil/abseil-cpp/issues/207 and
  489. // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
  490. //
  491. // libc++ spells out the availability requirements in the file
  492. // llvm-project/libcxx/include/__config via the #define
  493. // _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. The set of versions has been
  494. // modified a few times, via
  495. // https://github.com/llvm/llvm-project/commit/7fb40e1569dd66292b647f4501b85517e9247953
  496. // and
  497. // https://github.com/llvm/llvm-project/commit/0bc451e7e137c4ccadcd3377250874f641ca514a
  498. // The second has the actually correct versions, thus, is what we copy here.
  499. #if defined(__APPLE__) && \
  500. ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
  501. __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
  502. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
  503. __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
  504. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
  505. __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
  506. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
  507. __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))
  508. #define Y_ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
  509. #else
  510. #define Y_ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
  511. #endif
  512. // Y_ABSL_HAVE_STD_ANY
  513. //
  514. // Checks whether C++17 std::any is available.
  515. #ifdef Y_ABSL_HAVE_STD_ANY
  516. #error "Y_ABSL_HAVE_STD_ANY cannot be directly set."
  517. #elif defined(__cpp_lib_any)
  518. #define Y_ABSL_HAVE_STD_ANY 1
  519. #elif defined(Y_ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  520. Y_ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
  521. !Y_ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  522. #define Y_ABSL_HAVE_STD_ANY 1
  523. #endif
  524. // Y_ABSL_HAVE_STD_OPTIONAL
  525. //
  526. // Checks whether C++17 std::optional is available.
  527. #ifdef Y_ABSL_HAVE_STD_OPTIONAL
  528. #error "Y_ABSL_HAVE_STD_OPTIONAL cannot be directly set."
  529. #elif defined(__cpp_lib_optional)
  530. #define Y_ABSL_HAVE_STD_OPTIONAL 1
  531. #elif defined(Y_ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  532. Y_ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
  533. !Y_ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  534. #define Y_ABSL_HAVE_STD_OPTIONAL 1
  535. #endif
  536. // Y_ABSL_HAVE_STD_VARIANT
  537. //
  538. // Checks whether C++17 std::variant is available.
  539. #ifdef Y_ABSL_HAVE_STD_VARIANT
  540. #error "Y_ABSL_HAVE_STD_VARIANT cannot be directly set."
  541. #elif defined(__cpp_lib_variant)
  542. #define Y_ABSL_HAVE_STD_VARIANT 1
  543. #elif defined(Y_ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  544. Y_ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
  545. !Y_ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
  546. #define Y_ABSL_HAVE_STD_VARIANT 1
  547. #endif
  548. // Y_ABSL_HAVE_STD_STRING_VIEW
  549. //
  550. // Checks whether C++17 std::string_view is available.
  551. #ifdef Y_ABSL_HAVE_STD_STRING_VIEW
  552. #error "Y_ABSL_HAVE_STD_STRING_VIEW cannot be directly set."
  553. #elif defined(__NVCC__)
  554. #define Y_ABSL_HAVE_STD_STRING_VIEW 1
  555. #elif defined(__cpp_lib_string_view)
  556. #define Y_ABSL_HAVE_STD_STRING_VIEW 1
  557. #elif defined(Y_ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  558. Y_ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
  559. #define Y_ABSL_HAVE_STD_STRING_VIEW 1
  560. #endif
  561. // Y_ABSL_USES_STD_ANY
  562. //
  563. // Indicates whether y_absl::any is an alias for std::any.
  564. #if !defined(Y_ABSL_OPTION_USE_STD_ANY)
  565. #error options.h is misconfigured.
  566. #elif Y_ABSL_OPTION_USE_STD_ANY == 0 || \
  567. (Y_ABSL_OPTION_USE_STD_ANY == 2 && !defined(Y_ABSL_HAVE_STD_ANY))
  568. #undef Y_ABSL_USES_STD_ANY
  569. #elif Y_ABSL_OPTION_USE_STD_ANY == 1 || \
  570. (Y_ABSL_OPTION_USE_STD_ANY == 2 && defined(Y_ABSL_HAVE_STD_ANY))
  571. #define Y_ABSL_USES_STD_ANY 1
  572. #else
  573. #error options.h is misconfigured.
  574. #endif
  575. // Y_ABSL_USES_STD_OPTIONAL
  576. //
  577. // Indicates whether y_absl::optional is an alias for std::optional.
  578. #if !defined(Y_ABSL_OPTION_USE_STD_OPTIONAL)
  579. #error options.h is misconfigured.
  580. #elif Y_ABSL_OPTION_USE_STD_OPTIONAL == 0 || \
  581. (Y_ABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(Y_ABSL_HAVE_STD_OPTIONAL))
  582. #undef Y_ABSL_USES_STD_OPTIONAL
  583. #elif Y_ABSL_OPTION_USE_STD_OPTIONAL == 1 || \
  584. (Y_ABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(Y_ABSL_HAVE_STD_OPTIONAL))
  585. #define Y_ABSL_USES_STD_OPTIONAL 1
  586. #else
  587. #error options.h is misconfigured.
  588. #endif
  589. // Y_ABSL_USES_STD_VARIANT
  590. //
  591. // Indicates whether y_absl::variant is an alias for std::variant.
  592. #if !defined(Y_ABSL_OPTION_USE_STD_VARIANT)
  593. #error options.h is misconfigured.
  594. #elif Y_ABSL_OPTION_USE_STD_VARIANT == 0 || \
  595. (Y_ABSL_OPTION_USE_STD_VARIANT == 2 && !defined(Y_ABSL_HAVE_STD_VARIANT))
  596. #undef Y_ABSL_USES_STD_VARIANT
  597. #elif Y_ABSL_OPTION_USE_STD_VARIANT == 1 || \
  598. (Y_ABSL_OPTION_USE_STD_VARIANT == 2 && defined(Y_ABSL_HAVE_STD_VARIANT))
  599. #define Y_ABSL_USES_STD_VARIANT 1
  600. #else
  601. #error options.h is misconfigured.
  602. #endif
  603. // Y_ABSL_USES_STD_STRING_VIEW
  604. //
  605. // Indicates whether y_absl::string_view is an alias for std::string_view.
  606. #if !defined(Y_ABSL_OPTION_USE_STD_STRING_VIEW)
  607. #error options.h is misconfigured.
  608. #elif Y_ABSL_OPTION_USE_STD_STRING_VIEW == 0 || \
  609. (Y_ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
  610. !defined(Y_ABSL_HAVE_STD_STRING_VIEW))
  611. #undef Y_ABSL_USES_STD_STRING_VIEW
  612. #elif Y_ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
  613. (Y_ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
  614. defined(Y_ABSL_HAVE_STD_STRING_VIEW))
  615. #define Y_ABSL_USES_STD_STRING_VIEW 1
  616. #else
  617. #error options.h is misconfigured.
  618. #endif
  619. // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION
  620. // SEH exception from emplace for variant<SomeStruct> when constructing the
  621. // struct can throw. This defeats some of variant_test and
  622. // variant_exception_safety_test.
  623. #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG)
  624. #define Y_ABSL_INTERNAL_MSVC_2017_DBG_MODE
  625. #endif
  626. // Y_ABSL_INTERNAL_MANGLED_NS
  627. // Y_ABSL_INTERNAL_MANGLED_BACKREFERENCE
  628. //
  629. // Internal macros for building up mangled names in our internal fork of CCTZ.
  630. // This implementation detail is only needed and provided for the MSVC build.
  631. //
  632. // These macros both expand to string literals. Y_ABSL_INTERNAL_MANGLED_NS is
  633. // the mangled spelling of the `y_absl` namespace, and
  634. // Y_ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing
  635. // the proper count to skip past the CCTZ fork namespace names. (This number
  636. // is one larger when there is an inline namespace name to skip.)
  637. #if defined(_MSC_VER)
  638. #if Y_ABSL_OPTION_USE_INLINE_NAMESPACE == 0
  639. #define Y_ABSL_INTERNAL_MANGLED_NS "y_absl"
  640. #define Y_ABSL_INTERNAL_MANGLED_BACKREFERENCE "5"
  641. #else
  642. #define Y_ABSL_INTERNAL_MANGLED_NS \
  643. Y_ABSL_INTERNAL_TOKEN_STR(Y_ABSL_OPTION_INLINE_NAMESPACE_NAME) "@y_absl"
  644. #define Y_ABSL_INTERNAL_MANGLED_BACKREFERENCE "6"
  645. #endif
  646. #endif
  647. // Y_ABSL_DLL
  648. //
  649. // When building Abseil as a DLL, this macro expands to `__declspec(dllexport)`
  650. // so we can annotate symbols appropriately as being exported. When used in
  651. // headers consuming a DLL, this macro expands to `__declspec(dllimport)` so
  652. // that consumers know the symbol is defined inside the DLL. In all other cases,
  653. // the macro expands to nothing.
  654. #if defined(_MSC_VER)
  655. #if defined(Y_ABSL_BUILD_DLL)
  656. #define Y_ABSL_DLL __declspec(dllexport)
  657. #elif defined(Y_ABSL_CONSUME_DLL)
  658. #define Y_ABSL_DLL __declspec(dllimport)
  659. #else
  660. #define Y_ABSL_DLL
  661. #endif
  662. #else
  663. #define Y_ABSL_DLL
  664. #endif // defined(_MSC_VER)
  665. #if defined(_MSC_VER)
  666. #if defined(Y_ABSL_BUILD_TEST_DLL)
  667. #define Y_ABSL_TEST_DLL __declspec(dllexport)
  668. #elif defined(Y_ABSL_CONSUME_TEST_DLL)
  669. #define Y_ABSL_TEST_DLL __declspec(dllimport)
  670. #else
  671. #define Y_ABSL_TEST_DLL
  672. #endif
  673. #else
  674. #define Y_ABSL_TEST_DLL
  675. #endif // defined(_MSC_VER)
  676. // Y_ABSL_HAVE_MEMORY_SANITIZER
  677. //
  678. // MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of
  679. // a compiler instrumentation module and a run-time library.
  680. #ifdef Y_ABSL_HAVE_MEMORY_SANITIZER
  681. #error "Y_ABSL_HAVE_MEMORY_SANITIZER cannot be directly set."
  682. #elif !defined(__native_client__) && Y_ABSL_HAVE_FEATURE(memory_sanitizer)
  683. #define Y_ABSL_HAVE_MEMORY_SANITIZER 1
  684. #endif
  685. // Y_ABSL_HAVE_THREAD_SANITIZER
  686. //
  687. // ThreadSanitizer (TSan) is a fast data race detector.
  688. #ifdef Y_ABSL_HAVE_THREAD_SANITIZER
  689. #error "Y_ABSL_HAVE_THREAD_SANITIZER cannot be directly set."
  690. #elif defined(__SANITIZE_THREAD__)
  691. #define Y_ABSL_HAVE_THREAD_SANITIZER 1
  692. #elif Y_ABSL_HAVE_FEATURE(thread_sanitizer)
  693. #define Y_ABSL_HAVE_THREAD_SANITIZER 1
  694. #endif
  695. // Y_ABSL_HAVE_ADDRESS_SANITIZER
  696. //
  697. // AddressSanitizer (ASan) is a fast memory error detector.
  698. #ifdef Y_ABSL_HAVE_ADDRESS_SANITIZER
  699. #error "Y_ABSL_HAVE_ADDRESS_SANITIZER cannot be directly set."
  700. #elif defined(__SANITIZE_ADDRESS__)
  701. #define Y_ABSL_HAVE_ADDRESS_SANITIZER 1
  702. #elif Y_ABSL_HAVE_FEATURE(address_sanitizer)
  703. #define Y_ABSL_HAVE_ADDRESS_SANITIZER 1
  704. #endif
  705. // Y_ABSL_HAVE_HWADDRESS_SANITIZER
  706. //
  707. // Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan
  708. // memory error detector which can use CPU features like ARM TBI, Intel LAM or
  709. // AMD UAI.
  710. #ifdef Y_ABSL_HAVE_HWADDRESS_SANITIZER
  711. #error "Y_ABSL_HAVE_HWADDRESS_SANITIZER cannot be directly set."
  712. #elif defined(__SANITIZE_HWADDRESS__)
  713. #define Y_ABSL_HAVE_HWADDRESS_SANITIZER 1
  714. #elif Y_ABSL_HAVE_FEATURE(hwaddress_sanitizer)
  715. #define Y_ABSL_HAVE_HWADDRESS_SANITIZER 1
  716. #endif
  717. // Y_ABSL_HAVE_DATAFLOW_SANITIZER
  718. //
  719. // Dataflow Sanitizer (or DFSAN) is a generalised dynamic data flow analysis.
  720. #ifdef Y_ABSL_HAVE_DATAFLOW_SANITIZER
  721. #error "Y_ABSL_HAVE_DATAFLOW_SANITIZER cannot be directly set."
  722. #elif defined(DATAFLOW_SANITIZER)
  723. // GCC provides no method for detecting the presence of the standalone
  724. // DataFlowSanitizer (-fsanitize=dataflow), so GCC users of -fsanitize=dataflow
  725. // should also use -DDATAFLOW_SANITIZER.
  726. #define Y_ABSL_HAVE_DATAFLOW_SANITIZER 1
  727. #elif Y_ABSL_HAVE_FEATURE(dataflow_sanitizer)
  728. #define Y_ABSL_HAVE_DATAFLOW_SANITIZER 1
  729. #endif
  730. // Y_ABSL_HAVE_LEAK_SANITIZER
  731. //
  732. // LeakSanitizer (or lsan) is a detector of memory leaks.
  733. // https://clang.llvm.org/docs/LeakSanitizer.html
  734. // https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
  735. //
  736. // The macro Y_ABSL_HAVE_LEAK_SANITIZER can be used to detect at compile-time
  737. // whether the LeakSanitizer is potentially available. However, just because the
  738. // LeakSanitizer is available does not mean it is active. Use the
  739. // always-available run-time interface in //y_absl/debugging/leak_check.h for
  740. // interacting with LeakSanitizer.
  741. #ifdef Y_ABSL_HAVE_LEAK_SANITIZER
  742. #error "Y_ABSL_HAVE_LEAK_SANITIZER cannot be directly set."
  743. #elif defined(LEAK_SANITIZER)
  744. // GCC provides no method for detecting the presence of the standalone
  745. // LeakSanitizer (-fsanitize=leak), so GCC users of -fsanitize=leak should also
  746. // use -DLEAK_SANITIZER.
  747. #define Y_ABSL_HAVE_LEAK_SANITIZER 1
  748. // Clang standalone LeakSanitizer (-fsanitize=leak)
  749. #elif Y_ABSL_HAVE_FEATURE(leak_sanitizer)
  750. #define Y_ABSL_HAVE_LEAK_SANITIZER 1
  751. #elif defined(Y_ABSL_HAVE_ADDRESS_SANITIZER)
  752. // GCC or Clang using the LeakSanitizer integrated into AddressSanitizer.
  753. #define Y_ABSL_HAVE_LEAK_SANITIZER 1
  754. #endif
  755. // Y_ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  756. //
  757. // Class template argument deduction is a language feature added in C++17.
  758. #ifdef Y_ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  759. #error "Y_ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION cannot be directly set."
  760. #elif defined(__cpp_deduction_guides)
  761. #define Y_ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
  762. #endif
  763. // Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
  764. //
  765. // Prior to C++17, static constexpr variables defined in classes required a
  766. // separate definition outside of the class body, for example:
  767. //
  768. // class Foo {
  769. // static constexpr int kBar = 0;
  770. // };
  771. // constexpr int Foo::kBar;
  772. //
  773. // In C++17, these variables defined in classes are considered inline variables,
  774. // and the extra declaration is redundant. Since some compilers warn on the
  775. // extra declarations, Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL can be used
  776. // conditionally ignore them:
  777. //
  778. // #ifdef Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
  779. // constexpr int Foo::kBar;
  780. // #endif
  781. #if defined(Y_ABSL_INTERNAL_CPLUSPLUS_LANG) && \
  782. Y_ABSL_INTERNAL_CPLUSPLUS_LANG < 201703L
  783. #define Y_ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
  784. #endif
  785. // `Y_ABSL_INTERNAL_HAS_RTTI` determines whether abseil is being compiled with
  786. // RTTI support.
  787. #ifdef Y_ABSL_INTERNAL_HAS_RTTI
  788. #error Y_ABSL_INTERNAL_HAS_RTTI cannot be directly set
  789. #elif (defined(__GNUC__) && defined(__GXX_RTTI)) || \
  790. (defined(_MSC_VER) && defined(_CPPRTTI)) || \
  791. (!defined(__GNUC__) && !defined(_MSC_VER))
  792. #define Y_ABSL_INTERNAL_HAS_RTTI 1
  793. #endif // !defined(__GNUC__) || defined(__GXX_RTTI)
  794. // Y_ABSL_INTERNAL_HAVE_SSE is used for compile-time detection of SSE support.
  795. // See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
  796. // which architectures support the various x86 instruction sets.
  797. #ifdef Y_ABSL_INTERNAL_HAVE_SSE
  798. #error Y_ABSL_INTERNAL_HAVE_SSE cannot be directly set
  799. #elif defined(__SSE__)
  800. #define Y_ABSL_INTERNAL_HAVE_SSE 1
  801. #elif (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)) && \
  802. !defined(_M_ARM64EC)
  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 Y_ABSL_INTERNAL_HAVE_SSE 1
  808. #endif
  809. // Y_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 Y_ABSL_INTERNAL_HAVE_SSE2
  813. #error Y_ABSL_INTERNAL_HAVE_SSE2 cannot be directly set
  814. #elif defined(__SSE2__)
  815. #define Y_ABSL_INTERNAL_HAVE_SSE2 1
  816. #elif (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)) && \
  817. !defined(_M_ARM64EC)
  818. // MSVC only defines _M_IX86_FP for x86 32-bit code, and _M_IX86_FP >= 2
  819. // indicates that at least SSE2 was targeted with the /arch:SSE2 option.
  820. // All x86-64 processors support SSE2, so support can be assumed.
  821. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  822. #define Y_ABSL_INTERNAL_HAVE_SSE2 1
  823. #endif
  824. // Y_ABSL_INTERNAL_HAVE_SSSE3 is used for compile-time detection of SSSE3 support.
  825. // See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
  826. // which architectures support the various x86 instruction sets.
  827. //
  828. // MSVC does not have a mode that targets SSSE3 at compile-time. To use SSSE3
  829. // with MSVC requires either assuming that the code will only every run on CPUs
  830. // that support SSSE3, otherwise __cpuid() can be used to detect support at
  831. // runtime and fallback to a non-SSSE3 implementation when SSSE3 is unsupported
  832. // by the CPU.
  833. #ifdef Y_ABSL_INTERNAL_HAVE_SSSE3
  834. #error Y_ABSL_INTERNAL_HAVE_SSSE3 cannot be directly set
  835. #elif defined(__SSSE3__)
  836. #define Y_ABSL_INTERNAL_HAVE_SSSE3 1
  837. #endif
  838. // Y_ABSL_INTERNAL_HAVE_ARM_NEON is used for compile-time detection of NEON (ARM
  839. // SIMD).
  840. //
  841. // If __CUDA_ARCH__ is defined, then we are compiling CUDA code in device mode.
  842. // In device mode, NEON intrinsics are not available, regardless of host
  843. // platform.
  844. // https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code
  845. #ifdef Y_ABSL_INTERNAL_HAVE_ARM_NEON
  846. #error Y_ABSL_INTERNAL_HAVE_ARM_NEON cannot be directly set
  847. #elif defined(__ARM_NEON) && !defined(__CUDA_ARCH__)
  848. #define Y_ABSL_INTERNAL_HAVE_ARM_NEON 1
  849. #endif
  850. // Y_ABSL_HAVE_CONSTANT_EVALUATED is used for compile-time detection of
  851. // constant evaluation support through `y_absl::is_constant_evaluated`.
  852. #ifdef Y_ABSL_HAVE_CONSTANT_EVALUATED
  853. #error Y_ABSL_HAVE_CONSTANT_EVALUATED cannot be directly set
  854. #endif
  855. #if defined(__cpp_lib_is_constant_evaluated) && (!defined(__CUDACC__) || CUDA_VERSION >= 11000)
  856. #define Y_ABSL_HAVE_CONSTANT_EVALUATED 1
  857. #elif Y_ABSL_HAVE_BUILTIN(__builtin_is_constant_evaluated) && (!defined(__CUDACC__) || CUDA_VERSION >= 11000)
  858. #define Y_ABSL_HAVE_CONSTANT_EVALUATED 1
  859. #endif
  860. // Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION combines Emscripten's three version macros
  861. // into an integer that can be compared against.
  862. #ifdef Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION
  863. #error Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION cannot be directly set
  864. #endif
  865. #ifdef __EMSCRIPTEN__
  866. #error #include <emscripten/version.h>
  867. #ifdef __EMSCRIPTEN_major__
  868. #if __EMSCRIPTEN_minor__ >= 1000
  869. #error __EMSCRIPTEN_minor__ is too big to fit in Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION
  870. #endif
  871. #if __EMSCRIPTEN_tiny__ >= 1000
  872. #error __EMSCRIPTEN_tiny__ is too big to fit in Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION
  873. #endif
  874. #define Y_ABSL_INTERNAL_EMSCRIPTEN_VERSION \
  875. ((__EMSCRIPTEN_major__)*1000000 + (__EMSCRIPTEN_minor__)*1000 + \
  876. (__EMSCRIPTEN_tiny__))
  877. #endif
  878. #endif
  879. #endif // Y_ABSL_BASE_CONFIG_H_