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