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#define ABSL_LTS_RELEASE_VERSION 20240116
121#define ABSL_LTS_RELEASE_PATCH_LEVEL 2
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
162static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0',
163 "options.h misconfigured: ABSL_OPTION_INLINE_NAMESPACE_NAME must "
164 "not be empty.");
165static_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__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \
383 !(ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(5, 0) && \
384 !defined(__cpp_exceptions)) && \
385 !(defined(_MSC_VER) && !defined(_CPPUNWIND))
386#define ABSL_HAVE_EXCEPTIONS 1
387#endif
388
389// -----------------------------------------------------------------------------
390// Platform Feature Checks
391// -----------------------------------------------------------------------------
392
393// Currently supported operating systems and associated preprocessor
394// symbols:
395//
396// Linux and Linux-derived __linux__
397// Android __ANDROID__ (implies __linux__)
398// Linux (non-Android) __linux__ && !__ANDROID__
399// Darwin (macOS and iOS) __APPLE__
400// Akaros (http://akaros.org) __ros__
401// Windows _WIN32
402// NaCL __native_client__
403// AsmJS __asmjs__
404// WebAssembly (Emscripten) __EMSCRIPTEN__
405// Fuchsia __Fuchsia__
406//
407// Note that since Android defines both __ANDROID__ and __linux__, one
408// may probe for either Linux or Android by simply testing for __linux__.
409
410// ABSL_HAVE_MMAP
411//
412// Checks whether the platform has an mmap(2) implementation as defined in
413// POSIX.1-2001.
414#ifdef ABSL_HAVE_MMAP
415#error ABSL_HAVE_MMAP cannot be directly set
416#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
417 defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
418 defined(__asmjs__) || defined(__EMSCRIPTEN__) || defined(__Fuchsia__) || \
419 defined(__sun) || defined(__ASYLO__) || defined(__myriad2__) || \
420 defined(__HAIKU__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
421 defined(__QNX__) || defined(__VXWORKS__) || defined(__hexagon__)
422#define ABSL_HAVE_MMAP 1
423#endif
424
425// ABSL_HAVE_PTHREAD_GETSCHEDPARAM
426//
427// Checks whether the platform implements the pthread_(get|set)schedparam(3)
428// functions as defined in POSIX.1-2001.
429#ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
430#error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
431#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
432 defined(_AIX) || defined(__ros__) || defined(__OpenBSD__) || \
433 defined(__NetBSD__) || defined(__VXWORKS__)
434#define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
435#endif
436
437// ABSL_HAVE_SCHED_GETCPU
438//
439// Checks whether sched_getcpu is available.
440#ifdef ABSL_HAVE_SCHED_GETCPU
441#error ABSL_HAVE_SCHED_GETCPU cannot be directly set
442#elif defined(__linux__)
443#define ABSL_HAVE_SCHED_GETCPU 1
444#endif
445
446// ABSL_HAVE_SCHED_YIELD
447//
448// Checks whether the platform implements sched_yield(2) as defined in
449// POSIX.1-2001.
450#ifdef ABSL_HAVE_SCHED_YIELD
451#error ABSL_HAVE_SCHED_YIELD cannot be directly set
452#elif defined(__linux__) || defined(__ros__) || defined(__native_client__) || \
453 defined(__VXWORKS__)
454#define ABSL_HAVE_SCHED_YIELD 1
455#endif
456
457// ABSL_HAVE_SEMAPHORE_H
458//
459// Checks whether the platform supports the <semaphore.h> header and sem_init(3)
460// family of functions as standardized in POSIX.1-2001.
461//
462// Note: While Apple provides <semaphore.h> for both iOS and macOS, it is
463// explicitly deprecated and will cause build failures if enabled for those
464// platforms. We side-step the issue by not defining it here for Apple
465// platforms.
466#ifdef ABSL_HAVE_SEMAPHORE_H
467#error ABSL_HAVE_SEMAPHORE_H cannot be directly set
468#elif defined(__linux__) || defined(__ros__) || defined(__VXWORKS__)
469#define ABSL_HAVE_SEMAPHORE_H 1
470#endif
471
472// ABSL_HAVE_ALARM
473//
474// Checks whether the platform supports the <signal.h> header and alarm(2)
475// function as standardized in POSIX.1-2001.
476#ifdef ABSL_HAVE_ALARM
477#error ABSL_HAVE_ALARM cannot be directly set
478#elif defined(__GOOGLE_GRTE_VERSION__)
479// feature tests for Google's GRTE
480#define ABSL_HAVE_ALARM 1
481#elif defined(__GLIBC__)
482// feature test for glibc
483#define ABSL_HAVE_ALARM 1
484#elif defined(_MSC_VER)
485// feature tests for Microsoft's library
486#elif defined(__MINGW32__)
487// mingw32 doesn't provide alarm(2):
488// https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h
489// mingw-w64 provides a no-op implementation:
490// https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c
491#elif defined(__EMSCRIPTEN__)
492// emscripten doesn't support signals
493#elif defined(__wasi__)
494// WASI doesn't support signals
495#elif defined(__Fuchsia__)
496// Signals don't exist on fuchsia.
497#elif defined(__native_client__)
498// Signals don't exist on hexagon/QuRT
499#elif defined(__hexagon__)
500#else
501// other standard libraries
502#define ABSL_HAVE_ALARM 1
503#endif
504
505// ABSL_IS_LITTLE_ENDIAN
506// ABSL_IS_BIG_ENDIAN
507//
508// Checks the endianness of the platform.
509//
510// Notes: uses the built in endian macros provided by GCC (since 4.6) and
511// Clang (since 3.2); see
512// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html.
513// Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error.
514#if defined(ABSL_IS_BIG_ENDIAN)
515#error "ABSL_IS_BIG_ENDIAN cannot be directly set."
516#endif
517#if defined(ABSL_IS_LITTLE_ENDIAN)
518#error "ABSL_IS_LITTLE_ENDIAN cannot be directly set."
519#endif
520
521#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
522 __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
523#define ABSL_IS_LITTLE_ENDIAN 1
524#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
525 __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
526#define ABSL_IS_BIG_ENDIAN 1
527#elif defined(_WIN32)
528#define ABSL_IS_LITTLE_ENDIAN 1
529#else
530#error "absl endian detection needs to be set up for your compiler"
531#endif
532
533// macOS < 10.13 and iOS < 12 don't support <any>, <optional>, or <variant>
534// because the libc++ shared library shipped on the system doesn't have the
535// requisite exported symbols. See
536// https://github.com/abseil/abseil-cpp/issues/207 and
537// https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
538//
539// libc++ spells out the availability requirements in the file
540// llvm-project/libcxx/include/__config via the #define
541// _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. The set of versions has been
542// modified a few times, via
543// https://github.com/llvm/llvm-project/commit/7fb40e1569dd66292b647f4501b85517e9247953
544// and
545// https://github.com/llvm/llvm-project/commit/0bc451e7e137c4ccadcd3377250874f641ca514a
546// The second has the actually correct versions, thus, is what we copy here.
547#if defined(__APPLE__) && \
548 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
549 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101300) || \
550 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
551 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
552 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
553 __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000) || \
554 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
555 __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 120000))
556#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
557#else
558#define ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
559#endif
560
561// ABSL_HAVE_STD_ANY
562//
563// Checks whether C++17 std::any is available.
564#ifdef ABSL_HAVE_STD_ANY
565#error "ABSL_HAVE_STD_ANY cannot be directly set."
566#elif defined(__cpp_lib_any) && __cpp_lib_any >= 201606L
567#define ABSL_HAVE_STD_ANY 1
568#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
569 ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
570 !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
571#define ABSL_HAVE_STD_ANY 1
572#endif
573
574// ABSL_HAVE_STD_OPTIONAL
575//
576// Checks whether C++17 std::optional is available.
577#ifdef ABSL_HAVE_STD_OPTIONAL
578#error "ABSL_HAVE_STD_OPTIONAL cannot be directly set."
579#elif defined(__cpp_lib_optional) && __cpp_lib_optional >= 202106L
580#define ABSL_HAVE_STD_OPTIONAL 1
581#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
582 ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
583 !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
584#define ABSL_HAVE_STD_OPTIONAL 1
585#endif
586
587// ABSL_HAVE_STD_VARIANT
588//
589// Checks whether C++17 std::variant is available.
590#ifdef ABSL_HAVE_STD_VARIANT
591#error "ABSL_HAVE_STD_VARIANT cannot be directly set."
592#elif defined(__cpp_lib_variant) && __cpp_lib_variant >= 201606L
593#define ABSL_HAVE_STD_VARIANT 1
594#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
595 ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
596 !ABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
597#define ABSL_HAVE_STD_VARIANT 1
598#endif
599
600// ABSL_HAVE_STD_STRING_VIEW
601//
602// Checks whether C++17 std::string_view is available.
603#ifdef ABSL_HAVE_STD_STRING_VIEW
604#error "ABSL_HAVE_STD_STRING_VIEW cannot be directly set."
605#elif defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
606#define ABSL_HAVE_STD_STRING_VIEW 1
607#elif defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
608 ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
609#define ABSL_HAVE_STD_STRING_VIEW 1
610#endif
611
612// ABSL_HAVE_STD_ORDERING
613//
614// Checks whether C++20 std::{partial,weak,strong}_ordering are available.
615//
616// __cpp_lib_three_way_comparison is missing on libc++
617// (https://github.com/llvm/llvm-project/issues/73953) so treat it as defined
618// when building in C++20 mode.
619#ifdef ABSL_HAVE_STD_ORDERING
620#error "ABSL_HAVE_STD_ORDERING cannot be directly set."
621#elif (defined(__cpp_lib_three_way_comparison) && \
622 __cpp_lib_three_way_comparison >= 201907L) || \
623 (defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
624 ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L)
625#define ABSL_HAVE_STD_ORDERING 1
626#endif
627
628// ABSL_USES_STD_ANY
629//
630// Indicates whether absl::any is an alias for std::any.
631#if !defined(ABSL_OPTION_USE_STD_ANY)
632#error options.h is misconfigured.
633#elif ABSL_OPTION_USE_STD_ANY == 0 || \
634 (ABSL_OPTION_USE_STD_ANY == 2 && !defined(ABSL_HAVE_STD_ANY))
635#undef ABSL_USES_STD_ANY
636#elif ABSL_OPTION_USE_STD_ANY == 1 || \
637 (ABSL_OPTION_USE_STD_ANY == 2 && defined(ABSL_HAVE_STD_ANY))
638#define ABSL_USES_STD_ANY 1
639#else
640#error options.h is misconfigured.
641#endif
642
643// ABSL_USES_STD_OPTIONAL
644//
645// Indicates whether absl::optional is an alias for std::optional.
646#if !defined(ABSL_OPTION_USE_STD_OPTIONAL)
647#error options.h is misconfigured.
648#elif ABSL_OPTION_USE_STD_OPTIONAL == 0 || \
649 (ABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(ABSL_HAVE_STD_OPTIONAL))
650#undef ABSL_USES_STD_OPTIONAL
651#elif ABSL_OPTION_USE_STD_OPTIONAL == 1 || \
652 (ABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(ABSL_HAVE_STD_OPTIONAL))
653#define ABSL_USES_STD_OPTIONAL 1
654#else
655#error options.h is misconfigured.
656#endif
657
658// ABSL_USES_STD_VARIANT
659//
660// Indicates whether absl::variant is an alias for std::variant.
661#if !defined(ABSL_OPTION_USE_STD_VARIANT)
662#error options.h is misconfigured.
663#elif ABSL_OPTION_USE_STD_VARIANT == 0 || \
664 (ABSL_OPTION_USE_STD_VARIANT == 2 && !defined(ABSL_HAVE_STD_VARIANT))
665#undef ABSL_USES_STD_VARIANT
666#elif ABSL_OPTION_USE_STD_VARIANT == 1 || \
667 (ABSL_OPTION_USE_STD_VARIANT == 2 && defined(ABSL_HAVE_STD_VARIANT))
668#define ABSL_USES_STD_VARIANT 1
669#else
670#error options.h is misconfigured.
671#endif
672
673// ABSL_USES_STD_STRING_VIEW
674//
675// Indicates whether absl::string_view is an alias for std::string_view.
676#if !defined(ABSL_OPTION_USE_STD_STRING_VIEW)
677#error options.h is misconfigured.
678#elif ABSL_OPTION_USE_STD_STRING_VIEW == 0 || \
679 (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
680 !defined(ABSL_HAVE_STD_STRING_VIEW))
681#undef ABSL_USES_STD_STRING_VIEW
682#elif ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
683 (ABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
684 defined(ABSL_HAVE_STD_STRING_VIEW))
685#define ABSL_USES_STD_STRING_VIEW 1
686#else
687#error options.h is misconfigured.
688#endif
689
690// ABSL_USES_STD_ORDERING
691//
692// Indicates whether absl::{partial,weak,strong}_ordering are aliases for the
693// std:: ordering types.
694#if !defined(ABSL_OPTION_USE_STD_ORDERING)
695#error options.h is misconfigured.
696#elif ABSL_OPTION_USE_STD_ORDERING == 0 || \
697 (ABSL_OPTION_USE_STD_ORDERING == 2 && !defined(ABSL_HAVE_STD_ORDERING))
698#undef ABSL_USES_STD_ORDERING
699#elif ABSL_OPTION_USE_STD_ORDERING == 1 || \
700 (ABSL_OPTION_USE_STD_ORDERING == 2 && defined(ABSL_HAVE_STD_ORDERING))
701#define ABSL_USES_STD_ORDERING 1
702#else
703#error options.h is misconfigured.
704#endif
705
706// In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION
707// SEH exception from emplace for variant<SomeStruct> when constructing the
708// struct can throw. This defeats some of variant_test and
709// variant_exception_safety_test.
710#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG)
711#define ABSL_INTERNAL_MSVC_2017_DBG_MODE
712#endif
713
714// ABSL_INTERNAL_MANGLED_NS
715// ABSL_INTERNAL_MANGLED_BACKREFERENCE
716//
717// Internal macros for building up mangled names in our internal fork of CCTZ.
718// This implementation detail is only needed and provided for the MSVC build.
719//
720// These macros both expand to string literals. ABSL_INTERNAL_MANGLED_NS is
721// the mangled spelling of the `absl` namespace, and
722// ABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing
723// the proper count to skip past the CCTZ fork namespace names. (This number
724// is one larger when there is an inline namespace name to skip.)
725#if defined(_MSC_VER)
726#if ABSL_OPTION_USE_INLINE_NAMESPACE == 0
727#define ABSL_INTERNAL_MANGLED_NS "absl"
728#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "5"
729#else
730#define ABSL_INTERNAL_MANGLED_NS \
731 ABSL_INTERNAL_TOKEN_STR(ABSL_OPTION_INLINE_NAMESPACE_NAME) "@absl"
732#define ABSL_INTERNAL_MANGLED_BACKREFERENCE "6"
733#endif
734#endif
735
736// ABSL_DLL
737//
738// When building Abseil as a DLL, this macro expands to `__declspec(dllexport)`
739// so we can annotate symbols appropriately as being exported. When used in
740// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so
741// that consumers know the symbol is defined inside the DLL. In all other cases,
742// the macro expands to nothing.
743#if defined(_MSC_VER)
744#if defined(ABSL_BUILD_DLL)
745#define ABSL_DLL __declspec(dllexport)
746#elif defined(ABSL_CONSUME_DLL)
747#define ABSL_DLL __declspec(dllimport)
748#else
749#define ABSL_DLL
750#endif
751#else
752#define ABSL_DLL
753#endif // defined(_MSC_VER)
754
755#if defined(_MSC_VER)
756#if defined(ABSL_BUILD_TEST_DLL)
757#define ABSL_TEST_DLL __declspec(dllexport)
758#elif defined(ABSL_CONSUME_TEST_DLL)
759#define ABSL_TEST_DLL __declspec(dllimport)
760#else
761#define ABSL_TEST_DLL
762#endif
763#else
764#define ABSL_TEST_DLL
765#endif // defined(_MSC_VER)
766
767// ABSL_HAVE_MEMORY_SANITIZER
768//
769// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of
770// a compiler instrumentation module and a run-time library.
771#ifdef ABSL_HAVE_MEMORY_SANITIZER
772#error "ABSL_HAVE_MEMORY_SANITIZER cannot be directly set."
773#elif !defined(__native_client__) && ABSL_HAVE_FEATURE(memory_sanitizer)
774#define ABSL_HAVE_MEMORY_SANITIZER 1
775#endif
776
777// ABSL_HAVE_THREAD_SANITIZER
778//
779// ThreadSanitizer (TSan) is a fast data race detector.
780#ifdef ABSL_HAVE_THREAD_SANITIZER
781#error "ABSL_HAVE_THREAD_SANITIZER cannot be directly set."
782#elif defined(__SANITIZE_THREAD__)
783#define ABSL_HAVE_THREAD_SANITIZER 1
784#elif ABSL_HAVE_FEATURE(thread_sanitizer)
785#define ABSL_HAVE_THREAD_SANITIZER 1
786#endif
787
788// ABSL_HAVE_ADDRESS_SANITIZER
789//
790// AddressSanitizer (ASan) is a fast memory error detector.
791#ifdef ABSL_HAVE_ADDRESS_SANITIZER
792#error "ABSL_HAVE_ADDRESS_SANITIZER cannot be directly set."
793#elif defined(__SANITIZE_ADDRESS__)
794#define ABSL_HAVE_ADDRESS_SANITIZER 1
795#elif ABSL_HAVE_FEATURE(address_sanitizer)
796#define ABSL_HAVE_ADDRESS_SANITIZER 1
797#endif
798
799// ABSL_HAVE_HWADDRESS_SANITIZER
800//
801// Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan
802// memory error detector which can use CPU features like ARM TBI, Intel LAM or
803// AMD UAI.
804#ifdef ABSL_HAVE_HWADDRESS_SANITIZER
805#error "ABSL_HAVE_HWADDRESS_SANITIZER cannot be directly set."
806#elif defined(__SANITIZE_HWADDRESS__)
807#define ABSL_HAVE_HWADDRESS_SANITIZER 1
808#elif ABSL_HAVE_FEATURE(hwaddress_sanitizer)
809#define ABSL_HAVE_HWADDRESS_SANITIZER 1
810#endif
811
812// ABSL_HAVE_DATAFLOW_SANITIZER
813//
814// Dataflow Sanitizer (or DFSAN) is a generalised dynamic data flow analysis.
815#ifdef ABSL_HAVE_DATAFLOW_SANITIZER
816#error "ABSL_HAVE_DATAFLOW_SANITIZER cannot be directly set."
817#elif defined(DATAFLOW_SANITIZER)
818// GCC provides no method for detecting the presence of the standalone
819// DataFlowSanitizer (-fsanitize=dataflow), so GCC users of -fsanitize=dataflow
820// should also use -DDATAFLOW_SANITIZER.
821#define ABSL_HAVE_DATAFLOW_SANITIZER 1
822#elif ABSL_HAVE_FEATURE(dataflow_sanitizer)
823#define ABSL_HAVE_DATAFLOW_SANITIZER 1
824#endif
825
826// ABSL_HAVE_LEAK_SANITIZER
827//
828// LeakSanitizer (or lsan) is a detector of memory leaks.
829// https://clang.llvm.org/docs/LeakSanitizer.html
830// https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
831//
832// The macro ABSL_HAVE_LEAK_SANITIZER can be used to detect at compile-time
833// whether the LeakSanitizer is potentially available. However, just because the
834// LeakSanitizer is available does not mean it is active. Use the
835// always-available run-time interface in //absl/debugging/leak_check.h for
836// interacting with LeakSanitizer.
837#ifdef ABSL_HAVE_LEAK_SANITIZER
838#error "ABSL_HAVE_LEAK_SANITIZER cannot be directly set."
839#elif defined(LEAK_SANITIZER)
840// GCC provides no method for detecting the presence of the standalone
841// LeakSanitizer (-fsanitize=leak), so GCC users of -fsanitize=leak should also
842// use -DLEAK_SANITIZER.
843#define ABSL_HAVE_LEAK_SANITIZER 1
844// Clang standalone LeakSanitizer (-fsanitize=leak)
845#elif ABSL_HAVE_FEATURE(leak_sanitizer)
846#define ABSL_HAVE_LEAK_SANITIZER 1
847#elif defined(ABSL_HAVE_ADDRESS_SANITIZER)
848// GCC or Clang using the LeakSanitizer integrated into AddressSanitizer.
849#define ABSL_HAVE_LEAK_SANITIZER 1
850#endif
851
852// ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
853//
854// Class template argument deduction is a language feature added in C++17.
855#ifdef ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
856#error "ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION cannot be directly set."
857#elif defined(__cpp_deduction_guides)
858#define ABSL_HAVE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
859#endif
860
861// ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
862//
863// Prior to C++17, static constexpr variables defined in classes required a
864// separate definition outside of the class body, for example:
865//
866// class Foo {
867// static constexpr int kBar = 0;
868// };
869// constexpr int Foo::kBar;
870//
871// In C++17, these variables defined in classes are considered inline variables,
872// and the extra declaration is redundant. Since some compilers warn on the
873// extra declarations, ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL can be used
874// conditionally ignore them:
875//
876// #ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
877// constexpr int Foo::kBar;
878// #endif
879#if defined(ABSL_INTERNAL_CPLUSPLUS_LANG) && \
880 ABSL_INTERNAL_CPLUSPLUS_LANG < 201703L
881#define ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
882#endif
883
884// `ABSL_INTERNAL_HAS_RTTI` determines whether abseil is being compiled with
885// RTTI support.
886#ifdef ABSL_INTERNAL_HAS_RTTI
887#error ABSL_INTERNAL_HAS_RTTI cannot be directly set
888#elif ABSL_HAVE_FEATURE(cxx_rtti)
889#define ABSL_INTERNAL_HAS_RTTI 1
890#elif defined(__GNUC__) && defined(__GXX_RTTI)
891#define ABSL_INTERNAL_HAS_RTTI 1
892#elif defined(_MSC_VER) && defined(_CPPRTTI)
893#define ABSL_INTERNAL_HAS_RTTI 1
894#elif !defined(__GNUC__) && !defined(_MSC_VER)
895// Unknown compiler, default to RTTI
896#define ABSL_INTERNAL_HAS_RTTI 1
897#endif
898
899// `ABSL_INTERNAL_HAS_CXA_DEMANGLE` determines whether `abi::__cxa_demangle` is
900// available.
901#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
902#error ABSL_INTERNAL_HAS_CXA_DEMANGLE cannot be directly set
903#elif defined(OS_ANDROID) && (defined(__i386__) || defined(__x86_64__))
904#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 0
905#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && \
906 (__GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)) && \
907 !defined(__mips__)
908#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 1
909#elif defined(__clang__) && !defined(_MSC_VER)
910#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 1
911#endif
912
913// ABSL_INTERNAL_HAVE_SSE is used for compile-time detection of SSE support.
914// See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
915// which architectures support the various x86 instruction sets.
916#ifdef ABSL_INTERNAL_HAVE_SSE
917#error ABSL_INTERNAL_HAVE_SSE cannot be directly set
918#elif defined(__SSE__)
919#define ABSL_INTERNAL_HAVE_SSE 1
920#elif (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)) && \
921 !defined(_M_ARM64EC)
922// MSVC only defines _M_IX86_FP for x86 32-bit code, and _M_IX86_FP >= 1
923// indicates that at least SSE was targeted with the /arch:SSE option.
924// All x86-64 processors support SSE, so support can be assumed.
925// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
926#define ABSL_INTERNAL_HAVE_SSE 1
927#endif
928
929// ABSL_INTERNAL_HAVE_SSE2 is used for compile-time detection of SSE2 support.
930// See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
931// which architectures support the various x86 instruction sets.
932#ifdef ABSL_INTERNAL_HAVE_SSE2
933#error ABSL_INTERNAL_HAVE_SSE2 cannot be directly set
934#elif defined(__SSE2__)
935#define ABSL_INTERNAL_HAVE_SSE2 1
936#elif (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)) && \
937 !defined(_M_ARM64EC)
938// MSVC only defines _M_IX86_FP for x86 32-bit code, and _M_IX86_FP >= 2
939// indicates that at least SSE2 was targeted with the /arch:SSE2 option.
940// All x86-64 processors support SSE2, so support can be assumed.
941// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
942#define ABSL_INTERNAL_HAVE_SSE2 1
943#endif
944
945// ABSL_INTERNAL_HAVE_SSSE3 is used for compile-time detection of SSSE3 support.
946// See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html for an overview of
947// which architectures support the various x86 instruction sets.
948//
949// MSVC does not have a mode that targets SSSE3 at compile-time. To use SSSE3
950// with MSVC requires either assuming that the code will only every run on CPUs
951// that support SSSE3, otherwise __cpuid() can be used to detect support at
952// runtime and fallback to a non-SSSE3 implementation when SSSE3 is unsupported
953// by the CPU.
954#ifdef ABSL_INTERNAL_HAVE_SSSE3
955#error ABSL_INTERNAL_HAVE_SSSE3 cannot be directly set
956#elif defined(__SSSE3__)
957#define ABSL_INTERNAL_HAVE_SSSE3 1
958#endif
959
960// ABSL_INTERNAL_HAVE_ARM_NEON is used for compile-time detection of NEON (ARM
961// SIMD).
962//
963// If __CUDA_ARCH__ is defined, then we are compiling CUDA code in device mode.
964// In device mode, NEON intrinsics are not available, regardless of host
965// platform.
966// https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code
967#ifdef ABSL_INTERNAL_HAVE_ARM_NEON
968#error ABSL_INTERNAL_HAVE_ARM_NEON cannot be directly set
969#elif defined(__ARM_NEON) && !defined(__CUDA_ARCH__)
970#define ABSL_INTERNAL_HAVE_ARM_NEON 1
971#endif
972
973// ABSL_HAVE_CONSTANT_EVALUATED is used for compile-time detection of
974// constant evaluation support through `absl::is_constant_evaluated`.
975#ifdef ABSL_HAVE_CONSTANT_EVALUATED
976#error ABSL_HAVE_CONSTANT_EVALUATED cannot be directly set
977#endif
978#ifdef __cpp_lib_is_constant_evaluated
979#define ABSL_HAVE_CONSTANT_EVALUATED 1
980#elif ABSL_HAVE_BUILTIN(__builtin_is_constant_evaluated)
981#define ABSL_HAVE_CONSTANT_EVALUATED 1
982#endif
983
984// ABSL_INTERNAL_EMSCRIPTEN_VERSION combines Emscripten's three version macros
985// into an integer that can be compared against.
986#ifdef ABSL_INTERNAL_EMSCRIPTEN_VERSION
987#error ABSL_INTERNAL_EMSCRIPTEN_VERSION cannot be directly set
988#endif
989#ifdef __EMSCRIPTEN__
990#include <emscripten/version.h>
991#ifdef __EMSCRIPTEN_major__
992#if __EMSCRIPTEN_minor__ >= 1000
993#error __EMSCRIPTEN_minor__ is too big to fit in ABSL_INTERNAL_EMSCRIPTEN_VERSION
994#endif
995#if __EMSCRIPTEN_tiny__ >= 1000
996#error __EMSCRIPTEN_tiny__ is too big to fit in ABSL_INTERNAL_EMSCRIPTEN_VERSION
997#endif
998#define ABSL_INTERNAL_EMSCRIPTEN_VERSION \
999 ((__EMSCRIPTEN_major__) * 1000000 + (__EMSCRIPTEN_minor__) * 1000 + \
1000 (__EMSCRIPTEN_tiny__))
1001#endif
1002#endif
1003
1004#endif // ABSL_BASE_CONFIG_H_
1005