1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP___CONFIG 11#define _LIBCPP___CONFIG 12 13#include <__config_site> 14 15#if defined(_MSC_VER) && !defined(__clang__) 16# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 18# endif 19#endif 20 21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 22# pragma GCC system_header 23#endif 24 25#if defined(__apple_build_version__) 26// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403) 27# define _LIBCPP_COMPILER_CLANG_BASED 28# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) 29#elif defined(__clang__) 30# define _LIBCPP_COMPILER_CLANG_BASED 31# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 32#elif defined(__GNUC__) 33# define _LIBCPP_COMPILER_GCC 34#endif 35 36#ifdef __cplusplus 37 38// The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html 39 40// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. 41// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is 42// defined to XXYYZZ. 43# define _LIBCPP_VERSION 170000 44 45# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y 46# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) 47 48// Valid C++ identifier that revs with every libc++ version. This can be used to 49// generate identifiers that must be unique for every released libc++ version. 50# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION) 51 52# if __STDC_HOSTED__ == 0 53# define _LIBCPP_FREESTANDING 54# endif 55 56// NOLINTBEGIN(libcpp-cpp-version-check) 57# ifndef _LIBCPP_STD_VER 58# if __cplusplus <= 201103L 59# define _LIBCPP_STD_VER 11 60# elif __cplusplus <= 201402L 61# define _LIBCPP_STD_VER 14 62# elif __cplusplus <= 201703L 63# define _LIBCPP_STD_VER 17 64# elif __cplusplus <= 202002L 65# define _LIBCPP_STD_VER 20 66# elif __cplusplus <= 202302L 67# define _LIBCPP_STD_VER 23 68# else 69// Expected release year of the next C++ standard 70# define _LIBCPP_STD_VER 26 71# endif 72# endif // _LIBCPP_STD_VER 73// NOLINTEND(libcpp-cpp-version-check) 74 75# if defined(__ELF__) 76# define _LIBCPP_OBJECT_FORMAT_ELF 1 77# elif defined(__MACH__) 78# define _LIBCPP_OBJECT_FORMAT_MACHO 1 79# elif defined(_WIN32) 80# define _LIBCPP_OBJECT_FORMAT_COFF 1 81# elif defined(__wasm__) 82# define _LIBCPP_OBJECT_FORMAT_WASM 1 83# elif defined(_AIX) 84# define _LIBCPP_OBJECT_FORMAT_XCOFF 1 85# else 86// ... add new file formats here ... 87# endif 88 89// ABI { 90 91# if _LIBCPP_ABI_VERSION >= 2 92// Change short string representation so that string data starts at offset 0, 93// improving its alignment in some cases. 94# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 95// Fix deque iterator type in order to support incomplete types. 96# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 97// Fix undefined behavior in how std::list stores its linked nodes. 98# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 99// Fix undefined behavior in how __tree stores its end and parent nodes. 100# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 101// Fix undefined behavior in how __hash_table stores its pointer types. 102# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 103# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 104# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 105// Define a key function for `bad_function_call` in the library, to centralize 106// its vtable and typeinfo to libc++ rather than having all other libraries 107// using that class define their own copies. 108# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 109// Override the default return value of exception::what() for 110// bad_function_call::what() with a string that is specific to 111// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break 112// because it changes the vtable layout of bad_function_call. 113# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 114// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 115# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 116// Give reverse_iterator<T> one data member of type T, not two. 117// Also, in C++17 and later, don't derive iterator types from std::iterator. 118# define _LIBCPP_ABI_NO_ITERATOR_BASES 119// Use the smallest possible integer type to represent the index of the variant. 120// Previously libc++ used "unsigned int" exclusively. 121# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 122// Unstable attempt to provide a more optimized std::function 123# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 124// All the regex constants must be distinct and nonzero. 125# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 126// Re-worked external template instantiations for std::string with a focus on 127// performance and fast-path inlining. 128# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 129// Enable clang::trivial_abi on std::unique_ptr. 130# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 131// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 132# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 133// std::random_device holds some state when it uses an implementation that gets 134// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 135// implementation to another one on a platform that has already shipped 136// std::random_device, one needs to retain the same object layout to remain ABI 137// compatible. This switch removes these workarounds for platforms that don't care 138// about ABI compatibility. 139# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 140// Don't export the legacy __basic_string_common class and its methods from the built library. 141# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 142// Don't export the legacy __vector_base_common class and its methods from the built library. 143# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 144// According to the Standard, `bitset::operator[] const` returns bool 145# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 146// Fix the implementation of CityHash used for std::hash<fundamental-type>. 147// This is an ABI break because `std::hash` will return a different result, 148// which means that hashing the same object in translation units built against 149// different versions of libc++ can return inconsistent results. This is especially 150// tricky since std::hash is used in the implementation of unordered containers. 151// 152// The incorrect implementation of CityHash has the problem that it drops some 153// bits on the floor. 154# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION 155// Remove the base 10 implementation of std::to_chars from the dylib. 156// The implementation moved to the header, but we still export the symbols from 157// the dylib for backwards compatibility. 158# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 159# elif _LIBCPP_ABI_VERSION == 1 160# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 161// Enable compiling copies of now inline methods into the dylib to support 162// applications compiled against older libraries. This is unnecessary with 163// COFF dllexport semantics, since dllexport forces a non-inline definition 164// of inline functions to be emitted anyway. Our own non-inline copy would 165// conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 166// the linker will take issue with the symbols in the shared object if the 167// weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 168// so disable it. 169# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 170# endif 171// Feature macros for disabling pre ABI v1 features. All of these options 172// are deprecated. 173# if defined(__FreeBSD__) 174# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 175# endif 176// For XCOFF linkers, we have problems if we see a weak hidden version of a symbol 177// in user code (like you get with -fvisibility-inlines-hidden) and then a strong def 178// in the library, so we need to always rely on the library version. 179# if defined(_AIX) 180# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 181# endif 182# endif 183 184# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 185// Enable additional explicit instantiations of iostreams components. This 186// reduces the number of weak definitions generated in programs that use 187// iostreams by providing a single strong definition in the shared library. 188# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 189 190// Define a key function for `bad_function_call` in the library, to centralize 191// its vtable and typeinfo to libc++ rather than having all other libraries 192// using that class define their own copies. 193# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 194# endif 195 196// Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's 197// within the bounds of the original container and asserts it on every dereference. 198// 199// ABI impact: changes the iterator type of the relevant containers. 200// 201// Supported containers: 202// - `span`; 203// - `string_view`; 204// - `array`. 205// #define _LIBCPP_ABI_BOUNDED_ITERATORS 206 207// } ABI 208 209// HARDENING { 210 211// TODO(hardening): remove this in LLVM 18. 212// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) 213// equivalent to setting the hardened mode. 214# ifdef _LIBCPP_ENABLE_ASSERTIONS 215# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_ENABLE_HARDENED_MODE instead." 216# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 217# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" 218# endif 219# if _LIBCPP_ENABLE_ASSERTIONS 220# define _LIBCPP_ENABLE_HARDENED_MODE 1 221# endif 222# endif 223 224// Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes 225// security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with 226// `_LIBCPP_ENABLE_DEBUG_MODE`. 227// 228// #define _LIBCPP_ENABLE_HARDENED_MODE 1 229 230// Enables the debug mode which contains all the checks from the hardened mode and additionally more expensive checks 231// that may affect the complexity of algorithms. The debug mode is intended to be used for testing, not in production. 232// Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE`. 233// 234// #define _LIBCPP_ENABLE_DEBUG_MODE 1 235 236// Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These 237// macros are only for internal use -- users should only pick one of the high-level hardening modes described above. 238// 239// - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and 240// a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid: 241// - the sentinel is reachable from the begin iterator; 242// - TODO(hardening): both iterators refer to the same container. 243// 244// - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through 245// the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access 246// a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like 247// `optional` and `function` are considered one-element containers for the purposes of this check. 248// 249// - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the 250// given ranges do not overlap. 251// 252// - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure 253// the containers have compatible allocators. 254// 255// - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on 256// user input. 257// 258// - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet. 259 260# ifndef _LIBCPP_ENABLE_HARDENED_MODE 261# define _LIBCPP_ENABLE_HARDENED_MODE _LIBCPP_ENABLE_HARDENED_MODE_DEFAULT 262# endif 263# if _LIBCPP_ENABLE_HARDENED_MODE != 0 && _LIBCPP_ENABLE_HARDENED_MODE != 1 264# error "_LIBCPP_ENABLE_HARDENED_MODE must be set to 0 or 1." 265# endif 266 267# ifndef _LIBCPP_ENABLE_DEBUG_MODE 268# define _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT 269# endif 270# if _LIBCPP_ENABLE_DEBUG_MODE != 0 && _LIBCPP_ENABLE_DEBUG_MODE != 1 271# error "_LIBCPP_ENABLE_DEBUG_MODE must be set to 0 or 1." 272# endif 273 274# if _LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_DEBUG_MODE 275# error "Only one of _LIBCPP_ENABLE_HARDENED_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled." 276# endif 277 278// Hardened mode checks. 279 280// clang-format off 281# if _LIBCPP_ENABLE_HARDENED_MODE 282 283// Enabled checks. 284# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) 285# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) 286// Disabled checks. 287// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security 288// vulnerability. 289# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) 290# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) 291# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) 292# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) 293 294// Debug mode checks. 295 296# elif _LIBCPP_ENABLE_DEBUG_MODE 297 298// All checks enabled. 299# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) 300# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) 301# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) 302# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) 303# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message) 304# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) 305 306// Disable all checks if hardening is not enabled. 307 308# else 309 310// All checks disabled. 311# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression) 312# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression) 313# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) 314# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) 315# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) 316# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) 317 318# endif // _LIBCPP_ENABLE_HARDENED_MODE 319// clang-format on 320 321// } HARDENING 322 323# define _LIBCPP_TOSTRING2(x) #x 324# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 325 326// NOLINTNEXTLINE(libcpp-cpp-version-check) 327# if __cplusplus < 201103L 328# define _LIBCPP_CXX03_LANG 329# endif 330 331# ifndef __has_attribute 332# define __has_attribute(__x) 0 333# endif 334 335# ifndef __has_builtin 336# define __has_builtin(__x) 0 337# endif 338 339# ifndef __has_extension 340# define __has_extension(__x) 0 341# endif 342 343# ifndef __has_feature 344# define __has_feature(__x) 0 345# endif 346 347# ifndef __has_cpp_attribute 348# define __has_cpp_attribute(__x) 0 349# endif 350 351# ifndef __has_constexpr_builtin 352# define __has_constexpr_builtin(x) 0 353# endif 354 355// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 356// the compiler and '1' otherwise. 357# ifndef __is_identifier 358# define __is_identifier(__x) 1 359# endif 360 361# ifndef __has_declspec_attribute 362# define __has_declspec_attribute(__x) 0 363# endif 364 365# define __has_keyword(__x) !(__is_identifier(__x)) 366 367# ifndef __has_include 368# define __has_include(...) 0 369# endif 370 371# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L 372# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" 373# endif 374 375// FIXME: ABI detection should be done via compiler builtin macros. This 376// is just a placeholder until Clang implements such macros. For now assume 377// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 378// and allow the user to explicitly specify the ABI to handle cases where this 379// heuristic falls short. 380# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 381# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 382# elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 383# define _LIBCPP_ABI_ITANIUM 384# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 385# define _LIBCPP_ABI_MICROSOFT 386# else 387# if defined(_WIN32) && defined(_MSC_VER) 388# define _LIBCPP_ABI_MICROSOFT 389# else 390# define _LIBCPP_ABI_ITANIUM 391# endif 392# endif 393 394# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 395# define _LIBCPP_ABI_VCRUNTIME 396# endif 397 398# if __has_feature(experimental_library) 399# ifndef _LIBCPP_ENABLE_EXPERIMENTAL 400# define _LIBCPP_ENABLE_EXPERIMENTAL 401# endif 402# endif 403 404// Incomplete features get their own specific disabling flags. This makes it 405// easier to grep for target specific flags once the feature is complete. 406# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) 407# define _LIBCPP_HAS_NO_INCOMPLETE_PSTL 408# endif 409 410# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) 411# define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN 412# endif 413 414// Need to detect which libc we're using if we're on Linux. 415# if defined(__linux__) 416# include <features.h> 417# if defined(__GLIBC_PREREQ) 418# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 419# else 420# define _LIBCPP_GLIBC_PREREQ(a, b) 0 421# endif // defined(__GLIBC_PREREQ) 422# endif // defined(__linux__) 423 424# if defined(__MVS__) 425# include <features.h> // for __NATIVE_ASCII_F 426# endif 427 428# ifdef __LITTLE_ENDIAN__ 429# if __LITTLE_ENDIAN__ 430# define _LIBCPP_LITTLE_ENDIAN 431# endif // __LITTLE_ENDIAN__ 432# endif // __LITTLE_ENDIAN__ 433 434# ifdef __BIG_ENDIAN__ 435# if __BIG_ENDIAN__ 436# define _LIBCPP_BIG_ENDIAN 437# endif // __BIG_ENDIAN__ 438# endif // __BIG_ENDIAN__ 439 440# ifdef __BYTE_ORDER__ 441# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 442# define _LIBCPP_LITTLE_ENDIAN 443# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 444# define _LIBCPP_BIG_ENDIAN 445# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 446# endif // __BYTE_ORDER__ 447 448# ifdef __FreeBSD__ 449# include <osreldate.h> 450# include <sys/endian.h> 451# if _BYTE_ORDER == _LITTLE_ENDIAN 452# define _LIBCPP_LITTLE_ENDIAN 453# else // _BYTE_ORDER == _LITTLE_ENDIAN 454# define _LIBCPP_BIG_ENDIAN 455# endif // _BYTE_ORDER == _LITTLE_ENDIAN 456# endif // __FreeBSD__ 457 458# if defined(__NetBSD__) || defined(__OpenBSD__) 459# include <sys/endian.h> 460# if _BYTE_ORDER == _LITTLE_ENDIAN 461# define _LIBCPP_LITTLE_ENDIAN 462# else // _BYTE_ORDER == _LITTLE_ENDIAN 463# define _LIBCPP_BIG_ENDIAN 464# endif // _BYTE_ORDER == _LITTLE_ENDIAN 465# endif // defined(__NetBSD__) || defined(__OpenBSD__) 466 467# if defined(_WIN32) 468# define _LIBCPP_WIN32API 469# define _LIBCPP_LITTLE_ENDIAN 470# define _LIBCPP_SHORT_WCHAR 1 471// Both MinGW and native MSVC provide a "MSVC"-like environment 472# define _LIBCPP_MSVCRT_LIKE 473// If mingw not explicitly detected, assume using MS C runtime only if 474// a MS compatibility version is specified. 475# if defined(_MSC_VER) && !defined(__MINGW32__) 476# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 477# endif 478# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 479# define _LIBCPP_HAS_BITSCAN64 480# endif 481# define _LIBCPP_HAS_OPEN_WITH_WCHAR 482# endif // defined(_WIN32) 483 484# if defined(_AIX) && !defined(__64BIT__) 485// The size of wchar is 2 byte on 32-bit mode on AIX. 486# define _LIBCPP_SHORT_WCHAR 1 487# endif 488 489// Libc++ supports various implementations of std::random_device. 490// 491// _LIBCPP_USING_DEV_RANDOM 492// Read entropy from the given file, by default `/dev/urandom`. 493// If a token is provided, it is assumed to be the path to a file 494// to read entropy from. This is the default behavior if nothing 495// else is specified. This implementation requires storing state 496// inside `std::random_device`. 497// 498// _LIBCPP_USING_ARC4_RANDOM 499// Use arc4random(). This allows obtaining random data even when 500// using sandboxing mechanisms. On some platforms like Apple, this 501// is the recommended source of entropy for user-space programs. 502// When this option is used, the token passed to `std::random_device`'s 503// constructor *must* be "/dev/urandom" -- anything else is an error. 504// 505// _LIBCPP_USING_GETENTROPY 506// Use getentropy(). 507// When this option is used, the token passed to `std::random_device`'s 508// constructor *must* be "/dev/urandom" -- anything else is an error. 509// 510// _LIBCPP_USING_FUCHSIA_CPRNG 511// Use Fuchsia's zx_cprng_draw() system call, which is specified to 512// deliver high-quality entropy and cannot fail. 513// When this option is used, the token passed to `std::random_device`'s 514// constructor *must* be "/dev/urandom" -- anything else is an error. 515// 516// _LIBCPP_USING_NACL_RANDOM 517// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 518// including accesses to the special files under `/dev`. This implementation 519// uses the NaCL syscall `nacl_secure_random_init()` to get entropy. 520// When this option is used, the token passed to `std::random_device`'s 521// constructor *must* be "/dev/urandom" -- anything else is an error. 522// 523// _LIBCPP_USING_WIN32_RANDOM 524// Use rand_s(), for use on Windows. 525// When this option is used, the token passed to `std::random_device`'s 526// constructor *must* be "/dev/urandom" -- anything else is an error. 527# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ 528 defined(__DragonFly__) 529# define _LIBCPP_USING_ARC4_RANDOM 530# elif defined(__wasi__) || defined(__EMSCRIPTEN__) 531# define _LIBCPP_USING_GETENTROPY 532# elif defined(__Fuchsia__) 533# define _LIBCPP_USING_FUCHSIA_CPRNG 534# elif defined(__native_client__) 535# define _LIBCPP_USING_NACL_RANDOM 536# elif defined(_LIBCPP_WIN32API) 537# define _LIBCPP_USING_WIN32_RANDOM 538# else 539# define _LIBCPP_USING_DEV_RANDOM 540# endif 541 542# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 543# include <endian.h> 544# if __BYTE_ORDER == __LITTLE_ENDIAN 545# define _LIBCPP_LITTLE_ENDIAN 546# elif __BYTE_ORDER == __BIG_ENDIAN 547# define _LIBCPP_BIG_ENDIAN 548# else // __BYTE_ORDER == __BIG_ENDIAN 549# error unable to determine endian 550# endif 551# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 552 553# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 554# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 555# else 556# define _LIBCPP_NO_CFI 557# endif 558 559# ifndef _LIBCPP_CXX03_LANG 560 561# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 562# define _ALIGNAS_TYPE(x) alignas(x) 563# define _ALIGNAS(x) alignas(x) 564# define _LIBCPP_NORETURN [[noreturn]] 565# define _NOEXCEPT noexcept 566# define _NOEXCEPT_(x) noexcept(x) 567# define _LIBCPP_CONSTEXPR constexpr 568 569# else 570 571# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 572# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 573# define _ALIGNAS(x) __attribute__((__aligned__(x))) 574# define _LIBCPP_NORETURN __attribute__((__noreturn__)) 575# define _LIBCPP_HAS_NO_NOEXCEPT 576# define nullptr __nullptr 577# define _NOEXCEPT throw() 578# define _NOEXCEPT_(x) 579# define static_assert(...) _Static_assert(__VA_ARGS__) 580# define decltype(...) __decltype(__VA_ARGS__) 581# define _LIBCPP_CONSTEXPR 582 583typedef __char16_t char16_t; 584typedef __char32_t char32_t; 585 586# endif 587 588# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L 589# define _LIBCPP_HAS_NO_EXCEPTIONS 590# endif 591 592# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 593 594# if defined(_LIBCPP_COMPILER_CLANG_BASED) 595 596# if defined(__APPLE__) 597# if defined(__i386__) || defined(__x86_64__) 598// use old string layout on x86_64 and i386 599# elif defined(__arm__) 600// use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs 601# if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2 602# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 603# endif 604# else 605# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 606# endif 607# endif 608 609// Objective-C++ features (opt-in) 610# if __has_feature(objc_arc) 611# define _LIBCPP_HAS_OBJC_ARC 612# endif 613 614# if __has_feature(objc_arc_weak) 615# define _LIBCPP_HAS_OBJC_ARC_WEAK 616# endif 617 618# if __has_extension(blocks) 619# define _LIBCPP_HAS_EXTENSION_BLOCKS 620# endif 621 622# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 623# define _LIBCPP_HAS_BLOCKS_RUNTIME 624# endif 625 626# if !__has_feature(address_sanitizer) 627# define _LIBCPP_HAS_NO_ASAN 628# endif 629 630// Allow for build-time disabling of unsigned integer sanitization 631# if __has_attribute(no_sanitize) 632# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 633# endif 634 635# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 636 637# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 638 639# elif defined(_LIBCPP_COMPILER_GCC) 640 641# if !defined(__SANITIZE_ADDRESS__) 642# define _LIBCPP_HAS_NO_ASAN 643# endif 644 645# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 646 647# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 648 649# endif // _LIBCPP_COMPILER_[CLANG|GCC] 650 651# if defined(_LIBCPP_OBJECT_FORMAT_COFF) 652 653# ifdef _DLL 654# define _LIBCPP_CRT_FUNC __declspec(dllimport) 655# else 656# define _LIBCPP_CRT_FUNC 657# endif 658 659# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) 660# define _LIBCPP_DLL_VIS 661# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 662# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 663# define _LIBCPP_OVERRIDABLE_FUNC_VIS 664# define _LIBCPP_EXPORTED_FROM_ABI 665# elif defined(_LIBCPP_BUILDING_LIBRARY) 666# define _LIBCPP_DLL_VIS __declspec(dllexport) 667# if defined(__MINGW32__) 668# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 669# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 670# else 671# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 672# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 673# endif 674# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 675# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 676# else 677# define _LIBCPP_DLL_VIS __declspec(dllimport) 678# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 679# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 680# define _LIBCPP_OVERRIDABLE_FUNC_VIS 681# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 682# endif 683 684# define _LIBCPP_HIDDEN 685# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 686# define _LIBCPP_TEMPLATE_VIS 687# define _LIBCPP_TEMPLATE_DATA_VIS 688# define _LIBCPP_ENUM_VIS 689 690# else 691 692# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 693# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) 694# else 695# define _LIBCPP_VISIBILITY(vis) 696# endif 697 698# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") 699# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") 700# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") 701# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default") 702# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 703 704// TODO: Make this a proper customization point or remove the option to override it. 705# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 706# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") 707# endif 708 709# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 710// The inline should be removed once PR32114 is resolved 711# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 712# else 713# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 714# endif 715 716# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 717# if __has_attribute(__type_visibility__) 718# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) 719# else 720# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) 721# endif 722# else 723# define _LIBCPP_TEMPLATE_VIS 724# endif 725 726# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 727# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) 728# else 729# define _LIBCPP_ENUM_VIS 730# endif 731 732# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 733 734# if __has_attribute(exclude_from_explicit_instantiation) 735# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) 736# else 737// Try to approximate the effect of exclude_from_explicit_instantiation 738// (which is that entities are not assumed to be provided by explicit 739// template instantiations in the dylib) by always inlining those entities. 740# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 741# endif 742 743// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved 744// on two levels: 745// 1. The symbol is given hidden visibility, which ensures that users won't start exporting 746// symbols from their dynamic library by means of using the libc++ headers. This ensures 747// that those symbols stay private to the dynamic library in which it is defined. 748// 749// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures 750// that no ODR violation can arise from mixing two TUs compiled with different versions 751// of libc++ where we would have changed the definition of a symbol. If the symbols shared 752// the same name, the ODR would require that their definitions be token-by-token equivalent, 753// which basically prevents us from being able to make any change to any function in our 754// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at 755// each release, which lets us change the definition of these symbols at our leisure. 756// Note that historically, this has been achieved in various ways, including force-inlining 757// all functions or giving internal linkage to all functions. Both these (previous) solutions 758// suffer from drawbacks that lead notably to code bloat. 759// 760// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend 761// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library. 762// 763// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions 764// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled 765// name of a virtual function is part of its ABI, since some architectures like arm64e can sign 766// the virtual function pointer in the vtable based on the mangled name of the function. Since 767// we use an ABI tag that changes with each released version, the mangled name of the virtual 768// function would change, which is incorrect. Note that it doesn't make much sense to change 769// the implementation of a virtual function in an ABI-incompatible way in the first place, 770// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable. 771// 772// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing 773// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and 774// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. 775# ifndef _LIBCPP_NO_ABI_TAG 776# define _LIBCPP_HIDE_FROM_ABI \ 777 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ 778 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) 779# else 780# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 781# endif 782# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 783 784// This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern 785// "C" function, as those lack mangling. 786# define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 787 788# ifdef _LIBCPP_BUILDING_LIBRARY 789# if _LIBCPP_ABI_VERSION > 1 790# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 791# else 792# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 793# endif 794# else 795# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 796# endif 797 798// Just so we can migrate to the new macros gradually. 799# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 800 801// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 802// clang-format off 803# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 804# define _LIBCPP_END_NAMESPACE_STD }} 805# define _VSTD std 806 807_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 808 809# if _LIBCPP_STD_VER >= 17 810# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 811 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 812# else 813# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 814 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 815# endif 816 817# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} 818// clang-format on 819 820# define _VSTD_FS std::__fs::filesystem 821 822# if __has_attribute(__enable_if__) 823# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) 824# endif 825 826# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER) 827# define _LIBCPP_HAS_NO_INT128 828# endif 829 830# if __has_attribute(__malloc__) 831# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 832# else 833# define _LIBCPP_NOALIAS 834# endif 835 836# if __has_attribute(__using_if_exists__) 837# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__)) 838# else 839# define _LIBCPP_USING_IF_EXISTS 840# endif 841 842# ifdef _LIBCPP_CXX03_LANG 843# define _LIBCPP_DECLARE_STRONG_ENUM(x) \ 844 struct _LIBCPP_EXPORTED_FROM_ABI x { \ 845 enum __lx 846// clang-format off 847# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 848 __lx __v_; \ 849 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 850 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 851 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ 852 }; 853// clang-format on 854 855# else // _LIBCPP_CXX03_LANG 856# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 857# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 858# endif // _LIBCPP_CXX03_LANG 859 860# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__) 861# define _LIBCPP_LOCALE__L_EXTENSIONS 1 862# endif 863 864# ifdef __FreeBSD__ 865# define _DECLARE_C99_LDBL_MATH 1 866# endif 867 868// If we are getting operator new from the MSVC CRT, then allocation overloads 869// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 870# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 871# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 872# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 873// We're deferring to Microsoft's STL to provide aligned new et al. We don't 874// have it unless the language feature test macro is defined. 875# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 876# elif defined(__MVS__) 877# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 878# endif 879 880# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) 881# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 882# endif 883 884// It is not yet possible to use aligned_alloc() on all Apple platforms since 885// 10.15 was the first version to ship an implementation of aligned_alloc(). 886# if defined(__APPLE__) 887# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ 888 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) 889# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC 890# endif 891# elif defined(__ANDROID__) && __ANDROID_API__ < 28 892// Android only provides aligned_alloc when targeting API 28 or higher. 893# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC 894# endif 895 896# if defined(__APPLE__) || defined(__FreeBSD__) 897# define _LIBCPP_HAS_DEFAULTRUNELOCALE 898# endif 899 900# if defined(__APPLE__) || defined(__FreeBSD__) 901# define _LIBCPP_WCTYPE_IS_MASK 902# endif 903 904# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 905# define _LIBCPP_HAS_NO_CHAR8_T 906# endif 907 908// Deprecation macros. 909// 910// Deprecations warnings are always enabled, except when users explicitly opt-out 911// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 912# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 913# if __has_attribute(__deprecated__) 914# define _LIBCPP_DEPRECATED __attribute__((__deprecated__)) 915# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m))) 916# elif _LIBCPP_STD_VER >= 14 917# define _LIBCPP_DEPRECATED [[deprecated]] 918# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]] 919# else 920# define _LIBCPP_DEPRECATED 921# define _LIBCPP_DEPRECATED_(m) 922# endif 923# else 924# define _LIBCPP_DEPRECATED 925# define _LIBCPP_DEPRECATED_(m) 926# endif 927 928# if !defined(_LIBCPP_CXX03_LANG) 929# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 930# else 931# define _LIBCPP_DEPRECATED_IN_CXX11 932# endif 933 934# if _LIBCPP_STD_VER >= 14 935# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 936# else 937# define _LIBCPP_DEPRECATED_IN_CXX14 938# endif 939 940# if _LIBCPP_STD_VER >= 17 941# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 942# else 943# define _LIBCPP_DEPRECATED_IN_CXX17 944# endif 945 946# if _LIBCPP_STD_VER >= 20 947# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 948# else 949# define _LIBCPP_DEPRECATED_IN_CXX20 950# endif 951 952# if _LIBCPP_STD_VER >= 23 953# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED 954# else 955# define _LIBCPP_DEPRECATED_IN_CXX23 956# endif 957 958# if !defined(_LIBCPP_HAS_NO_CHAR8_T) 959# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 960# else 961# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 962# endif 963 964// Macros to enter and leave a state where deprecation warnings are suppressed. 965# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) 966# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 967 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ 968 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 969# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") 970# else 971# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 972# define _LIBCPP_SUPPRESS_DEPRECATED_POP 973# endif 974 975# if _LIBCPP_STD_VER <= 11 976# define _LIBCPP_EXPLICIT_SINCE_CXX14 977# else 978# define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit 979# endif 980 981# if _LIBCPP_STD_VER >= 23 982# define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit 983# else 984# define _LIBCPP_EXPLICIT_SINCE_CXX23 985# endif 986 987# if _LIBCPP_STD_VER >= 14 988# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr 989# else 990# define _LIBCPP_CONSTEXPR_SINCE_CXX14 991# endif 992 993# if _LIBCPP_STD_VER >= 17 994# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr 995# else 996# define _LIBCPP_CONSTEXPR_SINCE_CXX17 997# endif 998 999# if _LIBCPP_STD_VER >= 20 1000# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr 1001# else 1002# define _LIBCPP_CONSTEXPR_SINCE_CXX20 1003# endif 1004 1005# if _LIBCPP_STD_VER >= 23 1006# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr 1007# else 1008# define _LIBCPP_CONSTEXPR_SINCE_CXX23 1009# endif 1010 1011# if __has_cpp_attribute(nodiscard) 1012# define _LIBCPP_NODISCARD [[__nodiscard__]] 1013# else 1014// We can't use GCC's [[gnu::warn_unused_result]] and 1015// __attribute__((warn_unused_result)), because GCC does not silence them via 1016// (void) cast. 1017# define _LIBCPP_NODISCARD 1018# endif 1019 1020// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 1021// specified as such as an extension. 1022# if !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 1023# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD 1024# else 1025# define _LIBCPP_NODISCARD_EXT 1026# endif 1027 1028# if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 1029# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD 1030# else 1031# define _LIBCPP_NODISCARD_AFTER_CXX17 1032# endif 1033 1034# if __has_attribute(__no_destroy__) 1035# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 1036# else 1037# define _LIBCPP_NO_DESTROY 1038# endif 1039 1040# ifndef _LIBCPP_HAS_NO_ASAN 1041 extern "C" _LIBCPP_EXPORTED_FROM_ABI void 1042 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); 1043# if _LIBCPP_CLANG_VER >= 1600 1044extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container( 1045 const void*, const void*, const void*, const void*, const void*, const void*); 1046extern "C" _LIBCPP_EXPORTED_FROM_ABI int 1047__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); 1048# endif 1049# endif 1050 1051// Try to find out if RTTI is disabled. 1052# if !defined(__cpp_rtti) || __cpp_rtti < 199711L 1053# define _LIBCPP_HAS_NO_RTTI 1054# endif 1055 1056# ifndef _LIBCPP_WEAK 1057# define _LIBCPP_WEAK __attribute__((__weak__)) 1058# endif 1059 1060// Thread API 1061// clang-format off 1062# if !defined(_LIBCPP_HAS_NO_THREADS) && \ 1063 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 1064 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 1065 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 1066 1067# if defined(__FreeBSD__) || \ 1068 defined(__wasi__) || \ 1069 defined(__NetBSD__) || \ 1070 defined(__OpenBSD__) || \ 1071 defined(__NuttX__) || \ 1072 defined(__linux__) || \ 1073 defined(__GNU__) || \ 1074 defined(__APPLE__) || \ 1075 defined(__MVS__) || \ 1076 defined(_AIX) || \ 1077 defined(__EMSCRIPTEN__) 1078// clang-format on 1079# define _LIBCPP_HAS_THREAD_API_PTHREAD 1080# elif defined(__Fuchsia__) 1081// TODO(44575): Switch to C11 thread API when possible. 1082# define _LIBCPP_HAS_THREAD_API_PTHREAD 1083# elif defined(_LIBCPP_WIN32API) 1084# define _LIBCPP_HAS_THREAD_API_WIN32 1085# else 1086# error "No thread API" 1087# endif // _LIBCPP_HAS_THREAD_API 1088# endif // _LIBCPP_HAS_NO_THREADS 1089 1090# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 1091# if defined(__ANDROID__) && __ANDROID_API__ >= 30 1092# define _LIBCPP_HAS_COND_CLOCKWAIT 1093# elif defined(_LIBCPP_GLIBC_PREREQ) 1094# if _LIBCPP_GLIBC_PREREQ(2, 30) 1095# define _LIBCPP_HAS_COND_CLOCKWAIT 1096# endif 1097# endif 1098# endif 1099 1100# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 1101# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 1102 _LIBCPP_HAS_NO_THREADS is not defined. 1103# endif 1104 1105# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 1106# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 1107 _LIBCPP_HAS_NO_THREADS is defined. 1108# endif 1109 1110# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 1111# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 1112 _LIBCPP_HAS_NO_THREADS is defined. 1113# endif 1114 1115# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 1116# define __STDCPP_THREADS__ 1 1117# endif 1118 1119// The glibc and Bionic implementation of pthreads implements 1120// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 1121// mutexes have no destroy mechanism. 1122// 1123// This optimization can't be performed on Apple platforms, where 1124// pthread_mutex_destroy can allow the kernel to release resources. 1125// See https://llvm.org/D64298 for details. 1126// 1127// TODO(EricWF): Enable this optimization on Bionic after speaking to their 1128// respective stakeholders. 1129// clang-format off 1130# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ 1131 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 1132 defined(_LIBCPP_HAS_THREAD_API_WIN32) 1133// clang-format on 1134# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1135# endif 1136 1137// Destroying a condvar is a nop on Windows. 1138// 1139// This optimization can't be performed on Apple platforms, where 1140// pthread_cond_destroy can allow the kernel to release resources. 1141// See https://llvm.org/D64298 for details. 1142// 1143// TODO(EricWF): This is potentially true for some pthread implementations 1144// as well. 1145# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) 1146# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1147# endif 1148 1149// Some systems do not provide gets() in their C library, for security reasons. 1150# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) 1151# define _LIBCPP_C_HAS_NO_GETS 1152# endif 1153 1154# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ 1155 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) 1156# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1157# endif 1158 1159# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 1160# define _LIBCPP_HAS_C_ATOMIC_IMP 1161# elif defined(_LIBCPP_COMPILER_GCC) 1162# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1163# endif 1164 1165# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 1166 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) 1167# define _LIBCPP_HAS_NO_ATOMIC_HEADER 1168# else 1169# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 1170# define _LIBCPP_ATOMIC_FLAG_TYPE bool 1171# endif 1172# ifdef _LIBCPP_FREESTANDING 1173# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 1174# endif 1175# endif 1176 1177# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1178# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1179# endif 1180 1181# if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__) 1182# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__)) 1183# else 1184# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 1185# endif 1186 1187# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 1188# if defined(__clang__) && __has_attribute(acquire_capability) 1189// Work around the attribute handling in clang. When both __declspec and 1190// __attribute__ are present, the processing goes awry preventing the definition 1191// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus 1192// combining the two does work. 1193# if !defined(_MSC_VER) 1194# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1195# endif 1196# endif 1197# endif 1198 1199# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1200# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1201# else 1202# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1203# endif 1204 1205# if _LIBCPP_STD_VER >= 20 1206# define _LIBCPP_CONSTINIT constinit 1207# elif __has_attribute(__require_constant_initialization__) 1208# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) 1209# else 1210# define _LIBCPP_CONSTINIT 1211# endif 1212 1213# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1214# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning"))) 1215# else 1216# define _LIBCPP_DIAGNOSE_WARNING(...) 1217# endif 1218 1219// Use a function like macro to imply that it must be followed by a semicolon 1220# if __has_cpp_attribute(fallthrough) 1221# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1222# elif __has_attribute(__fallthrough__) 1223# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 1224# else 1225# define _LIBCPP_FALLTHROUGH() ((void)0) 1226# endif 1227 1228# if __has_cpp_attribute(_Clang::__lifetimebound__) 1229# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] 1230# else 1231# define _LIBCPP_LIFETIMEBOUND 1232# endif 1233 1234# if __has_attribute(__nodebug__) 1235# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 1236# else 1237# define _LIBCPP_NODEBUG 1238# endif 1239 1240# if __has_attribute(__standalone_debug__) 1241# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) 1242# else 1243# define _LIBCPP_STANDALONE_DEBUG 1244# endif 1245 1246# if __has_attribute(__preferred_name__) 1247# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 1248# else 1249# define _LIBCPP_PREFERRED_NAME(x) 1250# endif 1251 1252# if __has_attribute(__no_sanitize__) 1253# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__))) 1254# else 1255# define _LIBCPP_NO_SANITIZE(...) 1256# endif 1257 1258// We often repeat things just for handling wide characters in the library. 1259// When wide characters are disabled, it can be useful to have a quick way of 1260// disabling it without having to resort to #if-#endif, which has a larger 1261// impact on readability. 1262# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) 1263# define _LIBCPP_IF_WIDE_CHARACTERS(...) 1264# else 1265# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ 1266# endif 1267 1268# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases) 1269# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 1270# else 1271# define _LIBCPP_DECLSPEC_EMPTY_BASES 1272# endif 1273 1274# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 1275# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 1276# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1277# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1278# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1279# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 1280# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 1281 1282# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) 1283# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS 1284# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION 1285# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS 1286# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS 1287# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR 1288# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS 1289# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES 1290 1291// clang-format off 1292# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh()\")") _Pragma("push_macro(\"move(int, int)\")") _Pragma("push_macro(\"erase()\")") 1293# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh()\")") _Pragma("pop_macro(\"move(int, int)\")") _Pragma("pop_macro(\"erase()\")") 1294// clang-format on 1295 1296# ifndef _LIBCPP_NO_AUTO_LINK 1297# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1298# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 1299# pragma comment(lib, "c++.lib") 1300# else 1301# pragma comment(lib, "libc++.lib") 1302# endif 1303# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1304# endif // _LIBCPP_NO_AUTO_LINK 1305 1306// Configures the fopen close-on-exec mode character, if any. This string will 1307// be appended to any mode string used by fstream for fopen/fdopen. 1308// 1309// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1310// do. 1311# if defined(__BIONIC__) 1312# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1313# else 1314# define _LIBCPP_FOPEN_CLOEXEC_MODE 1315# endif 1316 1317// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1318// of functions used in cstdio may not be available for low API levels when 1319// using 64-bit file offsets on LP32. 1320# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1321# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1322# endif 1323 1324# if __has_attribute(__init_priority__) 1325# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100))) 1326# else 1327# define _LIBCPP_INIT_PRIORITY_MAX 1328# endif 1329 1330# if __has_attribute(__format__) 1331// The attribute uses 1-based indices for ordinary and static member functions. 1332// The attribute uses 2-based indices for non-static member functions. 1333# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ 1334 __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) 1335# else 1336# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ 1337# endif 1338 1339# if __has_cpp_attribute(msvc::no_unique_address) 1340// MSVC implements [[no_unique_address]] as a silent no-op currently. 1341// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) 1342// However, MSVC implements [[msvc::no_unique_address]] which does what 1343// [[no_unique_address]] is supposed to do, in general. 1344 1345// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or 1346// [[msvc::no_unique_address]] though. If/when it does implement 1347// [[msvc::no_unique_address]], this should be preferred though. 1348# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] 1349# elif __has_cpp_attribute(no_unique_address) 1350# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]] 1351# else 1352# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ 1353// Note that this can be replaced by #error as soon as clang-cl 1354// implements msvc::no_unique_address, since there should be no C++20 1355// compiler that doesn't support one of the two attributes at that point. 1356// We generally don't want to use this macro outside of C++20-only code, 1357// because using it conditionally in one language version only would make 1358// the ABI inconsistent. 1359# endif 1360 1361# ifdef _LIBCPP_COMPILER_CLANG_BASED 1362# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1363# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1364# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) 1365# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1366# elif defined(_LIBCPP_COMPILER_GCC) 1367# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1368# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1369# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1370# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) 1371# else 1372# define _LIBCPP_DIAGNOSTIC_PUSH 1373# define _LIBCPP_DIAGNOSTIC_POP 1374# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1375# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1376# endif 1377 1378# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) 1379# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") 1380# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") 1381# else 1382# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ 1383# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ 1384# endif 1385 1386# if __has_attribute(__packed__) 1387# define _LIBCPP_PACKED __attribute__((__packed__)) 1388# else 1389# define _LIBCPP_PACKED 1390# endif 1391 1392// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these 1393// functions is gradually being added to existing C libraries. The conditions 1394// below check for known C library versions and conditions under which these 1395// functions are declared by the C library. 1396# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 1397// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if 1398// __cpp_char8_t is defined or if C2X extensions are enabled. Determining 1399// the latter depends on internal GNU libc details that are not appropriate 1400// to depend on here, so any declarations present when __cpp_char8_t is not 1401// defined are ignored. 1402# if defined(_LIBCPP_GLIBC_PREREQ) 1403# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) 1404# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 1405# endif 1406# endif 1407 1408// There are a handful of public standard library types that are intended to 1409// support CTAD but don't need any explicit deduction guides to do so. This 1410// macro is used to mark them as such, which suppresses the 1411// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code 1412// with these classes. 1413# if _LIBCPP_STD_VER >= 17 1414# ifdef _LIBCPP_COMPILER_CLANG_BASED 1415# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \ 1416 template <class... _Tag> \ 1417 [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...> 1418# else 1419# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \ 1420 template <class... _Tag> \ 1421 ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...> 1422# endif 1423# else 1424# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") 1425# endif 1426 1427// TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use 1428// compiler intrinsics in the Objective-C++ mode. 1429# ifdef __OBJC__ 1430# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS 1431# endif 1432 1433# define _PSTL_PRAGMA(x) _Pragma(#x) 1434 1435// Enable SIMD for compilers that support OpenMP 4.0 1436# if (defined(_OPENMP) && _OPENMP >= 201307) 1437 1438# define _PSTL_UDR_PRESENT 1439# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd) 1440# define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd) 1441# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM)) 1442# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM)) 1443# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM)) 1444# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM)) 1445 1446// Declaration of reduction functor, where 1447// NAME - the name of the functor 1448// OP - type of the callable object with the reduction operation 1449// omp_in - refers to the local partial result 1450// omp_out - refers to the final value of the combiner operator 1451// omp_priv - refers to the private copy of the initial value 1452// omp_orig - refers to the original variable to be reduced 1453# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \ 1454 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig)) 1455 1456# else // (defined(_OPENMP) && _OPENMP >= 201307) 1457 1458# define _PSTL_PRAGMA_SIMD 1459# define _PSTL_PRAGMA_DECLARE_SIMD 1460# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) 1461# define _PSTL_PRAGMA_SIMD_SCAN(PRM) 1462# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) 1463# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) 1464# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) 1465 1466# endif // (defined(_OPENMP) && _OPENMP >= 201307) 1467 1468# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED 1469 1470#endif // __cplusplus 1471 1472#endif // _LIBCPP___CONFIG 1473