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