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