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