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