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