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