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