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