146035553Spatrick// -*- C++ -*- 2*dc37c87aSrobert//===----------------------------------------------------------------------===// 346035553Spatrick// 446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 546035553Spatrick// See https://llvm.org/LICENSE.txt for license information. 646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 746035553Spatrick// 846035553Spatrick//===----------------------------------------------------------------------===// 946035553Spatrick 10*dc37c87aSrobert#ifndef _LIBCPP___CONFIG 11*dc37c87aSrobert#define _LIBCPP___CONFIG 1246035553Spatrick 13a0747c9fSpatrick#include <__config_site> 14a0747c9fSpatrick 1546035553Spatrick#if defined(_MSC_VER) && !defined(__clang__) 1646035553Spatrick# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1746035553Spatrick# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 1846035553Spatrick# endif 1946035553Spatrick#endif 2046035553Spatrick 2146035553Spatrick#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 2246035553Spatrick# pragma GCC system_header 2346035553Spatrick#endif 2446035553Spatrick 25*dc37c87aSrobert#if defined(__apple_build_version__) 26*dc37c87aSrobert// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403) 27*dc37c87aSrobert# define _LIBCPP_COMPILER_CLANG_BASED 28*dc37c87aSrobert# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) 29*dc37c87aSrobert#elif defined(__clang__) 30*dc37c87aSrobert# define _LIBCPP_COMPILER_CLANG_BASED 31*dc37c87aSrobert# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 32*dc37c87aSrobert#elif defined(__GNUC__) 33*dc37c87aSrobert# define _LIBCPP_COMPILER_GCC 34*dc37c87aSrobert#endif 35*dc37c87aSrobert 3646035553Spatrick#ifdef __cplusplus 3746035553Spatrick 38*dc37c87aSrobert// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. 39*dc37c87aSrobert// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 16.0.1 == 16.00.01), _LIBCPP_VERSION is 40*dc37c87aSrobert// defined to XXYYZZ. 41*dc37c87aSrobert# define _LIBCPP_VERSION 160006 4246035553Spatrick 43*dc37c87aSrobert# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y 44*dc37c87aSrobert# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) 4546035553Spatrick 46*dc37c87aSrobert// Valid C++ identifier that revs with every libc++ version. This can be used to 47*dc37c87aSrobert// generate identifiers that must be unique for every released libc++ version. 48*dc37c87aSrobert# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION) 4946035553Spatrick 50a0747c9fSpatrick# if __STDC_HOSTED__ == 0 5146035553Spatrick# define _LIBCPP_FREESTANDING 5246035553Spatrick# endif 5346035553Spatrick 5446035553Spatrick# ifndef _LIBCPP_STD_VER 5546035553Spatrick# if __cplusplus <= 201103L 5646035553Spatrick# define _LIBCPP_STD_VER 11 5746035553Spatrick# elif __cplusplus <= 201402L 5846035553Spatrick# define _LIBCPP_STD_VER 14 5946035553Spatrick# elif __cplusplus <= 201703L 6046035553Spatrick# define _LIBCPP_STD_VER 17 61a0747c9fSpatrick# elif __cplusplus <= 202002L 62a0747c9fSpatrick# define _LIBCPP_STD_VER 20 6346035553Spatrick# else 64*dc37c87aSrobert// Expected release year of the next C++ standard 65*dc37c87aSrobert# define _LIBCPP_STD_VER 23 6646035553Spatrick# endif 6746035553Spatrick# endif // _LIBCPP_STD_VER 6846035553Spatrick 6946035553Spatrick# if defined(__ELF__) 7046035553Spatrick# define _LIBCPP_OBJECT_FORMAT_ELF 1 7146035553Spatrick# elif defined(__MACH__) 7246035553Spatrick# define _LIBCPP_OBJECT_FORMAT_MACHO 1 7346035553Spatrick# elif defined(_WIN32) 7446035553Spatrick# define _LIBCPP_OBJECT_FORMAT_COFF 1 7546035553Spatrick# elif defined(__wasm__) 7646035553Spatrick# define _LIBCPP_OBJECT_FORMAT_WASM 1 77*dc37c87aSrobert# elif defined(_AIX) 78*dc37c87aSrobert# define _LIBCPP_OBJECT_FORMAT_XCOFF 1 7946035553Spatrick# else 80a0747c9fSpatrick// ... add new file formats here ... 8146035553Spatrick# endif 8246035553Spatrick 83*dc37c87aSrobert# if _LIBCPP_ABI_VERSION >= 2 8446035553Spatrick// Change short string representation so that string data starts at offset 0, 8546035553Spatrick// improving its alignment in some cases. 8646035553Spatrick# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 8746035553Spatrick// Fix deque iterator type in order to support incomplete types. 8846035553Spatrick# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 8946035553Spatrick// Fix undefined behavior in how std::list stores its linked nodes. 9046035553Spatrick# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 9146035553Spatrick// Fix undefined behavior in how __tree stores its end and parent nodes. 9246035553Spatrick# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 9346035553Spatrick// Fix undefined behavior in how __hash_table stores its pointer types. 9446035553Spatrick# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 9546035553Spatrick# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 9646035553Spatrick# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 9746035553Spatrick// Define a key function for `bad_function_call` in the library, to centralize 9846035553Spatrick// its vtable and typeinfo to libc++ rather than having all other libraries 9946035553Spatrick// using that class define their own copies. 10046035553Spatrick# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 101*dc37c87aSrobert// Override the default return value of exception::what() for 102*dc37c87aSrobert// bad_function_call::what() with a string that is specific to 103*dc37c87aSrobert// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break 104*dc37c87aSrobert// because it changes the vtable layout of bad_function_call. 105*dc37c87aSrobert# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 10646035553Spatrick// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 10746035553Spatrick# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 108a0747c9fSpatrick// Give reverse_iterator<T> one data member of type T, not two. 109a0747c9fSpatrick// Also, in C++17 and later, don't derive iterator types from std::iterator. 110a0747c9fSpatrick# define _LIBCPP_ABI_NO_ITERATOR_BASES 11146035553Spatrick// Use the smallest possible integer type to represent the index of the variant. 11246035553Spatrick// Previously libc++ used "unsigned int" exclusively. 11346035553Spatrick# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 11446035553Spatrick// Unstable attempt to provide a more optimized std::function 11546035553Spatrick# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 11646035553Spatrick// All the regex constants must be distinct and nonzero. 11746035553Spatrick# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 118601cdc12Spatrick// Re-worked external template instantiations for std::string with a focus on 119601cdc12Spatrick// performance and fast-path inlining. 120601cdc12Spatrick# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 121a0747c9fSpatrick// Enable clang::trivial_abi on std::unique_ptr. 122a0747c9fSpatrick# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 123a0747c9fSpatrick// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 124a0747c9fSpatrick# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 125*dc37c87aSrobert// std::random_device holds some state when it uses an implementation that gets 126*dc37c87aSrobert// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 127*dc37c87aSrobert// implementation to another one on a platform that has already shipped 128*dc37c87aSrobert// std::random_device, one needs to retain the same object layout to remain ABI 129*dc37c87aSrobert// compatible. This switch removes these workarounds for platforms that don't care 130*dc37c87aSrobert// about ABI compatibility. 131*dc37c87aSrobert# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 132*dc37c87aSrobert// Don't export the legacy __basic_string_common class and its methods from the built library. 133*dc37c87aSrobert# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 134*dc37c87aSrobert// Don't export the legacy __vector_base_common class and its methods from the built library. 135*dc37c87aSrobert# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 136*dc37c87aSrobert// According to the Standard, `bitset::operator[] const` returns bool 137*dc37c87aSrobert# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 138*dc37c87aSrobert// Fix the implementation of CityHash used for std::hash<fundamental-type>. 139*dc37c87aSrobert// This is an ABI break because `std::hash` will return a different result, 140*dc37c87aSrobert// which means that hashing the same object in translation units built against 141*dc37c87aSrobert// different versions of libc++ can return inconsistent results. This is especially 142*dc37c87aSrobert// tricky since std::hash is used in the implementation of unordered containers. 143*dc37c87aSrobert// 144*dc37c87aSrobert// The incorrect implementation of CityHash has the problem that it drops some 145*dc37c87aSrobert// bits on the floor. 146*dc37c87aSrobert# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION 147*dc37c87aSrobert// Remove the base 10 implementation of std::to_chars from the dylib. 148*dc37c87aSrobert// The implementation moved to the header, but we still export the symbols from 149*dc37c87aSrobert// the dylib for backwards compatibility. 150*dc37c87aSrobert# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 15146035553Spatrick# elif _LIBCPP_ABI_VERSION == 1 152*dc37c87aSrobert# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 15346035553Spatrick// Enable compiling copies of now inline methods into the dylib to support 15446035553Spatrick// applications compiled against older libraries. This is unnecessary with 15546035553Spatrick// COFF dllexport semantics, since dllexport forces a non-inline definition 15646035553Spatrick// of inline functions to be emitted anyway. Our own non-inline copy would 157*dc37c87aSrobert// conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 158*dc37c87aSrobert// the linker will take issue with the symbols in the shared object if the 159*dc37c87aSrobert// weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 160*dc37c87aSrobert// so disable it. 16146035553Spatrick# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 16246035553Spatrick# endif 16346035553Spatrick// Feature macros for disabling pre ABI v1 features. All of these options 16446035553Spatrick// are deprecated. 16546035553Spatrick# if defined(__FreeBSD__) 16646035553Spatrick# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 16746035553Spatrick# endif 16846035553Spatrick# endif 16946035553Spatrick 170*dc37c87aSrobert# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 171a0747c9fSpatrick// Enable additional explicit instantiations of iostreams components. This 172a0747c9fSpatrick// reduces the number of weak definitions generated in programs that use 173a0747c9fSpatrick// iostreams by providing a single strong definition in the shared library. 174a0747c9fSpatrick# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 175*dc37c87aSrobert 176*dc37c87aSrobert// Define a key function for `bad_function_call` in the library, to centralize 177*dc37c87aSrobert// its vtable and typeinfo to libc++ rather than having all other libraries 178*dc37c87aSrobert// using that class define their own copies. 179*dc37c87aSrobert# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 18046035553Spatrick# endif 18146035553Spatrick 182*dc37c87aSrobert# define _LIBCPP_TOSTRING2(x) #x 183*dc37c87aSrobert# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 18446035553Spatrick 18546035553Spatrick# if __cplusplus < 201103L 18646035553Spatrick# define _LIBCPP_CXX03_LANG 18746035553Spatrick# endif 18846035553Spatrick 18946035553Spatrick# ifndef __has_attribute 19046035553Spatrick# define __has_attribute(__x) 0 19146035553Spatrick# endif 19246035553Spatrick 19346035553Spatrick# ifndef __has_builtin 19446035553Spatrick# define __has_builtin(__x) 0 19546035553Spatrick# endif 19646035553Spatrick 19746035553Spatrick# ifndef __has_extension 19846035553Spatrick# define __has_extension(__x) 0 19946035553Spatrick# endif 20046035553Spatrick 20146035553Spatrick# ifndef __has_feature 20246035553Spatrick# define __has_feature(__x) 0 20346035553Spatrick# endif 20446035553Spatrick 20546035553Spatrick# ifndef __has_cpp_attribute 20646035553Spatrick# define __has_cpp_attribute(__x) 0 20746035553Spatrick# endif 20846035553Spatrick 209*dc37c87aSrobert# ifndef __has_constexpr_builtin 210*dc37c87aSrobert# define __has_constexpr_builtin(x) 0 211*dc37c87aSrobert# endif 212*dc37c87aSrobert 21346035553Spatrick// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 21446035553Spatrick// the compiler and '1' otherwise. 21546035553Spatrick# ifndef __is_identifier 21646035553Spatrick# define __is_identifier(__x) 1 21746035553Spatrick# endif 21846035553Spatrick 21946035553Spatrick# ifndef __has_declspec_attribute 22046035553Spatrick# define __has_declspec_attribute(__x) 0 22146035553Spatrick# endif 22246035553Spatrick 22346035553Spatrick# define __has_keyword(__x) !(__is_identifier(__x)) 22446035553Spatrick 22546035553Spatrick# ifndef __has_include 22646035553Spatrick# define __has_include(...) 0 22746035553Spatrick# endif 22846035553Spatrick 229*dc37c87aSrobert# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L 230*dc37c87aSrobert# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" 23146035553Spatrick# endif 23246035553Spatrick 23346035553Spatrick// FIXME: ABI detection should be done via compiler builtin macros. This 23446035553Spatrick// is just a placeholder until Clang implements such macros. For now assume 23546035553Spatrick// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 23646035553Spatrick// and allow the user to explicitly specify the ABI to handle cases where this 23746035553Spatrick// heuristic falls short. 23846035553Spatrick# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 23946035553Spatrick# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 24046035553Spatrick# elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 24146035553Spatrick# define _LIBCPP_ABI_ITANIUM 24246035553Spatrick# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 24346035553Spatrick# define _LIBCPP_ABI_MICROSOFT 24446035553Spatrick# else 24546035553Spatrick# if defined(_WIN32) && defined(_MSC_VER) 24646035553Spatrick# define _LIBCPP_ABI_MICROSOFT 24746035553Spatrick# else 24846035553Spatrick# define _LIBCPP_ABI_ITANIUM 24946035553Spatrick# endif 25046035553Spatrick# endif 25146035553Spatrick 25246035553Spatrick# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 25346035553Spatrick# define _LIBCPP_ABI_VCRUNTIME 25446035553Spatrick# endif 25546035553Spatrick 256*dc37c87aSrobert# if __has_feature(experimental_library) 257*dc37c87aSrobert# ifndef _LIBCPP_ENABLE_EXPERIMENTAL 258*dc37c87aSrobert# define _LIBCPP_ENABLE_EXPERIMENTAL 259*dc37c87aSrobert# endif 260*dc37c87aSrobert# endif 261*dc37c87aSrobert 262*dc37c87aSrobert// Incomplete features get their own specific disabling flags. This makes it 263*dc37c87aSrobert// easier to grep for target specific flags once the feature is complete. 264*dc37c87aSrobert# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) 265*dc37c87aSrobert# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT 266*dc37c87aSrobert# endif 267*dc37c87aSrobert 26846035553Spatrick// Need to detect which libc we're using if we're on Linux. 26946035553Spatrick# if defined(__linux__) 27046035553Spatrick# include <features.h> 27146035553Spatrick# if defined(__GLIBC_PREREQ) 27246035553Spatrick# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 27346035553Spatrick# else 27446035553Spatrick# define _LIBCPP_GLIBC_PREREQ(a, b) 0 27546035553Spatrick# endif // defined(__GLIBC_PREREQ) 27646035553Spatrick# endif // defined(__linux__) 27746035553Spatrick 278*dc37c87aSrobert# if defined(__MVS__) 279*dc37c87aSrobert# include <features.h> // for __NATIVE_ASCII_F 280*dc37c87aSrobert# endif 281*dc37c87aSrobert 28246035553Spatrick# ifdef __LITTLE_ENDIAN__ 28346035553Spatrick# if __LITTLE_ENDIAN__ 28446035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 28546035553Spatrick# endif // __LITTLE_ENDIAN__ 28646035553Spatrick# endif // __LITTLE_ENDIAN__ 28746035553Spatrick 28846035553Spatrick# ifdef __BIG_ENDIAN__ 28946035553Spatrick# if __BIG_ENDIAN__ 29046035553Spatrick# define _LIBCPP_BIG_ENDIAN 29146035553Spatrick# endif // __BIG_ENDIAN__ 29246035553Spatrick# endif // __BIG_ENDIAN__ 29346035553Spatrick 29446035553Spatrick# ifdef __BYTE_ORDER__ 29546035553Spatrick# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 29646035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 29746035553Spatrick# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 29846035553Spatrick# define _LIBCPP_BIG_ENDIAN 29946035553Spatrick# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 30046035553Spatrick# endif // __BYTE_ORDER__ 30146035553Spatrick 30246035553Spatrick# ifdef __FreeBSD__ 30346035553Spatrick# include <sys/endian.h> 30446035553Spatrick# include <osreldate.h> 30546035553Spatrick# if _BYTE_ORDER == _LITTLE_ENDIAN 30646035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 30746035553Spatrick# else // _BYTE_ORDER == _LITTLE_ENDIAN 30846035553Spatrick# define _LIBCPP_BIG_ENDIAN 30946035553Spatrick# endif // _BYTE_ORDER == _LITTLE_ENDIAN 31046035553Spatrick# endif // __FreeBSD__ 31146035553Spatrick 312a0747c9fSpatrick# if defined(__NetBSD__) || defined(__OpenBSD__) 31346035553Spatrick# include <sys/endian.h> 31446035553Spatrick# if _BYTE_ORDER == _LITTLE_ENDIAN 31546035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 31646035553Spatrick# else // _BYTE_ORDER == _LITTLE_ENDIAN 31746035553Spatrick# define _LIBCPP_BIG_ENDIAN 31846035553Spatrick# endif // _BYTE_ORDER == _LITTLE_ENDIAN 319a0747c9fSpatrick# endif // defined(__NetBSD__) || defined(__OpenBSD__) 320b0c4c902Spatrick 32146035553Spatrick# if defined(_WIN32) 32246035553Spatrick# define _LIBCPP_WIN32API 32346035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 32446035553Spatrick# define _LIBCPP_SHORT_WCHAR 1 32546035553Spatrick// Both MinGW and native MSVC provide a "MSVC"-like environment 32646035553Spatrick# define _LIBCPP_MSVCRT_LIKE 32746035553Spatrick// If mingw not explicitly detected, assume using MS C runtime only if 32846035553Spatrick// a MS compatibility version is specified. 32946035553Spatrick# if defined(_MSC_VER) && !defined(__MINGW32__) 33046035553Spatrick# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 33146035553Spatrick# endif 33246035553Spatrick# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 33346035553Spatrick# define _LIBCPP_HAS_BITSCAN64 33446035553Spatrick# endif 33546035553Spatrick# define _LIBCPP_HAS_OPEN_WITH_WCHAR 33646035553Spatrick# endif // defined(_WIN32) 33746035553Spatrick 33846035553Spatrick# ifdef __sun__ 33946035553Spatrick# include <sys/isa_defs.h> 34046035553Spatrick# ifdef _LITTLE_ENDIAN 34146035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 34246035553Spatrick# else 34346035553Spatrick# define _LIBCPP_BIG_ENDIAN 34446035553Spatrick# endif 34546035553Spatrick# endif // __sun__ 34646035553Spatrick 347*dc37c87aSrobert# if defined(_AIX) && !defined(__64BIT__) 348*dc37c87aSrobert// The size of wchar is 2 byte on 32-bit mode on AIX. 349*dc37c87aSrobert# define _LIBCPP_SHORT_WCHAR 1 350*dc37c87aSrobert# endif 351*dc37c87aSrobert 352*dc37c87aSrobert// Libc++ supports various implementations of std::random_device. 353*dc37c87aSrobert// 354*dc37c87aSrobert// _LIBCPP_USING_DEV_RANDOM 355*dc37c87aSrobert// Read entropy from the given file, by default `/dev/urandom`. 356*dc37c87aSrobert// If a token is provided, it is assumed to be the path to a file 357*dc37c87aSrobert// to read entropy from. This is the default behavior if nothing 358*dc37c87aSrobert// else is specified. This implementation requires storing state 359*dc37c87aSrobert// inside `std::random_device`. 360*dc37c87aSrobert// 361*dc37c87aSrobert// _LIBCPP_USING_ARC4_RANDOM 362*dc37c87aSrobert// Use arc4random(). This allows obtaining random data even when 363*dc37c87aSrobert// using sandboxing mechanisms. On some platforms like Apple, this 364*dc37c87aSrobert// is the recommended source of entropy for user-space programs. 365*dc37c87aSrobert// When this option is used, the token passed to `std::random_device`'s 366*dc37c87aSrobert// constructor *must* be "/dev/urandom" -- anything else is an error. 367*dc37c87aSrobert// 368*dc37c87aSrobert// _LIBCPP_USING_GETENTROPY 369*dc37c87aSrobert// Use getentropy(). 370*dc37c87aSrobert// When this option is used, the token passed to `std::random_device`'s 371*dc37c87aSrobert// constructor *must* be "/dev/urandom" -- anything else is an error. 372*dc37c87aSrobert// 373*dc37c87aSrobert// _LIBCPP_USING_FUCHSIA_CPRNG 374*dc37c87aSrobert// Use Fuchsia's zx_cprng_draw() system call, which is specified to 375*dc37c87aSrobert// deliver high-quality entropy and cannot fail. 376*dc37c87aSrobert// When this option is used, the token passed to `std::random_device`'s 377*dc37c87aSrobert// constructor *must* be "/dev/urandom" -- anything else is an error. 378*dc37c87aSrobert// 379*dc37c87aSrobert// _LIBCPP_USING_NACL_RANDOM 38046035553Spatrick// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 381*dc37c87aSrobert// including accesses to the special files under `/dev`. This implementation 382*dc37c87aSrobert// uses the NaCL syscall `nacl_secure_random_init()` to get entropy. 383*dc37c87aSrobert// When this option is used, the token passed to `std::random_device`'s 384*dc37c87aSrobert// constructor *must* be "/dev/urandom" -- anything else is an error. 385*dc37c87aSrobert// 386*dc37c87aSrobert// _LIBCPP_USING_WIN32_RANDOM 387*dc37c87aSrobert// Use rand_s(), for use on Windows. 388*dc37c87aSrobert// When this option is used, the token passed to `std::random_device`'s 389*dc37c87aSrobert// constructor *must* be "/dev/urandom" -- anything else is an error. 390*dc37c87aSrobert# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ 391*dc37c87aSrobert defined(__DragonFly__) || defined(__sun__) 392*dc37c87aSrobert# define _LIBCPP_USING_ARC4_RANDOM 393*dc37c87aSrobert# elif defined(__wasi__) || defined(__EMSCRIPTEN__) 394*dc37c87aSrobert# define _LIBCPP_USING_GETENTROPY 395*dc37c87aSrobert# elif defined(__Fuchsia__) 396*dc37c87aSrobert# define _LIBCPP_USING_FUCHSIA_CPRNG 397*dc37c87aSrobert# elif defined(__native_client__) 39846035553Spatrick# define _LIBCPP_USING_NACL_RANDOM 39946035553Spatrick# elif defined(_LIBCPP_WIN32API) 40046035553Spatrick# define _LIBCPP_USING_WIN32_RANDOM 40146035553Spatrick# else 40246035553Spatrick# define _LIBCPP_USING_DEV_RANDOM 40346035553Spatrick# endif 40446035553Spatrick 40546035553Spatrick# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 40646035553Spatrick# include <endian.h> 40746035553Spatrick# if __BYTE_ORDER == __LITTLE_ENDIAN 40846035553Spatrick# define _LIBCPP_LITTLE_ENDIAN 40946035553Spatrick# elif __BYTE_ORDER == __BIG_ENDIAN 41046035553Spatrick# define _LIBCPP_BIG_ENDIAN 41146035553Spatrick# else // __BYTE_ORDER == __BIG_ENDIAN 41246035553Spatrick# error unable to determine endian 41346035553Spatrick# endif 41446035553Spatrick# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 41546035553Spatrick 41646035553Spatrick# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 41746035553Spatrick# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 41846035553Spatrick# else 41946035553Spatrick# define _LIBCPP_NO_CFI 42046035553Spatrick# endif 42146035553Spatrick 42246035553Spatrick# ifndef _LIBCPP_CXX03_LANG 423*dc37c87aSrobert 42446035553Spatrick# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 425*dc37c87aSrobert# define _ALIGNAS_TYPE(x) alignas(x) 426*dc37c87aSrobert# define _ALIGNAS(x) alignas(x) 427*dc37c87aSrobert# define _LIBCPP_NORETURN [[noreturn]] 428*dc37c87aSrobert# define _NOEXCEPT noexcept 429*dc37c87aSrobert# define _NOEXCEPT_(x) noexcept(x) 430*dc37c87aSrobert# define _LIBCPP_CONSTEXPR constexpr 431*dc37c87aSrobert 43246035553Spatrick# else 433*dc37c87aSrobert 434*dc37c87aSrobert# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 435*dc37c87aSrobert# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 436*dc37c87aSrobert# define _ALIGNAS(x) __attribute__((__aligned__(x))) 437*dc37c87aSrobert# define _LIBCPP_NORETURN __attribute__((__noreturn__)) 438*dc37c87aSrobert# define _LIBCPP_HAS_NO_NOEXCEPT 439*dc37c87aSrobert# define nullptr __nullptr 440*dc37c87aSrobert# define _NOEXCEPT throw() 441*dc37c87aSrobert# define _NOEXCEPT_(x) 442*dc37c87aSrobert# define static_assert(...) _Static_assert(__VA_ARGS__) 443*dc37c87aSrobert# define decltype(...) __decltype(__VA_ARGS__) 444*dc37c87aSrobert# define _LIBCPP_CONSTEXPR 445*dc37c87aSrobert 446*dc37c87aSroberttypedef __char16_t char16_t; 447*dc37c87aSroberttypedef __char32_t char32_t; 448*dc37c87aSrobert 449*dc37c87aSrobert# endif 450*dc37c87aSrobert 451*dc37c87aSrobert# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L 452*dc37c87aSrobert# define _LIBCPP_NO_EXCEPTIONS 45346035553Spatrick# endif 45446035553Spatrick 45546035553Spatrick# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 45646035553Spatrick 457a0747c9fSpatrick# if defined(_LIBCPP_COMPILER_CLANG_BASED) 45846035553Spatrick 459*dc37c87aSrobert# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 46046035553Spatrick# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 46146035553Spatrick# endif 46246035553Spatrick 46346035553Spatrick// Objective-C++ features (opt-in) 46446035553Spatrick# if __has_feature(objc_arc) 46546035553Spatrick# define _LIBCPP_HAS_OBJC_ARC 46646035553Spatrick# endif 46746035553Spatrick 46846035553Spatrick# if __has_feature(objc_arc_weak) 46946035553Spatrick# define _LIBCPP_HAS_OBJC_ARC_WEAK 47046035553Spatrick# endif 47146035553Spatrick 472601cdc12Spatrick# if __has_extension(blocks) 473601cdc12Spatrick# define _LIBCPP_HAS_EXTENSION_BLOCKS 474601cdc12Spatrick# endif 475601cdc12Spatrick 476601cdc12Spatrick# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 477601cdc12Spatrick# define _LIBCPP_HAS_BLOCKS_RUNTIME 478601cdc12Spatrick# endif 479601cdc12Spatrick 480a0747c9fSpatrick# if !__has_feature(address_sanitizer) 48146035553Spatrick# define _LIBCPP_HAS_NO_ASAN 48246035553Spatrick# endif 48346035553Spatrick 48446035553Spatrick// Allow for build-time disabling of unsigned integer sanitization 485a0747c9fSpatrick# if __has_attribute(no_sanitize) 48646035553Spatrick# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 48746035553Spatrick# endif 48846035553Spatrick 48946035553Spatrick# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 49046035553Spatrick 49146035553Spatrick# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 49246035553Spatrick 49346035553Spatrick# elif defined(_LIBCPP_COMPILER_GCC) 49446035553Spatrick 495a0747c9fSpatrick# if !defined(__SANITIZE_ADDRESS__) 49646035553Spatrick# define _LIBCPP_HAS_NO_ASAN 49746035553Spatrick# endif 49846035553Spatrick 49946035553Spatrick# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 50046035553Spatrick 50146035553Spatrick# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 50246035553Spatrick 503*dc37c87aSrobert# endif // _LIBCPP_COMPILER_[CLANG|GCC] 50446035553Spatrick 50546035553Spatrick# if defined(_LIBCPP_OBJECT_FORMAT_COFF) 50646035553Spatrick 50746035553Spatrick# ifdef _DLL 50846035553Spatrick# define _LIBCPP_CRT_FUNC __declspec(dllimport) 50946035553Spatrick# else 51046035553Spatrick# define _LIBCPP_CRT_FUNC 51146035553Spatrick# endif 51246035553Spatrick 513*dc37c87aSrobert# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) 51446035553Spatrick# define _LIBCPP_DLL_VIS 51546035553Spatrick# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 51646035553Spatrick# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 51746035553Spatrick# define _LIBCPP_OVERRIDABLE_FUNC_VIS 51846035553Spatrick# define _LIBCPP_EXPORTED_FROM_ABI 51946035553Spatrick# elif defined(_LIBCPP_BUILDING_LIBRARY) 52046035553Spatrick# define _LIBCPP_DLL_VIS __declspec(dllexport) 52146035553Spatrick# if defined(__MINGW32__) 52246035553Spatrick# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 52346035553Spatrick# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 52446035553Spatrick# else 52546035553Spatrick# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 52646035553Spatrick# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 52746035553Spatrick# endif 52846035553Spatrick# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 52946035553Spatrick# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 53046035553Spatrick# else 53146035553Spatrick# define _LIBCPP_DLL_VIS __declspec(dllimport) 53246035553Spatrick# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 53346035553Spatrick# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 53446035553Spatrick# define _LIBCPP_OVERRIDABLE_FUNC_VIS 53546035553Spatrick# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 53646035553Spatrick# endif 53746035553Spatrick 53846035553Spatrick# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 53946035553Spatrick# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 54046035553Spatrick# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 54146035553Spatrick# define _LIBCPP_HIDDEN 54246035553Spatrick# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 54346035553Spatrick# define _LIBCPP_TEMPLATE_VIS 544a0747c9fSpatrick# define _LIBCPP_TEMPLATE_DATA_VIS 54546035553Spatrick# define _LIBCPP_ENUM_VIS 54646035553Spatrick 54746035553Spatrick# else 548*dc37c87aSrobert 549*dc37c87aSrobert# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 550*dc37c87aSrobert# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) 551*dc37c87aSrobert# else 552*dc37c87aSrobert# define _LIBCPP_VISIBILITY(vis) 55346035553Spatrick# endif 55446035553Spatrick 555*dc37c87aSrobert# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") 556*dc37c87aSrobert# define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default") 557*dc37c87aSrobert# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") 558*dc37c87aSrobert# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") 559*dc37c87aSrobert# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") 560*dc37c87aSrobert# define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default") 561*dc37c87aSrobert# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default") 562*dc37c87aSrobert# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 563*dc37c87aSrobert 564*dc37c87aSrobert// TODO: Make this a proper customization point or remove the option to override it. 565*dc37c87aSrobert# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 566*dc37c87aSrobert# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") 567*dc37c87aSrobert# endif 568*dc37c87aSrobert 56946035553Spatrick# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 57046035553Spatrick// The inline should be removed once PR32114 is resolved 57146035553Spatrick# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 57246035553Spatrick# else 57346035553Spatrick# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 57446035553Spatrick# endif 57546035553Spatrick 57646035553Spatrick# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 57746035553Spatrick# if __has_attribute(__type_visibility__) 57846035553Spatrick# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) 57946035553Spatrick# else 58046035553Spatrick# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) 58146035553Spatrick# endif 58246035553Spatrick# else 58346035553Spatrick# define _LIBCPP_TEMPLATE_VIS 58446035553Spatrick# endif 58546035553Spatrick 58646035553Spatrick# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 58746035553Spatrick# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) 58846035553Spatrick# else 58946035553Spatrick# define _LIBCPP_ENUM_VIS 59046035553Spatrick# endif 59146035553Spatrick 592*dc37c87aSrobert# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 59346035553Spatrick 59446035553Spatrick# if __has_attribute(exclude_from_explicit_instantiation) 59546035553Spatrick# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) 59646035553Spatrick# else 59746035553Spatrick// Try to approximate the effect of exclude_from_explicit_instantiation 59846035553Spatrick// (which is that entities are not assumed to be provided by explicit 59946035553Spatrick// template instantiations in the dylib) by always inlining those entities. 60046035553Spatrick# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 60146035553Spatrick# endif 60246035553Spatrick 603*dc37c87aSrobert// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved 604*dc37c87aSrobert// on two levels: 605*dc37c87aSrobert// 1. The symbol is given hidden visibility, which ensures that users won't start exporting 606*dc37c87aSrobert// symbols from their dynamic library by means of using the libc++ headers. This ensures 607*dc37c87aSrobert// that those symbols stay private to the dynamic library in which it is defined. 608*dc37c87aSrobert// 609*dc37c87aSrobert// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures 610*dc37c87aSrobert// that no ODR violation can arise from mixing two TUs compiled with different versions 611*dc37c87aSrobert// of libc++ where we would have changed the definition of a symbol. If the symbols shared 612*dc37c87aSrobert// the same name, the ODR would require that their definitions be token-by-token equivalent, 613*dc37c87aSrobert// which basically prevents us from being able to make any change to any function in our 614*dc37c87aSrobert// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at 615*dc37c87aSrobert// each release, which lets us change the definition of these symbols at our leisure. 616*dc37c87aSrobert// Note that historically, this has been achieved in various ways, including force-inlining 617*dc37c87aSrobert// all functions or giving internal linkage to all functions. Both these (previous) solutions 618*dc37c87aSrobert// suffer from drawbacks that lead notably to code bloat. 619*dc37c87aSrobert// 620*dc37c87aSrobert// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend 621*dc37c87aSrobert// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library. 622*dc37c87aSrobert// 623*dc37c87aSrobert// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions 624*dc37c87aSrobert// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled 625*dc37c87aSrobert// name of a virtual function is part of its ABI, since some architectures like arm64e can sign 626*dc37c87aSrobert// the virtual function pointer in the vtable based on the mangled name of the function. Since 627*dc37c87aSrobert// we use an ABI tag that changes with each released version, the mangled name of the virtual 628*dc37c87aSrobert// function would change, which is incorrect. Note that it doesn't make much sense to change 629*dc37c87aSrobert// the implementation of a virtual function in an ABI-incompatible way in the first place, 630*dc37c87aSrobert// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable. 631*dc37c87aSrobert// 632*dc37c87aSrobert// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing 633*dc37c87aSrobert// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and 634*dc37c87aSrobert// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. 635*dc37c87aSrobert# ifndef _LIBCPP_NO_ABI_TAG 636*dc37c87aSrobert# define _LIBCPP_HIDE_FROM_ABI \ 637*dc37c87aSrobert _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ 638*dc37c87aSrobert __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) 63946035553Spatrick# else 64046035553Spatrick# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 64146035553Spatrick# endif 642*dc37c87aSrobert# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 643*dc37c87aSrobert 644*dc37c87aSrobert// This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern 645*dc37c87aSrobert// "C" function, as those lack mangling. 646*dc37c87aSrobert# define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 64746035553Spatrick 64846035553Spatrick# ifdef _LIBCPP_BUILDING_LIBRARY 64946035553Spatrick# if _LIBCPP_ABI_VERSION > 1 65046035553Spatrick# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 65146035553Spatrick# else 65246035553Spatrick# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 65346035553Spatrick# endif 65446035553Spatrick# else 65546035553Spatrick# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 65646035553Spatrick# endif 65746035553Spatrick 65846035553Spatrick// Just so we can migrate to the new macros gradually. 65946035553Spatrick# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 66046035553Spatrick 66146035553Spatrick// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 662*dc37c87aSrobert// clang-format off 66346035553Spatrick# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 66446035553Spatrick# define _LIBCPP_END_NAMESPACE_STD }} 665*dc37c87aSrobert# define _VSTD std 666*dc37c87aSrobert 66746035553Spatrick_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 66846035553Spatrick 669*dc37c87aSrobert# if _LIBCPP_STD_VER > 14 67046035553Spatrick# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 67146035553Spatrick _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 67246035553Spatrick# else 67346035553Spatrick# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 67446035553Spatrick _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 67546035553Spatrick# endif 67646035553Spatrick 677*dc37c87aSrobert# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} 678*dc37c87aSrobert// clang-format on 67946035553Spatrick 680*dc37c87aSrobert# define _VSTD_FS std::__fs::filesystem 68146035553Spatrick 68246035553Spatrick# if __has_attribute(__enable_if__) 68346035553Spatrick# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) 68446035553Spatrick# endif 68546035553Spatrick 68646035553Spatrick# ifndef __SIZEOF_INT128__ 68746035553Spatrick# define _LIBCPP_HAS_NO_INT128 68846035553Spatrick# endif 68946035553Spatrick 690a0747c9fSpatrick# ifndef __cpp_consteval 691a0747c9fSpatrick# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR 692a0747c9fSpatrick# else 693a0747c9fSpatrick# define _LIBCPP_CONSTEVAL consteval 694a0747c9fSpatrick# endif 695a0747c9fSpatrick 696*dc37c87aSrobert# if __has_attribute(__malloc__) 69746035553Spatrick# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 69846035553Spatrick# else 69946035553Spatrick# define _LIBCPP_NOALIAS 70046035553Spatrick# endif 70146035553Spatrick 702*dc37c87aSrobert# if __has_attribute(__using_if_exists__) 703*dc37c87aSrobert# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__)) 70446035553Spatrick# else 705a0747c9fSpatrick# define _LIBCPP_USING_IF_EXISTS 70646035553Spatrick# endif 70746035553Spatrick 708*dc37c87aSrobert# ifdef _LIBCPP_CXX03_LANG 709*dc37c87aSrobert# define _LIBCPP_DECLARE_STRONG_ENUM(x) \ 710*dc37c87aSrobert struct _LIBCPP_TYPE_VIS x { \ 711*dc37c87aSrobert enum __lx 712*dc37c87aSrobert// clang-format off 71346035553Spatrick# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 71446035553Spatrick __lx __v_; \ 71546035553Spatrick _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 71646035553Spatrick _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 71746035553Spatrick _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ 71846035553Spatrick }; 719*dc37c87aSrobert// clang-format on 720*dc37c87aSrobert 721*dc37c87aSrobert# else // _LIBCPP_CXX03_LANG 72246035553Spatrick# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 72346035553Spatrick# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 724*dc37c87aSrobert# endif // _LIBCPP_CXX03_LANG 72546035553Spatrick 726*dc37c87aSrobert# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ 727*dc37c87aSrobert defined(__NetBSD__) 72846035553Spatrick# define _LIBCPP_LOCALE__L_EXTENSIONS 1 72946035553Spatrick# endif 73046035553Spatrick 73146035553Spatrick# ifdef __FreeBSD__ 73246035553Spatrick# define _DECLARE_C99_LDBL_MATH 1 73346035553Spatrick# endif 73446035553Spatrick 73546035553Spatrick// If we are getting operator new from the MSVC CRT, then allocation overloads 73646035553Spatrick// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 73746035553Spatrick# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 73846035553Spatrick# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 73946035553Spatrick# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 74046035553Spatrick// We're deferring to Microsoft's STL to provide aligned new et al. We don't 74146035553Spatrick// have it unless the language feature test macro is defined. 74246035553Spatrick# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 743a0747c9fSpatrick# elif defined(__MVS__) 744a0747c9fSpatrick# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 74546035553Spatrick# endif 74646035553Spatrick 747*dc37c87aSrobert# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) 74846035553Spatrick# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 74946035553Spatrick# endif 75046035553Spatrick 751*dc37c87aSrobert// It is not yet possible to use aligned_alloc() on all Apple platforms since 752*dc37c87aSrobert// 10.15 was the first version to ship an implementation of aligned_alloc(). 753*dc37c87aSrobert# if defined(__APPLE__) 754*dc37c87aSrobert# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ 755*dc37c87aSrobert __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) 756*dc37c87aSrobert# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC 757*dc37c87aSrobert# endif 758*dc37c87aSrobert# elif defined(__ANDROID__) && __ANDROID_API__ < 28 759*dc37c87aSrobert// Android only provides aligned_alloc when targeting API 28 or higher. 760*dc37c87aSrobert# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC 761*dc37c87aSrobert# endif 762*dc37c87aSrobert 76346035553Spatrick# if defined(__APPLE__) || defined(__FreeBSD__) 76446035553Spatrick# define _LIBCPP_HAS_DEFAULTRUNELOCALE 76546035553Spatrick# endif 76646035553Spatrick 76746035553Spatrick# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 76846035553Spatrick# define _LIBCPP_WCTYPE_IS_MASK 76946035553Spatrick# endif 77046035553Spatrick 77146035553Spatrick# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 772a0747c9fSpatrick# define _LIBCPP_HAS_NO_CHAR8_T 77346035553Spatrick# endif 77446035553Spatrick 77546035553Spatrick// Deprecation macros. 77646035553Spatrick// 77746035553Spatrick// Deprecations warnings are always enabled, except when users explicitly opt-out 77846035553Spatrick// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 77946035553Spatrick# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 78046035553Spatrick# if __has_attribute(deprecated) 78146035553Spatrick# define _LIBCPP_DEPRECATED __attribute__((deprecated)) 782*dc37c87aSrobert# define _LIBCPP_DEPRECATED_(m) __attribute__((deprecated(m))) 78346035553Spatrick# elif _LIBCPP_STD_VER > 11 78446035553Spatrick# define _LIBCPP_DEPRECATED [[deprecated]] 785*dc37c87aSrobert# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]] 78646035553Spatrick# else 78746035553Spatrick# define _LIBCPP_DEPRECATED 788*dc37c87aSrobert# define _LIBCPP_DEPRECATED_(m) 78946035553Spatrick# endif 79046035553Spatrick# else 79146035553Spatrick# define _LIBCPP_DEPRECATED 792*dc37c87aSrobert# define _LIBCPP_DEPRECATED_(m) 79346035553Spatrick# endif 79446035553Spatrick 79546035553Spatrick# if !defined(_LIBCPP_CXX03_LANG) 79646035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 79746035553Spatrick# else 79846035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX11 79946035553Spatrick# endif 80046035553Spatrick 801*dc37c87aSrobert# if _LIBCPP_STD_VER > 11 80246035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 80346035553Spatrick# else 80446035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX14 80546035553Spatrick# endif 80646035553Spatrick 807*dc37c87aSrobert# if _LIBCPP_STD_VER > 14 80846035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 80946035553Spatrick# else 81046035553Spatrick# define _LIBCPP_DEPRECATED_IN_CXX17 81146035553Spatrick# endif 81246035553Spatrick 813a0747c9fSpatrick# if _LIBCPP_STD_VER > 17 814a0747c9fSpatrick# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 815a0747c9fSpatrick# else 816a0747c9fSpatrick# define _LIBCPP_DEPRECATED_IN_CXX20 817a0747c9fSpatrick# endif 818a0747c9fSpatrick 819*dc37c87aSrobert#if _LIBCPP_STD_VER >= 23 820*dc37c87aSrobert# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED 821*dc37c87aSrobert#else 822*dc37c87aSrobert# define _LIBCPP_DEPRECATED_IN_CXX23 823*dc37c87aSrobert#endif 824*dc37c87aSrobert 825a0747c9fSpatrick# if !defined(_LIBCPP_HAS_NO_CHAR8_T) 826a0747c9fSpatrick# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 827a0747c9fSpatrick# else 828a0747c9fSpatrick# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 829a0747c9fSpatrick# endif 830a0747c9fSpatrick 83146035553Spatrick// Macros to enter and leave a state where deprecation warnings are suppressed. 832a0747c9fSpatrick# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) 83346035553Spatrick# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 834*dc37c87aSrobert _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ 835a0747c9fSpatrick _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 836*dc37c87aSrobert# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") 837a0747c9fSpatrick# else 83846035553Spatrick# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 83946035553Spatrick# define _LIBCPP_SUPPRESS_DEPRECATED_POP 84046035553Spatrick# endif 84146035553Spatrick 84246035553Spatrick# if _LIBCPP_STD_VER <= 11 84346035553Spatrick# define _LIBCPP_EXPLICIT_AFTER_CXX11 84446035553Spatrick# else 84546035553Spatrick# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 84646035553Spatrick# endif 84746035553Spatrick 848*dc37c87aSrobert# if _LIBCPP_STD_VER > 11 849*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr 85046035553Spatrick# else 851*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX14 85246035553Spatrick# endif 85346035553Spatrick 854*dc37c87aSrobert# if _LIBCPP_STD_VER > 14 855*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr 85646035553Spatrick# else 857*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX17 85846035553Spatrick# endif 85946035553Spatrick 860*dc37c87aSrobert# if _LIBCPP_STD_VER > 17 861*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr 86246035553Spatrick# else 863*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX20 86446035553Spatrick# endif 86546035553Spatrick 866*dc37c87aSrobert# if _LIBCPP_STD_VER > 20 867*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr 868*dc37c87aSrobert# else 869*dc37c87aSrobert# define _LIBCPP_CONSTEXPR_SINCE_CXX23 870*dc37c87aSrobert# endif 871*dc37c87aSrobert 872*dc37c87aSrobert# if __has_cpp_attribute(nodiscard) 873*dc37c87aSrobert# define _LIBCPP_NODISCARD [[nodiscard]] 87446035553Spatrick# else 87546035553Spatrick// We can't use GCC's [[gnu::warn_unused_result]] and 87646035553Spatrick// __attribute__((warn_unused_result)), because GCC does not silence them via 87746035553Spatrick// (void) cast. 878*dc37c87aSrobert# define _LIBCPP_NODISCARD 87946035553Spatrick# endif 88046035553Spatrick 88146035553Spatrick// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 88246035553Spatrick// specified as such as an extension. 883*dc37c87aSrobert# if !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 884*dc37c87aSrobert# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD 88546035553Spatrick# else 88646035553Spatrick# define _LIBCPP_NODISCARD_EXT 88746035553Spatrick# endif 88846035553Spatrick 889*dc37c87aSrobert# if _LIBCPP_STD_VER > 17 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 890*dc37c87aSrobert# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD 89146035553Spatrick# else 89246035553Spatrick# define _LIBCPP_NODISCARD_AFTER_CXX17 89346035553Spatrick# endif 89446035553Spatrick 895*dc37c87aSrobert# if __has_attribute(__no_destroy__) 89646035553Spatrick# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 89746035553Spatrick# else 89846035553Spatrick# define _LIBCPP_NO_DESTROY 89946035553Spatrick# endif 90046035553Spatrick 90146035553Spatrick# ifndef _LIBCPP_HAS_NO_ASAN 902*dc37c87aSrobert extern "C" _LIBCPP_FUNC_VIS void 903*dc37c87aSrobert __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); 90446035553Spatrick# endif 90546035553Spatrick 90646035553Spatrick// Try to find out if RTTI is disabled. 907*dc37c87aSrobert# if !defined(__cpp_rtti) || __cpp_rtti < 199711L 908*dc37c87aSrobert# define _LIBCPP_HAS_NO_RTTI 90946035553Spatrick# endif 91046035553Spatrick 91146035553Spatrick# ifndef _LIBCPP_WEAK 91246035553Spatrick# define _LIBCPP_WEAK __attribute__((__weak__)) 91346035553Spatrick# endif 91446035553Spatrick 91546035553Spatrick// Thread API 916*dc37c87aSrobert// clang-format off 91746035553Spatrick# if !defined(_LIBCPP_HAS_NO_THREADS) && \ 91846035553Spatrick !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 91946035553Spatrick !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 92046035553Spatrick !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 921*dc37c87aSrobert 92246035553Spatrick# if defined(__FreeBSD__) || \ 92346035553Spatrick defined(__wasi__) || \ 92446035553Spatrick defined(__NetBSD__) || \ 925a0747c9fSpatrick defined(__OpenBSD__) || \ 926a0747c9fSpatrick defined(__NuttX__) || \ 92746035553Spatrick defined(__linux__) || \ 92846035553Spatrick defined(__GNU__) || \ 92946035553Spatrick defined(__APPLE__) || \ 93046035553Spatrick defined(__sun__) || \ 931a0747c9fSpatrick defined(__MVS__) || \ 932a0747c9fSpatrick defined(_AIX) || \ 933*dc37c87aSrobert defined(__EMSCRIPTEN__) 934*dc37c87aSrobert// clang-format on 93546035553Spatrick# define _LIBCPP_HAS_THREAD_API_PTHREAD 93646035553Spatrick# elif defined(__Fuchsia__) 937601cdc12Spatrick// TODO(44575): Switch to C11 thread API when possible. 938601cdc12Spatrick# define _LIBCPP_HAS_THREAD_API_PTHREAD 93946035553Spatrick# elif defined(_LIBCPP_WIN32API) 94046035553Spatrick# define _LIBCPP_HAS_THREAD_API_WIN32 94146035553Spatrick# else 94246035553Spatrick# error "No thread API" 94346035553Spatrick# endif // _LIBCPP_HAS_THREAD_API 94446035553Spatrick# endif // _LIBCPP_HAS_NO_THREADS 94546035553Spatrick 94646035553Spatrick# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 94746035553Spatrick# if defined(__ANDROID__) && __ANDROID_API__ >= 30 94846035553Spatrick# define _LIBCPP_HAS_COND_CLOCKWAIT 94946035553Spatrick# elif defined(_LIBCPP_GLIBC_PREREQ) 95046035553Spatrick# if _LIBCPP_GLIBC_PREREQ(2, 30) 95146035553Spatrick# define _LIBCPP_HAS_COND_CLOCKWAIT 95246035553Spatrick# endif 95346035553Spatrick# endif 95446035553Spatrick# endif 95546035553Spatrick 95646035553Spatrick# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 95746035553Spatrick# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 95846035553Spatrick _LIBCPP_HAS_NO_THREADS is not defined. 95946035553Spatrick# endif 96046035553Spatrick 96146035553Spatrick# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 96246035553Spatrick# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 96346035553Spatrick _LIBCPP_HAS_NO_THREADS is defined. 96446035553Spatrick# endif 96546035553Spatrick 96646035553Spatrick# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 96746035553Spatrick# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 96846035553Spatrick _LIBCPP_HAS_NO_THREADS is defined. 96946035553Spatrick# endif 97046035553Spatrick 97146035553Spatrick# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 97246035553Spatrick# define __STDCPP_THREADS__ 1 97346035553Spatrick# endif 97446035553Spatrick 97546035553Spatrick// The glibc and Bionic implementation of pthreads implements 97646035553Spatrick// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 97746035553Spatrick// mutexes have no destroy mechanism. 97846035553Spatrick// 97946035553Spatrick// This optimization can't be performed on Apple platforms, where 98046035553Spatrick// pthread_mutex_destroy can allow the kernel to release resources. 98146035553Spatrick// See https://llvm.org/D64298 for details. 98246035553Spatrick// 98346035553Spatrick// TODO(EricWF): Enable this optimization on Bionic after speaking to their 98446035553Spatrick// respective stakeholders. 985*dc37c87aSrobert// clang-format off 986*dc37c87aSrobert# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ 987*dc37c87aSrobert (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 988*dc37c87aSrobert defined(_LIBCPP_HAS_THREAD_API_WIN32) 989*dc37c87aSrobert// clang-format on 99046035553Spatrick# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 99146035553Spatrick# endif 99246035553Spatrick 99346035553Spatrick// Destroying a condvar is a nop on Windows. 99446035553Spatrick// 99546035553Spatrick// This optimization can't be performed on Apple platforms, where 99646035553Spatrick// pthread_cond_destroy can allow the kernel to release resources. 99746035553Spatrick// See https://llvm.org/D64298 for details. 99846035553Spatrick// 99946035553Spatrick// TODO(EricWF): This is potentially true for some pthread implementations 100046035553Spatrick// as well. 1001*dc37c87aSrobert# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) 100246035553Spatrick# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 100346035553Spatrick# endif 100446035553Spatrick 100546035553Spatrick// Some systems do not provide gets() in their C library, for security reasons. 1006*dc37c87aSrobert# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) 100746035553Spatrick# define _LIBCPP_C_HAS_NO_GETS 100846035553Spatrick# endif 100946035553Spatrick 1010*dc37c87aSrobert# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ 1011*dc37c87aSrobert defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) 101246035553Spatrick# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 101346035553Spatrick# endif 101446035553Spatrick 101546035553Spatrick# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 101646035553Spatrick# define _LIBCPP_HAS_C_ATOMIC_IMP 101746035553Spatrick# elif defined(_LIBCPP_COMPILER_GCC) 101846035553Spatrick# define _LIBCPP_HAS_GCC_ATOMIC_IMP 101946035553Spatrick# endif 102046035553Spatrick 1021*dc37c87aSrobert# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 1022*dc37c87aSrobert !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) 102346035553Spatrick# define _LIBCPP_HAS_NO_ATOMIC_HEADER 102446035553Spatrick# else 102546035553Spatrick# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 102646035553Spatrick# define _LIBCPP_ATOMIC_FLAG_TYPE bool 102746035553Spatrick# endif 102846035553Spatrick# ifdef _LIBCPP_FREESTANDING 102946035553Spatrick# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 103046035553Spatrick# endif 103146035553Spatrick# endif 103246035553Spatrick 103346035553Spatrick# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 103446035553Spatrick# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 103546035553Spatrick# endif 103646035553Spatrick 103746035553Spatrick# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 103846035553Spatrick# if defined(__clang__) && __has_attribute(acquire_capability) 103946035553Spatrick// Work around the attribute handling in clang. When both __declspec and 104046035553Spatrick// __attribute__ are present, the processing goes awry preventing the definition 1041*dc37c87aSrobert// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus 1042*dc37c87aSrobert// combining the two does work. 1043*dc37c87aSrobert# if !defined(_MSC_VER) 104446035553Spatrick# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 104546035553Spatrick# endif 104646035553Spatrick# endif 104746035553Spatrick# endif 104846035553Spatrick 104946035553Spatrick# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 105046035553Spatrick# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 105146035553Spatrick# else 105246035553Spatrick# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 105346035553Spatrick# endif 105446035553Spatrick 1055*dc37c87aSrobert# if _LIBCPP_STD_VER > 17 1056*dc37c87aSrobert# define _LIBCPP_CONSTINIT constinit 1057*dc37c87aSrobert# elif __has_attribute(__require_constant_initialization__) 1058*dc37c87aSrobert# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) 105946035553Spatrick# else 1060*dc37c87aSrobert# define _LIBCPP_CONSTINIT 106146035553Spatrick# endif 106246035553Spatrick 1063*dc37c87aSrobert# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1064*dc37c87aSrobert# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning"))) 106546035553Spatrick# else 106646035553Spatrick# define _LIBCPP_DIAGNOSE_WARNING(...) 106746035553Spatrick# endif 106846035553Spatrick 106946035553Spatrick// Use a function like macro to imply that it must be followed by a semicolon 1070*dc37c87aSrobert# if __has_cpp_attribute(fallthrough) 107146035553Spatrick# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1072*dc37c87aSrobert# elif __has_attribute(__fallthrough__) 107346035553Spatrick# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 107446035553Spatrick# else 107546035553Spatrick# define _LIBCPP_FALLTHROUGH() ((void)0) 107646035553Spatrick# endif 107746035553Spatrick 1078*dc37c87aSrobert# if __has_cpp_attribute(_Clang::__lifetimebound__) 1079*dc37c87aSrobert# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] 1080*dc37c87aSrobert# else 1081*dc37c87aSrobert# define _LIBCPP_LIFETIMEBOUND 1082*dc37c87aSrobert# endif 1083*dc37c87aSrobert 108446035553Spatrick# if __has_attribute(__nodebug__) 108546035553Spatrick# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 108646035553Spatrick# else 108746035553Spatrick# define _LIBCPP_NODEBUG 108846035553Spatrick# endif 108946035553Spatrick 1090a0747c9fSpatrick# if __has_attribute(__standalone_debug__) 1091a0747c9fSpatrick# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) 1092a0747c9fSpatrick# else 1093a0747c9fSpatrick# define _LIBCPP_STANDALONE_DEBUG 1094a0747c9fSpatrick# endif 1095a0747c9fSpatrick 1096a0747c9fSpatrick# if __has_attribute(__preferred_name__) 1097a0747c9fSpatrick# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 1098a0747c9fSpatrick# else 1099a0747c9fSpatrick# define _LIBCPP_PREFERRED_NAME(x) 1100a0747c9fSpatrick# endif 110146035553Spatrick 1102*dc37c87aSrobert// We often repeat things just for handling wide characters in the library. 1103*dc37c87aSrobert// When wide characters are disabled, it can be useful to have a quick way of 1104*dc37c87aSrobert// disabling it without having to resort to #if-#endif, which has a larger 1105*dc37c87aSrobert// impact on readability. 1106*dc37c87aSrobert# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) 1107*dc37c87aSrobert# define _LIBCPP_IF_WIDE_CHARACTERS(...) 1108*dc37c87aSrobert# else 1109*dc37c87aSrobert# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ 1110*dc37c87aSrobert# endif 1111*dc37c87aSrobert 1112*dc37c87aSrobert# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases) 111346035553Spatrick# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 111446035553Spatrick# else 111546035553Spatrick# define _LIBCPP_DECLSPEC_EMPTY_BASES 111646035553Spatrick# endif 111746035553Spatrick 111846035553Spatrick# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 111946035553Spatrick# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 112046035553Spatrick# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1121a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1122a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1123*dc37c87aSrobert# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 112446035553Spatrick# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 112546035553Spatrick 1126a0747c9fSpatrick# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) 1127a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS 1128*dc37c87aSrobert# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION 1129a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS 1130a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS 1131a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR 1132a0747c9fSpatrick# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS 1133a0747c9fSpatrick# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES 1134a0747c9fSpatrick 1135*dc37c87aSrobert# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") 1136*dc37c87aSrobert# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") 113746035553Spatrick 113846035553Spatrick# ifndef _LIBCPP_NO_AUTO_LINK 113946035553Spatrick# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1140a0747c9fSpatrick# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 114146035553Spatrick# pragma comment(lib, "c++.lib") 114246035553Spatrick# else 114346035553Spatrick# pragma comment(lib, "libc++.lib") 114446035553Spatrick# endif 114546035553Spatrick# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 114646035553Spatrick# endif // _LIBCPP_NO_AUTO_LINK 114746035553Spatrick 114846035553Spatrick// Configures the fopen close-on-exec mode character, if any. This string will 114946035553Spatrick// be appended to any mode string used by fstream for fopen/fdopen. 115046035553Spatrick// 115146035553Spatrick// Not all platforms support this, but it helps avoid fd-leaks on platforms that 115246035553Spatrick// do. 115346035553Spatrick# if defined(__BIONIC__) 115446035553Spatrick# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 115546035553Spatrick# else 115646035553Spatrick# define _LIBCPP_FOPEN_CLOEXEC_MODE 115746035553Spatrick# endif 115846035553Spatrick 1159601cdc12Spatrick// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1160601cdc12Spatrick// of functions used in cstdio may not be available for low API levels when 1161601cdc12Spatrick// using 64-bit file offsets on LP32. 1162601cdc12Spatrick# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1163601cdc12Spatrick# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1164601cdc12Spatrick# endif 1165601cdc12Spatrick 1166*dc37c87aSrobert# if __has_attribute(__init_priority__) 1167*dc37c87aSrobert# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100))) 1168a0747c9fSpatrick# else 1169a0747c9fSpatrick# define _LIBCPP_INIT_PRIORITY_MAX 1170a0747c9fSpatrick# endif 1171a0747c9fSpatrick 1172*dc37c87aSrobert# if __has_attribute(__format__) 1173*dc37c87aSrobert// The attribute uses 1-based indices for ordinary and static member functions. 1174*dc37c87aSrobert// The attribute uses 2-based indices for non-static member functions. 1175*dc37c87aSrobert# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ 1176*dc37c87aSrobert __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) 1177a0747c9fSpatrick# else 1178*dc37c87aSrobert# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ 1179*dc37c87aSrobert# endif 1180*dc37c87aSrobert 1181*dc37c87aSrobert# if __has_cpp_attribute(msvc::no_unique_address) 1182*dc37c87aSrobert// MSVC implements [[no_unique_address]] as a silent no-op currently. 1183*dc37c87aSrobert// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) 1184*dc37c87aSrobert// However, MSVC implements [[msvc::no_unique_address]] which does what 1185*dc37c87aSrobert// [[no_unique_address]] is supposed to do, in general. 1186*dc37c87aSrobert 1187*dc37c87aSrobert// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or 1188*dc37c87aSrobert// [[msvc::no_unique_address]] though. If/when it does implement 1189*dc37c87aSrobert// [[msvc::no_unique_address]], this should be preferred though. 1190*dc37c87aSrobert# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] 1191*dc37c87aSrobert# elif __has_cpp_attribute(no_unique_address) 1192*dc37c87aSrobert# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] 1193*dc37c87aSrobert# else 1194*dc37c87aSrobert# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ 1195*dc37c87aSrobert// Note that this can be replaced by #error as soon as clang-cl 1196*dc37c87aSrobert// implements msvc::no_unique_address, since there should be no C++20 1197*dc37c87aSrobert// compiler that doesn't support one of the two attributes at that point. 1198*dc37c87aSrobert// We generally don't want to use this macro outside of C++20-only code, 1199*dc37c87aSrobert// because using it conditionally in one language version only would make 1200*dc37c87aSrobert// the ABI inconsistent. 1201*dc37c87aSrobert# endif 1202*dc37c87aSrobert 1203*dc37c87aSrobert# ifdef _LIBCPP_COMPILER_CLANG_BASED 1204*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1205*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1206*dc37c87aSrobert# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) 1207*dc37c87aSrobert# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1208*dc37c87aSrobert# elif defined(_LIBCPP_COMPILER_GCC) 1209*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1210*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1211*dc37c87aSrobert# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1212*dc37c87aSrobert# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) 1213*dc37c87aSrobert# else 1214*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_PUSH 1215*dc37c87aSrobert# define _LIBCPP_DIAGNOSTIC_POP 1216*dc37c87aSrobert# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1217*dc37c87aSrobert# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1218*dc37c87aSrobert# endif 1219*dc37c87aSrobert 1220*dc37c87aSrobert# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) 1221*dc37c87aSrobert# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") 1222*dc37c87aSrobert# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") 1223*dc37c87aSrobert# else 1224*dc37c87aSrobert# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ 1225*dc37c87aSrobert# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ 1226*dc37c87aSrobert# endif 1227*dc37c87aSrobert 1228*dc37c87aSrobert# if __has_attribute(__packed__) 1229*dc37c87aSrobert# define _LIBCPP_PACKED __attribute__((__packed__)) 1230*dc37c87aSrobert# else 1231*dc37c87aSrobert# define _LIBCPP_PACKED 1232*dc37c87aSrobert# endif 1233*dc37c87aSrobert 1234*dc37c87aSrobert// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these 1235*dc37c87aSrobert// functions is gradually being added to existing C libraries. The conditions 1236*dc37c87aSrobert// below check for known C library versions and conditions under which these 1237*dc37c87aSrobert// functions are declared by the C library. 1238*dc37c87aSrobert# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 1239*dc37c87aSrobert// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if 1240*dc37c87aSrobert// __cpp_char8_t is defined or if C2X extensions are enabled. Determining 1241*dc37c87aSrobert// the latter depends on internal GNU libc details that are not appropriate 1242*dc37c87aSrobert// to depend on here, so any declarations present when __cpp_char8_t is not 1243*dc37c87aSrobert// defined are ignored. 1244*dc37c87aSrobert# if defined(_LIBCPP_GLIBC_PREREQ) 1245*dc37c87aSrobert# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) 1246*dc37c87aSrobert# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 1247*dc37c87aSrobert# endif 1248*dc37c87aSrobert# endif 1249*dc37c87aSrobert 1250*dc37c87aSrobert// There are a handful of public standard library types that are intended to 1251*dc37c87aSrobert// support CTAD but don't need any explicit deduction guides to do so. This 1252*dc37c87aSrobert// macro is used to mark them as such, which suppresses the 1253*dc37c87aSrobert// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code 1254*dc37c87aSrobert// with these classes. 1255*dc37c87aSrobert#if _LIBCPP_STD_VER >= 17 1256*dc37c87aSrobert# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \ 1257*dc37c87aSrobert template <class ..._Tag> \ 1258*dc37c87aSrobert _ClassName(typename _Tag::__allow_ctad...) -> _ClassName<_Tag...> 1259*dc37c87aSrobert#else 1260*dc37c87aSrobert# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") 1261*dc37c87aSrobert#endif 1262*dc37c87aSrobert 1263*dc37c87aSrobert// TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use 1264*dc37c87aSrobert// compiler intrinsics in the Objective-C++ mode. 1265*dc37c87aSrobert# ifdef __OBJC__ 1266*dc37c87aSrobert# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS 1267a0747c9fSpatrick# endif 1268a0747c9fSpatrick 126946035553Spatrick#endif // __cplusplus 127046035553Spatrick 1271*dc37c87aSrobert#endif // _LIBCPP___CONFIG 1272