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