1// -*- C++ -*- 2//===--------------------------- __config ---------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_CONFIG 11#define _LIBCPP_CONFIG 12 13#include <__config_site> 14 15#if defined(_MSC_VER) && !defined(__clang__) 16# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 18# endif 19#endif 20 21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 22#pragma GCC system_header 23#endif 24 25#ifdef __cplusplus 26 27#ifdef __GNUC__ 28# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) 29// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme 30// introduced in GCC 5.0. 31# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) 32#else 33# define _GNUC_VER 0 34# define _GNUC_VER_NEW 0 35#endif 36 37#define _LIBCPP_VERSION 13000 38 39#ifndef _LIBCPP_ABI_VERSION 40# define _LIBCPP_ABI_VERSION 1 41#endif 42 43#if __STDC_HOSTED__ == 0 44# define _LIBCPP_FREESTANDING 45#endif 46 47#ifndef _LIBCPP_STD_VER 48# if __cplusplus <= 201103L 49# define _LIBCPP_STD_VER 11 50# elif __cplusplus <= 201402L 51# define _LIBCPP_STD_VER 14 52# elif __cplusplus <= 201703L 53# define _LIBCPP_STD_VER 17 54# elif __cplusplus <= 202002L 55# define _LIBCPP_STD_VER 20 56# else 57# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification 58# endif 59#endif // _LIBCPP_STD_VER 60 61#if defined(__ELF__) 62# define _LIBCPP_OBJECT_FORMAT_ELF 1 63#elif defined(__MACH__) 64# define _LIBCPP_OBJECT_FORMAT_MACHO 1 65#elif defined(_WIN32) 66# define _LIBCPP_OBJECT_FORMAT_COFF 1 67#elif defined(__wasm__) 68# define _LIBCPP_OBJECT_FORMAT_WASM 1 69#else 70 // ... add new file formats here ... 71#endif 72 73#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 74// Change short string representation so that string data starts at offset 0, 75// improving its alignment in some cases. 76# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 77// Fix deque iterator type in order to support incomplete types. 78# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 79// Fix undefined behavior in how std::list stores its linked nodes. 80# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 81// Fix undefined behavior in how __tree stores its end and parent nodes. 82# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 83// Fix undefined behavior in how __hash_table stores its pointer types. 84# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 85# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 86# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 87// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr 88// provided under the alternate keyword __nullptr, which changes the mangling 89// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. 90# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR 91// Define the `pointer_safety` enum as a C++11 strongly typed enumeration 92// instead of as a class simulating an enum. If this option is enabled 93// `pointer_safety` and `get_pointer_safety()` will no longer be available 94// in C++03. 95# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE 96// Define a key function for `bad_function_call` in the library, to centralize 97// its vtable and typeinfo to libc++ rather than having all other libraries 98// using that class define their own copies. 99# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 100// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 101# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 102// Use the smallest possible integer type to represent the index of the variant. 103// Previously libc++ used "unsigned int" exclusively. 104# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 105// Unstable attempt to provide a more optimized std::function 106# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 107// All the regex constants must be distinct and nonzero. 108# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 109// Re-worked external template instantiations for std::string with a focus on 110// performance and fast-path inlining. 111# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 112// Enable clang::trivial_abi on std::unique_ptr. 113# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 114// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 115# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 116#elif _LIBCPP_ABI_VERSION == 1 117# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 118// Enable compiling copies of now inline methods into the dylib to support 119// applications compiled against older libraries. This is unnecessary with 120// COFF dllexport semantics, since dllexport forces a non-inline definition 121// of inline functions to be emitted anyway. Our own non-inline copy would 122// conflict with the dllexport-emitted copy, so we disable it. 123# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 124# endif 125// Feature macros for disabling pre ABI v1 features. All of these options 126// are deprecated. 127# if defined(__FreeBSD__) 128# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 129# endif 130#endif 131 132#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 133// Enable additional explicit instantiations of iostreams components. This 134// reduces the number of weak definitions generated in programs that use 135// iostreams by providing a single strong definition in the shared library. 136# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 137#endif 138 139#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y 140#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) 141 142#ifndef _LIBCPP_ABI_NAMESPACE 143# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) 144#endif 145 146#if __cplusplus < 201103L 147#define _LIBCPP_CXX03_LANG 148#endif 149 150#ifndef __has_attribute 151#define __has_attribute(__x) 0 152#endif 153 154#ifndef __has_builtin 155#define __has_builtin(__x) 0 156#endif 157 158#ifndef __has_extension 159#define __has_extension(__x) 0 160#endif 161 162#ifndef __has_feature 163#define __has_feature(__x) 0 164#endif 165 166#ifndef __has_cpp_attribute 167#define __has_cpp_attribute(__x) 0 168#endif 169 170// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 171// the compiler and '1' otherwise. 172#ifndef __is_identifier 173#define __is_identifier(__x) 1 174#endif 175 176#ifndef __has_declspec_attribute 177#define __has_declspec_attribute(__x) 0 178#endif 179 180#define __has_keyword(__x) !(__is_identifier(__x)) 181 182#ifndef __has_include 183#define __has_include(...) 0 184#endif 185 186#if defined(__apple_build_version__) 187# define _LIBCPP_COMPILER_CLANG_BASED 188# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) 189#elif defined(__clang__) 190# define _LIBCPP_COMPILER_CLANG_BASED 191# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 192#elif defined(__GNUC__) 193# define _LIBCPP_COMPILER_GCC 194#elif defined(_MSC_VER) 195# define _LIBCPP_COMPILER_MSVC 196#elif defined(__IBMCPP__) 197# define _LIBCPP_COMPILER_IBM 198#endif 199 200#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L 201#error "libc++ does not support using GCC with C++03. Please enable C++11" 202#endif 203 204// FIXME: ABI detection should be done via compiler builtin macros. This 205// is just a placeholder until Clang implements such macros. For now assume 206// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 207// and allow the user to explicitly specify the ABI to handle cases where this 208// heuristic falls short. 209#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 210# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 211#elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 212# define _LIBCPP_ABI_ITANIUM 213#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 214# define _LIBCPP_ABI_MICROSOFT 215#else 216# if defined(_WIN32) && defined(_MSC_VER) 217# define _LIBCPP_ABI_MICROSOFT 218# else 219# define _LIBCPP_ABI_ITANIUM 220# endif 221#endif 222 223#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 224# define _LIBCPP_ABI_VCRUNTIME 225#endif 226 227// Need to detect which libc we're using if we're on Linux. 228#if defined(__linux__) 229# include <features.h> 230# if defined(__GLIBC_PREREQ) 231# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 232# else 233# define _LIBCPP_GLIBC_PREREQ(a, b) 0 234# endif // defined(__GLIBC_PREREQ) 235#endif // defined(__linux__) 236 237#ifdef __LITTLE_ENDIAN__ 238# if __LITTLE_ENDIAN__ 239# define _LIBCPP_LITTLE_ENDIAN 240# endif // __LITTLE_ENDIAN__ 241#endif // __LITTLE_ENDIAN__ 242 243#ifdef __BIG_ENDIAN__ 244# if __BIG_ENDIAN__ 245# define _LIBCPP_BIG_ENDIAN 246# endif // __BIG_ENDIAN__ 247#endif // __BIG_ENDIAN__ 248 249#ifdef __BYTE_ORDER__ 250# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 251# define _LIBCPP_LITTLE_ENDIAN 252# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 253# define _LIBCPP_BIG_ENDIAN 254# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 255#endif // __BYTE_ORDER__ 256 257#ifdef __FreeBSD__ 258# include <sys/endian.h> 259# include <osreldate.h> 260# if _BYTE_ORDER == _LITTLE_ENDIAN 261# define _LIBCPP_LITTLE_ENDIAN 262# else // _BYTE_ORDER == _LITTLE_ENDIAN 263# define _LIBCPP_BIG_ENDIAN 264# endif // _BYTE_ORDER == _LITTLE_ENDIAN 265# ifndef __LONG_LONG_SUPPORTED 266# define _LIBCPP_HAS_NO_LONG_LONG 267# endif // __LONG_LONG_SUPPORTED 268#endif // __FreeBSD__ 269 270#if defined(__NetBSD__) || defined(__OpenBSD__) 271# include <sys/endian.h> 272# if _BYTE_ORDER == _LITTLE_ENDIAN 273# define _LIBCPP_LITTLE_ENDIAN 274# else // _BYTE_ORDER == _LITTLE_ENDIAN 275# define _LIBCPP_BIG_ENDIAN 276# endif // _BYTE_ORDER == _LITTLE_ENDIAN 277#endif // defined(__NetBSD__) || defined(__OpenBSD__) 278 279#if defined(_WIN32) 280# define _LIBCPP_WIN32API 281# define _LIBCPP_LITTLE_ENDIAN 282# define _LIBCPP_SHORT_WCHAR 1 283// Both MinGW and native MSVC provide a "MSVC"-like environment 284# define _LIBCPP_MSVCRT_LIKE 285// If mingw not explicitly detected, assume using MS C runtime only if 286// a MS compatibility version is specified. 287# if defined(_MSC_VER) && !defined(__MINGW32__) 288# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 289# endif 290# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 291# define _LIBCPP_HAS_BITSCAN64 292# endif 293# define _LIBCPP_HAS_OPEN_WITH_WCHAR 294# if defined(_LIBCPP_MSVCRT) 295# define _LIBCPP_HAS_QUICK_EXIT 296# endif 297 298// Some CRT APIs are unavailable to store apps 299# if defined(WINAPI_FAMILY) 300# include <winapifamily.h> 301# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ 302 (!defined(WINAPI_PARTITION_SYSTEM) || \ 303 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) 304# define _LIBCPP_WINDOWS_STORE_APP 305# endif 306# endif 307#endif // defined(_WIN32) 308 309#ifdef __sun__ 310# include <sys/isa_defs.h> 311# ifdef _LITTLE_ENDIAN 312# define _LIBCPP_LITTLE_ENDIAN 313# else 314# define _LIBCPP_BIG_ENDIAN 315# endif 316#endif // __sun__ 317 318#if defined(__OpenBSD__) || defined(__CloudABI__) 319 // Certain architectures provide arc4random(). Prefer using 320 // arc4random() over /dev/{u,}random to make it possible to obtain 321 // random data even when using sandboxing mechanisms such as chroots, 322 // Capsicum, etc. 323# define _LIBCPP_USING_ARC4_RANDOM 324#elif defined(__Fuchsia__) || defined(__wasi__) 325# define _LIBCPP_USING_GETENTROPY 326#elif defined(__native_client__) 327 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 328 // including accesses to the special files under /dev. C++11's 329 // std::random_device is instead exposed through a NaCl syscall. 330# define _LIBCPP_USING_NACL_RANDOM 331#elif defined(_LIBCPP_WIN32API) 332# define _LIBCPP_USING_WIN32_RANDOM 333#else 334# define _LIBCPP_USING_DEV_RANDOM 335#endif 336 337#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 338# include <endian.h> 339# if __BYTE_ORDER == __LITTLE_ENDIAN 340# define _LIBCPP_LITTLE_ENDIAN 341# elif __BYTE_ORDER == __BIG_ENDIAN 342# define _LIBCPP_BIG_ENDIAN 343# else // __BYTE_ORDER == __BIG_ENDIAN 344# error unable to determine endian 345# endif 346#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 347 348#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 349# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 350#else 351# define _LIBCPP_NO_CFI 352#endif 353 354#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L 355# if defined(__FreeBSD__) 356# define _LIBCPP_HAS_ALIGNED_ALLOC 357# define _LIBCPP_HAS_QUICK_EXIT 358# if __FreeBSD_version >= 1300064 || \ 359 (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) 360# define _LIBCPP_HAS_TIMESPEC_GET 361# endif 362# elif defined(__BIONIC__) 363# if __ANDROID_API__ >= 21 364# define _LIBCPP_HAS_QUICK_EXIT 365# endif 366# if __ANDROID_API__ >= 28 367# define _LIBCPP_HAS_ALIGNED_ALLOC 368# endif 369# if __ANDROID_API__ >= 29 370# define _LIBCPP_HAS_TIMESPEC_GET 371# endif 372# elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) 373# define _LIBCPP_HAS_ALIGNED_ALLOC 374# define _LIBCPP_HAS_QUICK_EXIT 375# define _LIBCPP_HAS_TIMESPEC_GET 376# elif defined(__OpenBSD__) 377# define _LIBCPP_HAS_ALIGNED_ALLOC 378# define _LIBCPP_HAS_TIMESPEC_GET 379# elif defined(__linux__) 380# if !defined(_LIBCPP_HAS_MUSL_LIBC) 381# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) 382# define _LIBCPP_HAS_QUICK_EXIT 383# endif 384# if _LIBCPP_GLIBC_PREREQ(2, 17) 385# define _LIBCPP_HAS_ALIGNED_ALLOC 386# define _LIBCPP_HAS_TIMESPEC_GET 387# endif 388# else // defined(_LIBCPP_HAS_MUSL_LIBC) 389# define _LIBCPP_HAS_ALIGNED_ALLOC 390# define _LIBCPP_HAS_QUICK_EXIT 391# define _LIBCPP_HAS_TIMESPEC_GET 392# endif 393# elif defined(__APPLE__) 394 // timespec_get and aligned_alloc were introduced in macOS 10.15 and 395 // aligned releases 396# if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \ 397 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ 398 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ 399 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)) 400# define _LIBCPP_HAS_ALIGNED_ALLOC 401# define _LIBCPP_HAS_TIMESPEC_GET 402# endif 403# endif // __APPLE__ 404#endif 405 406#ifndef _LIBCPP_CXX03_LANG 407# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 408#elif defined(_LIBCPP_COMPILER_CLANG_BASED) 409# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 410#else 411# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" 412#endif 413 414#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 415 416#if defined(_LIBCPP_COMPILER_CLANG_BASED) 417 418#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) 419# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead 420#endif 421#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ 422 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 423# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 424#endif 425 426#if __has_feature(cxx_alignas) 427# define _ALIGNAS_TYPE(x) alignas(x) 428# define _ALIGNAS(x) alignas(x) 429#else 430# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 431# define _ALIGNAS(x) __attribute__((__aligned__(x))) 432#endif 433 434#if __cplusplus < 201103L 435typedef __char16_t char16_t; 436typedef __char32_t char32_t; 437#endif 438 439#if !__has_feature(cxx_exceptions) 440# define _LIBCPP_NO_EXCEPTIONS 441#endif 442 443#if !(__has_feature(cxx_strong_enums)) 444#define _LIBCPP_HAS_NO_STRONG_ENUMS 445#endif 446 447#if __has_feature(cxx_attributes) 448# define _LIBCPP_NORETURN [[noreturn]] 449#else 450# define _LIBCPP_NORETURN __attribute__ ((noreturn)) 451#endif 452 453#if !(__has_feature(cxx_nullptr)) 454# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) 455# define nullptr __nullptr 456# else 457# define _LIBCPP_HAS_NO_NULLPTR 458# endif 459#endif 460 461// Objective-C++ features (opt-in) 462#if __has_feature(objc_arc) 463#define _LIBCPP_HAS_OBJC_ARC 464#endif 465 466#if __has_feature(objc_arc_weak) 467#define _LIBCPP_HAS_OBJC_ARC_WEAK 468#endif 469 470#if __has_extension(blocks) 471# define _LIBCPP_HAS_EXTENSION_BLOCKS 472#endif 473 474#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 475# define _LIBCPP_HAS_BLOCKS_RUNTIME 476#endif 477 478#if !(__has_feature(cxx_relaxed_constexpr)) 479#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 480#endif 481 482#if !(__has_feature(cxx_variable_templates)) 483#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 484#endif 485 486#if !(__has_feature(cxx_noexcept)) 487#define _LIBCPP_HAS_NO_NOEXCEPT 488#endif 489 490#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) 491#define _LIBCPP_HAS_NO_ASAN 492#endif 493 494// Allow for build-time disabling of unsigned integer sanitization 495#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) 496#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 497#endif 498 499#if __has_builtin(__builtin_launder) 500#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER 501#endif 502 503#if __has_builtin(__builtin_constant_p) 504#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 505#endif 506 507#if !__is_identifier(__has_unique_object_representations) 508#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 509#endif 510 511#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 512 513// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1 514#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \ 515 (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001) 516#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS 517#endif 518 519#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 520 521#elif defined(_LIBCPP_COMPILER_GCC) 522 523#define _ALIGNAS(x) __attribute__((__aligned__(x))) 524#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 525 526#define _LIBCPP_NORETURN __attribute__((noreturn)) 527 528#if !__EXCEPTIONS 529# define _LIBCPP_NO_EXCEPTIONS 530#endif 531 532// Determine if GCC supports relaxed constexpr 533#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L 534#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 535#endif 536 537// GCC 5 supports variable templates 538#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L 539#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 540#endif 541 542#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) 543#define _LIBCPP_HAS_NO_ASAN 544#endif 545 546#if _GNUC_VER >= 700 547#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER 548#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 549#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS 550#endif 551 552#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 553 554#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 555 556#elif defined(_LIBCPP_COMPILER_MSVC) 557 558#define _LIBCPP_TOSTRING2(x) #x 559#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 560#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 561 562#if _MSC_VER < 1900 563#error "MSVC versions prior to Visual Studio 2015 are not supported" 564#endif 565 566#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 567#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 568#define __alignof__ __alignof 569#define _LIBCPP_NORETURN __declspec(noreturn) 570#define _ALIGNAS(x) __declspec(align(x)) 571#define _ALIGNAS_TYPE(x) alignas(x) 572 573#define _LIBCPP_WEAK 574 575#define _LIBCPP_HAS_NO_ASAN 576 577#define _LIBCPP_ALWAYS_INLINE __forceinline 578 579#define _LIBCPP_HAS_NO_VECTOR_EXTENSION 580 581#define _LIBCPP_DISABLE_EXTENSION_WARNING 582 583#elif defined(_LIBCPP_COMPILER_IBM) 584 585#define _ALIGNAS(x) __attribute__((__aligned__(x))) 586#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 587#define _ATTRIBUTE(x) __attribute__((x)) 588#define _LIBCPP_NORETURN __attribute__((noreturn)) 589 590#define _LIBCPP_HAS_NO_UNICODE_CHARS 591#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 592 593#if defined(_AIX) 594#define __MULTILOCALE_API 595#endif 596 597#define _LIBCPP_HAS_NO_ASAN 598 599#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 600 601#define _LIBCPP_HAS_NO_VECTOR_EXTENSION 602 603#define _LIBCPP_DISABLE_EXTENSION_WARNING 604 605#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] 606 607#if defined(_LIBCPP_OBJECT_FORMAT_COFF) 608 609#ifdef _DLL 610# define _LIBCPP_CRT_FUNC __declspec(dllimport) 611#else 612# define _LIBCPP_CRT_FUNC 613#endif 614 615#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 616# define _LIBCPP_DLL_VIS 617# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 618# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 619# define _LIBCPP_OVERRIDABLE_FUNC_VIS 620# define _LIBCPP_EXPORTED_FROM_ABI 621#elif defined(_LIBCPP_BUILDING_LIBRARY) 622# define _LIBCPP_DLL_VIS __declspec(dllexport) 623# if defined(__MINGW32__) 624# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 625# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 626# else 627# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 628# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 629# endif 630# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 631# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 632#else 633# define _LIBCPP_DLL_VIS __declspec(dllimport) 634# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 635# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 636# define _LIBCPP_OVERRIDABLE_FUNC_VIS 637# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 638#endif 639 640#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 641#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 642#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 643#define _LIBCPP_HIDDEN 644#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 645#define _LIBCPP_TEMPLATE_VIS 646#define _LIBCPP_TEMPLATE_DATA_VIS 647#define _LIBCPP_ENUM_VIS 648 649#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 650 651#ifndef _LIBCPP_HIDDEN 652# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 653# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) 654# else 655# define _LIBCPP_HIDDEN 656# endif 657#endif 658 659#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 660# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 661// The inline should be removed once PR32114 is resolved 662# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 663# else 664# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 665# endif 666#endif 667 668#ifndef _LIBCPP_FUNC_VIS 669# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 670# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) 671# else 672# define _LIBCPP_FUNC_VIS 673# endif 674#endif 675 676#ifndef _LIBCPP_TYPE_VIS 677# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 678# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) 679# else 680# define _LIBCPP_TYPE_VIS 681# endif 682#endif 683 684#ifndef _LIBCPP_TEMPLATE_VIS 685# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 686# if __has_attribute(__type_visibility__) 687# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) 688# else 689# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) 690# endif 691# else 692# define _LIBCPP_TEMPLATE_VIS 693# endif 694#endif 695 696#ifndef _LIBCPP_TEMPLATE_DATA_VIS 697# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 698# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default"))) 699# else 700# define _LIBCPP_TEMPLATE_DATA_VIS 701# endif 702#endif 703 704#ifndef _LIBCPP_EXPORTED_FROM_ABI 705# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 706# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) 707# else 708# define _LIBCPP_EXPORTED_FROM_ABI 709# endif 710#endif 711 712#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 713#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS 714#endif 715 716#ifndef _LIBCPP_EXCEPTION_ABI 717# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 718# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) 719# else 720# define _LIBCPP_EXCEPTION_ABI 721# endif 722#endif 723 724#ifndef _LIBCPP_ENUM_VIS 725# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 726# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) 727# else 728# define _LIBCPP_ENUM_VIS 729# endif 730#endif 731 732#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 733# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 734# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) 735# else 736# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 737# endif 738#endif 739 740#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 741#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 742#endif 743 744#if __has_attribute(internal_linkage) 745# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) 746#else 747# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE 748#endif 749 750#if __has_attribute(exclude_from_explicit_instantiation) 751# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) 752#else 753 // Try to approximate the effect of exclude_from_explicit_instantiation 754 // (which is that entities are not assumed to be provided by explicit 755 // template instantiations in the dylib) by always inlining those entities. 756# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 757#endif 758 759#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU 760# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT 761# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 762# else 763# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 764# endif 765#endif 766 767#ifndef _LIBCPP_HIDE_FROM_ABI 768# if _LIBCPP_HIDE_FROM_ABI_PER_TU 769# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE 770# else 771# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 772# endif 773#endif 774 775#ifdef _LIBCPP_BUILDING_LIBRARY 776# if _LIBCPP_ABI_VERSION > 1 777# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 778# else 779# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 780# endif 781#else 782# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 783#endif 784 785// Just so we can migrate to the new macros gradually. 786#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 787 788// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 789#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 790#define _LIBCPP_END_NAMESPACE_STD } } 791#define _VSTD std::_LIBCPP_ABI_NAMESPACE 792_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 793 794#if _LIBCPP_STD_VER >= 17 795#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 796 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 797#else 798#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 799 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 800#endif 801 802#define _LIBCPP_END_NAMESPACE_FILESYSTEM \ 803 _LIBCPP_END_NAMESPACE_STD } } 804 805#define _VSTD_FS _VSTD::__fs::filesystem 806 807#ifndef _LIBCPP_PREFERRED_OVERLOAD 808# if __has_attribute(__enable_if__) 809# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) 810# endif 811#endif 812 813#ifndef _LIBCPP_HAS_NO_NOEXCEPT 814# define _NOEXCEPT noexcept 815# define _NOEXCEPT_(x) noexcept(x) 816#else 817# define _NOEXCEPT throw() 818# define _NOEXCEPT_(x) 819#endif 820 821#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS 822typedef unsigned short char16_t; 823typedef unsigned int char32_t; 824#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 825 826#ifndef __SIZEOF_INT128__ 827#define _LIBCPP_HAS_NO_INT128 828#endif 829 830#ifdef _LIBCPP_CXX03_LANG 831# define static_assert(...) _Static_assert(__VA_ARGS__) 832# define decltype(...) __decltype(__VA_ARGS__) 833#endif // _LIBCPP_CXX03_LANG 834 835#ifdef _LIBCPP_CXX03_LANG 836# define _LIBCPP_CONSTEXPR 837#else 838# define _LIBCPP_CONSTEXPR constexpr 839#endif 840 841#ifndef __cpp_consteval 842# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR 843#else 844# define _LIBCPP_CONSTEVAL consteval 845#endif 846 847#if !defined(__cpp_concepts) || __cpp_concepts < 201907L 848#define _LIBCPP_HAS_NO_CONCEPTS 849#endif 850 851#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_MSC_VER) 852#define _LIBCPP_HAS_NO_RANGES 853#endif 854 855#ifdef _LIBCPP_CXX03_LANG 856# define _LIBCPP_DEFAULT {} 857#else 858# define _LIBCPP_DEFAULT = default; 859#endif 860 861#ifdef _LIBCPP_CXX03_LANG 862# define _LIBCPP_EQUAL_DELETE 863#else 864# define _LIBCPP_EQUAL_DELETE = delete 865#endif 866 867#ifdef __GNUC__ 868# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 869#else 870# define _LIBCPP_NOALIAS 871#endif 872 873#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ 874 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions 875# define _LIBCPP_EXPLICIT explicit 876#else 877# define _LIBCPP_EXPLICIT 878#endif 879 880#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 881# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx 882# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 883 __lx __v_; \ 884 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 885 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 886 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ 887 }; 888#else // _LIBCPP_HAS_NO_STRONG_ENUMS 889# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 890# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 891#endif // _LIBCPP_HAS_NO_STRONG_ENUMS 892 893// _LIBCPP_DEBUG potential values: 894// - undefined: No assertions. This is the default. 895// - 0: Basic assertions 896// - 1: Basic assertions + iterator validity checks. 897#if !defined(_LIBCPP_DEBUG) 898# define _LIBCPP_DEBUG_LEVEL 0 899#elif _LIBCPP_DEBUG == 0 900# define _LIBCPP_DEBUG_LEVEL 1 901#elif _LIBCPP_DEBUG == 1 902# define _LIBCPP_DEBUG_LEVEL 2 903#else 904# error Supported values for _LIBCPP_DEBUG are 0 and 1 905#endif 906 907// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point 908#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) 909# define _LIBCPP_EXTERN_TEMPLATE(...) 910#endif 911 912#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE 913# define _LIBCPP_EXTERN_TEMPLATE(...) 914# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) 915#endif 916 917#ifndef _LIBCPP_EXTERN_TEMPLATE 918#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; 919#endif 920 921// When the Debug mode is enabled, we disable extern declarations because we 922// don't want to use the functions compiled in the library, which might not 923// have had the debug mode enabled when built. However, some extern declarations 924// need to be used, because code correctness depends on it (several instances 925// in the <locale>). Those special declarations are declared with 926// _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled even 927// when the debug mode is enabled. 928#ifndef _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE 929# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; 930#endif 931 932#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE 933#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; 934#endif 935 936#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ 937 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) 938#define _LIBCPP_LOCALE__L_EXTENSIONS 1 939#endif 940 941#ifdef __FreeBSD__ 942#define _DECLARE_C99_LDBL_MATH 1 943#endif 944 945// If we are getting operator new from the MSVC CRT, then allocation overloads 946// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 947#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 948# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 949#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 950 // We're deferring to Microsoft's STL to provide aligned new et al. We don't 951 // have it unless the language feature test macro is defined. 952# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 953#elif defined(__MVS__) 954# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 955#endif 956 957#if defined(__APPLE__) 958# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ 959 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) 960# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 961# endif 962#endif // defined(__APPLE__) 963 964#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ 965 (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ 966 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)) 967# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 968#endif 969 970#if defined(__APPLE__) || defined(__FreeBSD__) 971#define _LIBCPP_HAS_DEFAULTRUNELOCALE 972#endif 973 974#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 975#define _LIBCPP_WCTYPE_IS_MASK 976#endif 977 978#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 979#define _LIBCPP_HAS_NO_CHAR8_T 980#endif 981 982// Deprecation macros. 983// 984// Deprecations warnings are always enabled, except when users explicitly opt-out 985// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 986#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 987# if __has_attribute(deprecated) 988# define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) 989# elif _LIBCPP_STD_VER > 11 990# define _LIBCPP_DEPRECATED [[deprecated]] 991# else 992# define _LIBCPP_DEPRECATED 993# endif 994#else 995# define _LIBCPP_DEPRECATED 996#endif 997 998#if !defined(_LIBCPP_CXX03_LANG) 999# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 1000#else 1001# define _LIBCPP_DEPRECATED_IN_CXX11 1002#endif 1003 1004#if _LIBCPP_STD_VER >= 14 1005# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 1006#else 1007# define _LIBCPP_DEPRECATED_IN_CXX14 1008#endif 1009 1010#if _LIBCPP_STD_VER >= 17 1011# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 1012#else 1013# define _LIBCPP_DEPRECATED_IN_CXX17 1014#endif 1015 1016#if _LIBCPP_STD_VER > 17 1017# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 1018#else 1019# define _LIBCPP_DEPRECATED_IN_CXX20 1020#endif 1021 1022#if !defined(_LIBCPP_HAS_NO_CHAR8_T) 1023# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 1024#else 1025# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 1026#endif 1027 1028// Macros to enter and leave a state where deprecation warnings are suppressed. 1029#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \ 1030 (defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)) 1031# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 1032 _Pragma("GCC diagnostic push") \ 1033 _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") 1034# define _LIBCPP_SUPPRESS_DEPRECATED_POP \ 1035 _Pragma("GCC diagnostic pop") 1036#endif 1037#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) 1038# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 1039# define _LIBCPP_SUPPRESS_DEPRECATED_POP 1040#endif 1041 1042#if _LIBCPP_STD_VER <= 11 1043# define _LIBCPP_EXPLICIT_AFTER_CXX11 1044#else 1045# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 1046#endif 1047 1048#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 1049# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 1050#else 1051# define _LIBCPP_CONSTEXPR_AFTER_CXX11 1052#endif 1053 1054#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 1055# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 1056#else 1057# define _LIBCPP_CONSTEXPR_AFTER_CXX14 1058#endif 1059 1060#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 1061# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr 1062#else 1063# define _LIBCPP_CONSTEXPR_AFTER_CXX17 1064#endif 1065 1066// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other 1067// NODISCARD macros to the correct attribute. 1068#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) 1069# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]] 1070#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) 1071# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]] 1072#else 1073// We can't use GCC's [[gnu::warn_unused_result]] and 1074// __attribute__((warn_unused_result)), because GCC does not silence them via 1075// (void) cast. 1076# define _LIBCPP_NODISCARD_ATTRIBUTE 1077#endif 1078 1079// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 1080// specified as such as an extension. 1081#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 1082# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE 1083#else 1084# define _LIBCPP_NODISCARD_EXT 1085#endif 1086 1087#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ 1088 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) 1089# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE 1090#else 1091# define _LIBCPP_NODISCARD_AFTER_CXX17 1092#endif 1093 1094#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) 1095# define _LIBCPP_INLINE_VAR inline 1096#else 1097# define _LIBCPP_INLINE_VAR 1098#endif 1099 1100#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG 1101#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 1102#define _LIBCPP_CONSTEXPR_IF_NODEBUG 1103#else 1104#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr 1105#endif 1106#endif 1107 1108#if __has_attribute(no_destroy) 1109# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 1110#else 1111# define _LIBCPP_NO_DESTROY 1112#endif 1113 1114#ifndef _LIBCPP_HAS_NO_ASAN 1115extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( 1116 const void *, const void *, const void *, const void *); 1117#endif 1118 1119// Try to find out if RTTI is disabled. 1120#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) 1121# define _LIBCPP_NO_RTTI 1122#elif defined(__GNUC__) && !defined(__GXX_RTTI) 1123# define _LIBCPP_NO_RTTI 1124#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) 1125# define _LIBCPP_NO_RTTI 1126#endif 1127 1128#ifndef _LIBCPP_WEAK 1129#define _LIBCPP_WEAK __attribute__((__weak__)) 1130#endif 1131 1132// Thread API 1133#if !defined(_LIBCPP_HAS_NO_THREADS) && \ 1134 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 1135 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 1136 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 1137# if defined(__FreeBSD__) || \ 1138 defined(__wasi__) || \ 1139 defined(__NetBSD__) || \ 1140 defined(__OpenBSD__) || \ 1141 defined(__NuttX__) || \ 1142 defined(__linux__) || \ 1143 defined(__GNU__) || \ 1144 defined(__APPLE__) || \ 1145 defined(__CloudABI__) || \ 1146 defined(__sun__) || \ 1147 defined(__MVS__) || \ 1148 defined(_AIX) || \ 1149 (defined(__MINGW32__) && __has_include(<pthread.h>)) 1150# define _LIBCPP_HAS_THREAD_API_PTHREAD 1151# elif defined(__Fuchsia__) 1152 // TODO(44575): Switch to C11 thread API when possible. 1153# define _LIBCPP_HAS_THREAD_API_PTHREAD 1154# elif defined(_LIBCPP_WIN32API) 1155# define _LIBCPP_HAS_THREAD_API_WIN32 1156# else 1157# error "No thread API" 1158# endif // _LIBCPP_HAS_THREAD_API 1159#endif // _LIBCPP_HAS_NO_THREADS 1160 1161#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 1162#if defined(__ANDROID__) && __ANDROID_API__ >= 30 1163#define _LIBCPP_HAS_COND_CLOCKWAIT 1164#elif defined(_LIBCPP_GLIBC_PREREQ) 1165#if _LIBCPP_GLIBC_PREREQ(2, 30) 1166#define _LIBCPP_HAS_COND_CLOCKWAIT 1167#endif 1168#endif 1169#endif 1170 1171#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 1172#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 1173 _LIBCPP_HAS_NO_THREADS is not defined. 1174#endif 1175 1176#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 1177#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 1178 _LIBCPP_HAS_NO_THREADS is defined. 1179#endif 1180 1181#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 1182#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 1183 _LIBCPP_HAS_NO_THREADS is defined. 1184#endif 1185 1186#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 1187#define __STDCPP_THREADS__ 1 1188#endif 1189 1190// The glibc and Bionic implementation of pthreads implements 1191// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 1192// mutexes have no destroy mechanism. 1193// 1194// This optimization can't be performed on Apple platforms, where 1195// pthread_mutex_destroy can allow the kernel to release resources. 1196// See https://llvm.org/D64298 for details. 1197// 1198// TODO(EricWF): Enable this optimization on Bionic after speaking to their 1199// respective stakeholders. 1200#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ 1201 || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ 1202 || defined(_LIBCPP_HAS_THREAD_API_WIN32) 1203# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1204#endif 1205 1206// Destroying a condvar is a nop on Windows. 1207// 1208// This optimization can't be performed on Apple platforms, where 1209// pthread_cond_destroy can allow the kernel to release resources. 1210// See https://llvm.org/D64298 for details. 1211// 1212// TODO(EricWF): This is potentially true for some pthread implementations 1213// as well. 1214#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 1215 defined(_LIBCPP_HAS_THREAD_API_WIN32) 1216# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1217#endif 1218 1219// Systems that use capability-based security (FreeBSD with Capsicum, 1220// Nuxi CloudABI) may only provide local filesystem access (using *at()). 1221// Functions like open(), rename(), unlink() and stat() should not be 1222// used, as they attempt to access the global filesystem namespace. 1223#ifdef __CloudABI__ 1224#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1225#endif 1226 1227// CloudABI is intended for running networked services. Processes do not 1228// have standard input and output channels. 1229#ifdef __CloudABI__ 1230#define _LIBCPP_HAS_NO_STDIN 1231#define _LIBCPP_HAS_NO_STDOUT 1232#endif 1233 1234// Some systems do not provide gets() in their C library, for security reasons. 1235#ifndef _LIBCPP_C_HAS_NO_GETS 1236# if defined(_LIBCPP_MSVCRT) || \ 1237 (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ 1238 defined(__OpenBSD__) 1239# define _LIBCPP_C_HAS_NO_GETS 1240# endif 1241#endif 1242 1243#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \ 1244 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \ 1245 defined(__MVS__) || defined(__OpenBSD__) 1246#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1247#endif 1248 1249// Thread-unsafe functions such as strtok() and localtime() 1250// are not available. 1251#ifdef __CloudABI__ 1252#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS 1253#endif 1254 1255#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 1256# define _LIBCPP_HAS_C_ATOMIC_IMP 1257#elif defined(_LIBCPP_COMPILER_GCC) 1258# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1259#endif 1260 1261#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ 1262 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 1263 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \ 1264 || defined(_LIBCPP_HAS_NO_THREADS) 1265# define _LIBCPP_HAS_NO_ATOMIC_HEADER 1266#else 1267# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 1268# define _LIBCPP_ATOMIC_FLAG_TYPE bool 1269# endif 1270# ifdef _LIBCPP_FREESTANDING 1271# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 1272# endif 1273#endif 1274 1275#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1276#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1277#endif 1278 1279#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 1280# if defined(__clang__) && __has_attribute(acquire_capability) 1281// Work around the attribute handling in clang. When both __declspec and 1282// __attribute__ are present, the processing goes awry preventing the definition 1283// of the types. 1284# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) 1285# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1286# endif 1287# endif 1288#endif 1289 1290#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION 1291# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1292# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1293# else 1294# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1295# endif 1296#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION 1297 1298#if __has_attribute(require_constant_initialization) 1299# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) 1300#else 1301# define _LIBCPP_SAFE_STATIC 1302#endif 1303 1304#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 1305#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 1306#endif 1307 1308#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900 1309#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED 1310#endif 1311 1312#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1313# define _LIBCPP_DIAGNOSE_WARNING(...) \ 1314 __attribute__((diagnose_if(__VA_ARGS__, "warning"))) 1315# define _LIBCPP_DIAGNOSE_ERROR(...) \ 1316 __attribute__((diagnose_if(__VA_ARGS__, "error"))) 1317#else 1318# define _LIBCPP_DIAGNOSE_WARNING(...) 1319# define _LIBCPP_DIAGNOSE_ERROR(...) 1320#endif 1321 1322// Use a function like macro to imply that it must be followed by a semicolon 1323#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) 1324# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1325#elif __has_cpp_attribute(clang::fallthrough) 1326# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] 1327#elif __has_attribute(fallthrough) || _GNUC_VER >= 700 1328# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 1329#else 1330# define _LIBCPP_FALLTHROUGH() ((void)0) 1331#endif 1332 1333#if __has_attribute(__nodebug__) 1334#define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 1335#else 1336#define _LIBCPP_NODEBUG 1337#endif 1338 1339#ifndef _LIBCPP_NODEBUG_TYPE 1340#if __has_attribute(__nodebug__) && \ 1341 (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900) 1342#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) 1343#else 1344#define _LIBCPP_NODEBUG_TYPE 1345#endif 1346#endif // !defined(_LIBCPP_NODEBUG_TYPE) 1347 1348#if __has_attribute(__preferred_name__) 1349#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 1350#else 1351#define _LIBCPP_PREFERRED_NAME(x) 1352#endif 1353 1354#if defined(_LIBCPP_ABI_MICROSOFT) && \ 1355 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) 1356# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 1357#else 1358# define _LIBCPP_DECLSPEC_EMPTY_BASES 1359#endif 1360 1361#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 1362#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 1363#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1364#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1365#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1366#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 1367 1368#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 1369#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES 1370#endif 1371 1372#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) 1373#define _LIBCPP_HAS_NO_IS_AGGREGATE 1374#endif 1375 1376#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L 1377#define _LIBCPP_HAS_NO_COROUTINES 1378#endif 1379 1380#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L 1381#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR 1382#endif 1383 1384#if defined(_LIBCPP_COMPILER_IBM) 1385#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO 1386#endif 1387 1388#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) 1389# define _LIBCPP_PUSH_MACROS 1390# define _LIBCPP_POP_MACROS 1391#else 1392 // Don't warn about macro conflicts when we can restore them at the 1393 // end of the header. 1394# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS 1395# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS 1396# endif 1397# if defined(_LIBCPP_COMPILER_MSVC) 1398# define _LIBCPP_PUSH_MACROS \ 1399 __pragma(push_macro("min")) \ 1400 __pragma(push_macro("max")) 1401# define _LIBCPP_POP_MACROS \ 1402 __pragma(pop_macro("min")) \ 1403 __pragma(pop_macro("max")) 1404# else 1405# define _LIBCPP_PUSH_MACROS \ 1406 _Pragma("push_macro(\"min\")") \ 1407 _Pragma("push_macro(\"max\")") 1408# define _LIBCPP_POP_MACROS \ 1409 _Pragma("pop_macro(\"min\")") \ 1410 _Pragma("pop_macro(\"max\")") 1411# endif 1412#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) 1413 1414#ifndef _LIBCPP_NO_AUTO_LINK 1415# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1416# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 1417# pragma comment(lib, "c++.lib") 1418# else 1419# pragma comment(lib, "libc++.lib") 1420# endif 1421# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1422#endif // _LIBCPP_NO_AUTO_LINK 1423 1424// Configures the fopen close-on-exec mode character, if any. This string will 1425// be appended to any mode string used by fstream for fopen/fdopen. 1426// 1427// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1428// do. 1429#if defined(__BIONIC__) 1430# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1431#else 1432# define _LIBCPP_FOPEN_CLOEXEC_MODE 1433#endif 1434 1435#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P 1436#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) 1437#else 1438#define _LIBCPP_BUILTIN_CONSTANT_P(x) false 1439#endif 1440 1441// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1442// of functions used in cstdio may not be available for low API levels when 1443// using 64-bit file offsets on LP32. 1444#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1445#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1446#endif 1447 1448#if __has_attribute(init_priority) 1449# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) 1450#else 1451# define _LIBCPP_INIT_PRIORITY_MAX 1452#endif 1453 1454#if defined(__GNUC__) || defined(__clang__) 1455#define _LIBCPP_FORMAT_PRINTF(a, b) \ 1456 __attribute__((__format__(__printf__, a, b))) 1457#else 1458#define _LIBCPP_FORMAT_PRINTF(a, b) 1459#endif 1460 1461#endif // __cplusplus 1462 1463#endif // _LIBCPP_CONFIG 1464