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