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