18 #ifndef OTABSL_BASE_CONFIG_H_
19 #define OTABSL_BASE_CONFIG_H_
29 #if defined(__APPLE__)
32 #include <Availability.h>
33 #include <TargetConditionals.h>
40 #define OTABSL_INTERNAL_DO_TOKEN_STR(x) #x
41 #define OTABSL_INTERNAL_TOKEN_STR(x) OTABSL_INTERNAL_DO_TOKEN_STR(x)
67 #if !defined(OTABSL_OPTION_NAMESPACE_NAME)
68 #error options.h is misconfigured.
72 #if defined(__cplusplus)
74 #define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \
75 OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME)
77 static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] !=
'\0',
78 "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must "
80 static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] !=
'h' ||
81 OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] !=
'e' ||
82 OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] !=
'a' ||
83 OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] !=
'd' ||
84 OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] !=
'\0',
85 "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must "
86 "be changed to a new, unique identifier name.");
91 #define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME {
92 #define OTABSL_NAMESPACE_END }
108 #define OTABSL_HAVE_BUILTIN(x) __has_builtin(x)
110 #define OTABSL_HAVE_BUILTIN(x) 0
113 #if defined(__is_identifier)
114 #define OTABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x))
116 #define OTABSL_INTERNAL_HAS_KEYWORD(x) 0
122 #ifdef OTABSL_HAVE_TLS
123 #error OTABSL_HAVE_TLS cannot be directly set
124 #elif defined(__linux__) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
125 #define OTABSL_HAVE_TLS 1
134 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
135 #error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set
136 #elif defined(_LIBCPP_VERSION) || \
137 (defined(__clang__) && __clang_major__ >= 15) || \
138 (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \
139 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
141 #define OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1
155 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
156 #error OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set
157 #elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE)
158 #error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set
159 #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \
160 (defined(__clang__) && __clang_major__ >= 15) || \
161 (!defined(__clang__) && defined(__GNUC__) && \
162 (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \
163 (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
164 (defined(_MSC_VER) && !defined(__NVCC__))
165 #define OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1
166 #define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
174 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
175 #error OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
176 #elif defined(__clang__) && (__clang_major__ >= 15)
177 #define OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
184 #ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT
185 #if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \
186 OTABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE)
187 #define OTABSL_HAVE_SOURCE_LOCATION_CURRENT 1
195 #ifdef OTABSL_HAVE_THREAD_LOCAL
196 #error OTABSL_HAVE_THREAD_LOCAL cannot be directly set
197 #elif defined(__APPLE__)
208 #if __has_feature(cxx_thread_local) && \
209 !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
210 #define OTABSL_HAVE_THREAD_LOCAL 1
212 #else // !defined(__APPLE__)
213 #define OTABSL_HAVE_THREAD_LOCAL 1
228 #if defined(__ANDROID__) && defined(__clang__)
229 #if __has_include(<android/ndk-version.h>)
230 #include <android/ndk-version.h>
231 #endif // __has_include(<android/ndk-version.h>)
232 #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \
233 defined(__NDK_MINOR__) && \
234 ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))
235 #undef OTABSL_HAVE_TLS
236 #undef OTABSL_HAVE_THREAD_LOCAL
238 #endif // defined(__ANDROID__) && defined(__clang__)
242 #if defined(__EMSCRIPTEN__)
243 #undef OTABSL_HAVE_TLS
244 #undef OTABSL_HAVE_THREAD_LOCAL
245 #endif // defined(__EMSCRIPTEN__)
260 #ifdef OTABSL_HAVE_INTRINSIC_INT128
261 #error OTABSL_HAVE_INTRINSIC_INT128 cannot be directly set
262 #elif defined(__SIZEOF_INT128__)
263 #if (defined(__clang__) && !defined(_WIN32)) || \
264 (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
265 (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
266 #define OTABSL_HAVE_INTRINSIC_INT128 1
267 #elif defined(__CUDACC__)
272 #if __CUDACC_VER__ >= 70000
273 #define OTABSL_HAVE_INTRINSIC_INT128 1
274 #endif // __CUDACC_VER__ >= 70000
275 #endif // defined(__CUDACC__)
276 #endif // OTABSL_HAVE_INTRINSIC_INT128
290 #ifdef OTABSL_HAVE_EXCEPTIONS
291 #error OTABSL_HAVE_EXCEPTIONS cannot be directly set.
293 #elif defined(__clang__)
295 #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6)
297 #if __has_feature(cxx_exceptions)
298 #define OTABSL_HAVE_EXCEPTIONS 1
299 #endif // __has_feature(cxx_exceptions)
303 #if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions)
304 #define OTABSL_HAVE_EXCEPTIONS 1
305 #endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions)
306 #endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6)
309 #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \
310 !(defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__cpp_exceptions)) && \
311 !(defined(_MSC_VER) && !defined(_CPPUNWIND))
312 #define OTABSL_HAVE_EXCEPTIONS 1
340 #ifdef OTABSL_HAVE_MMAP
341 #error OTABSL_HAVE_MMAP cannot be directly set
342 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
343 defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
344 defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
346 #define OTABSL_HAVE_MMAP 1
353 #ifdef OTABSL_HAVE_PTHREAD_GETSCHEDPARAM
354 #error OTABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
355 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
357 #define OTABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
364 #ifdef OTABSL_HAVE_SCHED_YIELD
365 #error OTABSL_HAVE_SCHED_YIELD cannot be directly set
366 #elif defined(__linux__) || defined(__ros__) || defined(__native_client__)
367 #define OTABSL_HAVE_SCHED_YIELD 1
379 #ifdef OTABSL_HAVE_SEMAPHORE_H
380 #error OTABSL_HAVE_SEMAPHORE_H cannot be directly set
381 #elif defined(__linux__) || defined(__ros__)
382 #define OTABSL_HAVE_SEMAPHORE_H 1
389 #ifdef OTABSL_HAVE_ALARM
390 #error OTABSL_HAVE_ALARM cannot be directly set
391 #elif defined(__GOOGLE_GRTE_VERSION__)
393 #define OTABSL_HAVE_ALARM 1
394 #elif defined(__GLIBC__)
396 #define OTABSL_HAVE_ALARM 1
397 #elif defined(_MSC_VER)
399 #elif defined(__MINGW32__)
404 #elif defined(__EMSCRIPTEN__)
406 #elif defined(__Fuchsia__)
408 #elif defined(__native_client__)
411 #define OTABSL_HAVE_ALARM 1
423 #if defined(OTABSL_IS_BIG_ENDIAN)
424 #error "OTABSL_IS_BIG_ENDIAN cannot be directly set."
426 #if defined(OTABSL_IS_LITTLE_ENDIAN)
427 #error "OTABSL_IS_LITTLE_ENDIAN cannot be directly set."
430 #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
431 __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
432 #define OTABSL_IS_LITTLE_ENDIAN 1
433 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
434 __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
435 #define OTABSL_IS_BIG_ENDIAN 1
436 #elif defined(_WIN32)
437 #define OTABSL_IS_LITTLE_ENDIAN 1
439 #error "absl endian detection needs to be set up for your compiler"
449 #if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \
450 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
451 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \
452 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
453 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
454 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
455 __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \
456 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
457 __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000))
458 #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
460 #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
466 #ifdef OTABSL_HAVE_STD_ANY
467 #error "OTABSL_HAVE_STD_ANY cannot be directly set."
471 #if __has_include(<any>) && __cplusplus >= 201703L && \
472 !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
473 #define OTABSL_HAVE_STD_ANY 1
480 #ifdef OTABSL_HAVE_STD_OPTIONAL
481 #error "OTABSL_HAVE_STD_OPTIONAL cannot be directly set."
485 #if __has_include(<optional>) && __cplusplus >= 201703L && \
486 !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
487 #define OTABSL_HAVE_STD_OPTIONAL 1
494 #ifdef OTABSL_HAVE_STD_VARIANT
495 #error "OTABSL_HAVE_STD_VARIANT cannot be directly set."
499 #if __has_include(<variant>) && __cplusplus >= 201703L && \
500 !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
501 #define OTABSL_HAVE_STD_VARIANT 1
508 #ifdef OTABSL_HAVE_STD_STRING_VIEW
509 #error "OTABSL_HAVE_STD_STRING_VIEW cannot be directly set."
513 #if __has_include(<string_view>) && __cplusplus >= 201703L
514 #define OTABSL_HAVE_STD_STRING_VIEW 1
525 #if defined(_MSC_VER) && _MSC_VER >= 1910 && \
526 ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402)
528 #define OTABSL_HAVE_STD_OPTIONAL 1
529 #define OTABSL_HAVE_STD_VARIANT 1
530 #define OTABSL_HAVE_STD_STRING_VIEW 1
536 #if !defined(OTABSL_OPTION_USE_STD_ANY)
537 #error options.h is misconfigured.
538 #elif OTABSL_OPTION_USE_STD_ANY == 0 || \
539 (OTABSL_OPTION_USE_STD_ANY == 2 && !defined(OTABSL_HAVE_STD_ANY))
540 #undef OTABSL_USES_STD_ANY
541 #elif OTABSL_OPTION_USE_STD_ANY == 1 || \
542 (OTABSL_OPTION_USE_STD_ANY == 2 && defined(OTABSL_HAVE_STD_ANY))
543 #define OTABSL_USES_STD_ANY 1
545 #error options.h is misconfigured.
551 #if !defined(OTABSL_OPTION_USE_STD_OPTIONAL)
552 #error options.h is misconfigured.
553 #elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \
554 (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(OTABSL_HAVE_STD_OPTIONAL))
555 #undef OTABSL_USES_STD_OPTIONAL
556 #elif OTABSL_OPTION_USE_STD_OPTIONAL == 1 || \
557 (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(OTABSL_HAVE_STD_OPTIONAL))
558 #define OTABSL_USES_STD_OPTIONAL 1
560 #error options.h is misconfigured.
566 #if !defined(OTABSL_OPTION_USE_STD_VARIANT)
567 #error options.h is misconfigured.
568 #elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \
569 (OTABSL_OPTION_USE_STD_VARIANT == 2 && !defined(OTABSL_HAVE_STD_VARIANT))
570 #undef OTABSL_USES_STD_VARIANT
571 #elif OTABSL_OPTION_USE_STD_VARIANT == 1 || \
572 (OTABSL_OPTION_USE_STD_VARIANT == 2 && defined(OTABSL_HAVE_STD_VARIANT))
573 #define OTABSL_USES_STD_VARIANT 1
575 #error options.h is misconfigured.
581 #if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW)
582 #error options.h is misconfigured.
583 #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \
584 (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
585 !defined(OTABSL_HAVE_STD_STRING_VIEW))
586 #undef OTABSL_USES_STD_STRING_VIEW
587 #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
588 (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
589 defined(OTABSL_HAVE_STD_STRING_VIEW))
590 #define OTABSL_USES_STD_STRING_VIEW 1
592 #error options.h is misconfigured.
599 #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG)
600 #define OTABSL_INTERNAL_MSVC_2017_DBG_MODE
614 #if defined(_MSC_VER)
615 #define OTABSL_INTERNAL_MANGLED_NS \
616 OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl"
617 #define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6"
620 #undef OTABSL_INTERNAL_HAS_KEYWORD
629 #if defined(_MSC_VER)
630 #if defined(OTABSL_BUILD_DLL)
631 #define OTABSL_DLL __declspec(dllexport)
633 #define OTABSL_DLL __declspec(dllimport)
639 #endif // defined(_MSC_VER)
641 #endif // OTABSL_BASE_CONFIG_H_