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