config.h 38 KB

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