1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP___CONFIG 11#define _LIBCPP___CONFIG 12 13#include <__config_site> 14 15#if defined(_MSC_VER) && !defined(__clang__) 16# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 18# endif 19#endif 20 21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 22# pragma GCC system_header 23#endif 24 25#ifdef __cplusplus 26 27# define _LIBCPP_VERSION 15000 28 29# if __STDC_HOSTED__ == 0 30# define _LIBCPP_FREESTANDING 31# endif 32 33# ifndef _LIBCPP_STD_VER 34# if __cplusplus <= 201103L 35# define _LIBCPP_STD_VER 11 36# elif __cplusplus <= 201402L 37# define _LIBCPP_STD_VER 14 38# elif __cplusplus <= 201703L 39# define _LIBCPP_STD_VER 17 40# elif __cplusplus <= 202002L 41# define _LIBCPP_STD_VER 20 42# else 43# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification 44# endif 45# endif // _LIBCPP_STD_VER 46 47# if defined(__ELF__) 48# define _LIBCPP_OBJECT_FORMAT_ELF 1 49# elif defined(__MACH__) 50# define _LIBCPP_OBJECT_FORMAT_MACHO 1 51# elif defined(_WIN32) 52# define _LIBCPP_OBJECT_FORMAT_COFF 1 53# elif defined(__wasm__) 54# define _LIBCPP_OBJECT_FORMAT_WASM 1 55# elif defined(_AIX) 56# define _LIBCPP_OBJECT_FORMAT_XCOFF 1 57# else 58// ... add new file formats here ... 59# endif 60 61# if _LIBCPP_ABI_VERSION >= 2 62// Change short string representation so that string data starts at offset 0, 63// improving its alignment in some cases. 64# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 65// Fix deque iterator type in order to support incomplete types. 66# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 67// Fix undefined behavior in how std::list stores its linked nodes. 68# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 69// Fix undefined behavior in how __tree stores its end and parent nodes. 70# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 71// Fix undefined behavior in how __hash_table stores its pointer types. 72# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 73# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 74# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 75// Define a key function for `bad_function_call` in the library, to centralize 76// its vtable and typeinfo to libc++ rather than having all other libraries 77// using that class define their own copies. 78# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 79// Override the default return value of exception::what() for 80// bad_function_call::what() with a string that is specific to 81// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break 82// because it changes the vtable layout of bad_function_call. 83# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 84// Enable optimized version of __do_get_(un)signed which avoids redundant copies. 85# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 86// In C++20 and later, don't derive std::plus from std::binary_function, 87// nor std::negate from std::unary_function. 88# define _LIBCPP_ABI_NO_BINDER_BASES 89// Give reverse_iterator<T> one data member of type T, not two. 90// Also, in C++17 and later, don't derive iterator types from std::iterator. 91# define _LIBCPP_ABI_NO_ITERATOR_BASES 92// Use the smallest possible integer type to represent the index of the variant. 93// Previously libc++ used "unsigned int" exclusively. 94# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 95// Unstable attempt to provide a more optimized std::function 96# define _LIBCPP_ABI_OPTIMIZED_FUNCTION 97// All the regex constants must be distinct and nonzero. 98# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 99// Use raw pointers, not wrapped ones, for std::span's iterator type. 100# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS 101// Re-worked external template instantiations for std::string with a focus on 102// performance and fast-path inlining. 103# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 104// Enable clang::trivial_abi on std::unique_ptr. 105# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 106// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 107# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 108// std::random_device holds some state when it uses an implementation that gets 109// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 110// implementation to another one on a platform that has already shipped 111// std::random_device, one needs to retain the same object layout to remain ABI 112// compatible. This switch removes these workarounds for platforms that don't care 113// about ABI compatibility. 114# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 115// Don't export the legacy __basic_string_common class and its methods from the built library. 116# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 117// Don't export the legacy __vector_base_common class and its methods from the built library. 118# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 119// According to the Standard, `bitset::operator[] const` returns bool 120# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 121// Remove the base 10 implementation of std::to_chars from the dylib. 122// The implementation moved to the header, but we still export the symbols from 123// the dylib for backwards compatibility. 124# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 125# elif _LIBCPP_ABI_VERSION == 1 126# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 127// Enable compiling copies of now inline methods into the dylib to support 128// applications compiled against older libraries. This is unnecessary with 129// COFF dllexport semantics, since dllexport forces a non-inline definition 130// of inline functions to be emitted anyway. Our own non-inline copy would 131// conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 132// the linker will take issue with the symbols in the shared object if the 133// weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 134// so disable it. 135# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 136# endif 137// Feature macros for disabling pre ABI v1 features. All of these options 138// are deprecated. 139# if defined(__FreeBSD__) 140# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 141# endif 142# endif 143 144# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 145// Enable additional explicit instantiations of iostreams components. This 146// reduces the number of weak definitions generated in programs that use 147// iostreams by providing a single strong definition in the shared library. 148# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 149 150// Define a key function for `bad_function_call` in the library, to centralize 151// its vtable and typeinfo to libc++ rather than having all other libraries 152// using that class define their own copies. 153# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION 154# endif 155 156# define _LIBCPP_TOSTRING2(x) # x 157# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 158 159# if __cplusplus < 201103L 160# define _LIBCPP_CXX03_LANG 161# endif 162 163# ifndef __has_attribute 164# define __has_attribute(__x) 0 165# endif 166 167# ifndef __has_builtin 168# define __has_builtin(__x) 0 169# endif 170 171# ifndef __has_extension 172# define __has_extension(__x) 0 173# endif 174 175# ifndef __has_feature 176# define __has_feature(__x) 0 177# endif 178 179# ifndef __has_cpp_attribute 180# define __has_cpp_attribute(__x) 0 181# endif 182 183// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 184// the compiler and '1' otherwise. 185# ifndef __is_identifier 186# define __is_identifier(__x) 1 187# endif 188 189# ifndef __has_declspec_attribute 190# define __has_declspec_attribute(__x) 0 191# endif 192 193# define __has_keyword(__x) !(__is_identifier(__x)) 194 195# ifndef __has_include 196# define __has_include(...) 0 197# endif 198 199# if defined(__apple_build_version__) 200# define _LIBCPP_COMPILER_CLANG_BASED 201# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) 202# elif defined(__clang__) 203# define _LIBCPP_COMPILER_CLANG_BASED 204# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 205# elif defined(__GNUC__) 206# define _LIBCPP_COMPILER_GCC 207# elif defined(_MSC_VER) 208# define _LIBCPP_COMPILER_MSVC 209# endif 210 211# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L 212# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" 213# endif 214 215// FIXME: ABI detection should be done via compiler builtin macros. This 216// is just a placeholder until Clang implements such macros. For now assume 217// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 218// and allow the user to explicitly specify the ABI to handle cases where this 219// heuristic falls short. 220# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) 221# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" 222# elif defined(_LIBCPP_ABI_FORCE_ITANIUM) 223# define _LIBCPP_ABI_ITANIUM 224# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) 225# define _LIBCPP_ABI_MICROSOFT 226# else 227# if defined(_WIN32) && defined(_MSC_VER) 228# define _LIBCPP_ABI_MICROSOFT 229# else 230# define _LIBCPP_ABI_ITANIUM 231# endif 232# endif 233 234# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) 235# define _LIBCPP_ABI_VCRUNTIME 236# endif 237 238// Need to detect which libc we're using if we're on Linux. 239# if defined(__linux__) 240# include <features.h> 241# if defined(__GLIBC_PREREQ) 242# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) 243# else 244# define _LIBCPP_GLIBC_PREREQ(a, b) 0 245# endif // defined(__GLIBC_PREREQ) 246# endif // defined(__linux__) 247 248# if defined(__MVS__) 249# include <features.h> // for __NATIVE_ASCII_F 250# endif 251 252# ifdef __LITTLE_ENDIAN__ 253# if __LITTLE_ENDIAN__ 254# define _LIBCPP_LITTLE_ENDIAN 255# endif // __LITTLE_ENDIAN__ 256# endif // __LITTLE_ENDIAN__ 257 258# ifdef __BIG_ENDIAN__ 259# if __BIG_ENDIAN__ 260# define _LIBCPP_BIG_ENDIAN 261# endif // __BIG_ENDIAN__ 262# endif // __BIG_ENDIAN__ 263 264# ifdef __BYTE_ORDER__ 265# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 266# define _LIBCPP_LITTLE_ENDIAN 267# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 268# define _LIBCPP_BIG_ENDIAN 269# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 270# endif // __BYTE_ORDER__ 271 272# ifdef __FreeBSD__ 273# include <sys/endian.h> 274# include <osreldate.h> 275# if _BYTE_ORDER == _LITTLE_ENDIAN 276# define _LIBCPP_LITTLE_ENDIAN 277# else // _BYTE_ORDER == _LITTLE_ENDIAN 278# define _LIBCPP_BIG_ENDIAN 279# endif // _BYTE_ORDER == _LITTLE_ENDIAN 280# endif // __FreeBSD__ 281 282# if defined(__NetBSD__) || defined(__OpenBSD__) 283# include <sys/endian.h> 284# if _BYTE_ORDER == _LITTLE_ENDIAN 285# define _LIBCPP_LITTLE_ENDIAN 286# else // _BYTE_ORDER == _LITTLE_ENDIAN 287# define _LIBCPP_BIG_ENDIAN 288# endif // _BYTE_ORDER == _LITTLE_ENDIAN 289# endif // defined(__NetBSD__) || defined(__OpenBSD__) 290 291# if defined(_WIN32) 292# define _LIBCPP_WIN32API 293# define _LIBCPP_LITTLE_ENDIAN 294# define _LIBCPP_SHORT_WCHAR 1 295// Both MinGW and native MSVC provide a "MSVC"-like environment 296# define _LIBCPP_MSVCRT_LIKE 297// If mingw not explicitly detected, assume using MS C runtime only if 298// a MS compatibility version is specified. 299# if defined(_MSC_VER) && !defined(__MINGW32__) 300# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 301# endif 302# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 303# define _LIBCPP_HAS_BITSCAN64 304# endif 305# define _LIBCPP_HAS_OPEN_WITH_WCHAR 306# endif // defined(_WIN32) 307 308# ifdef __sun__ 309# include <sys/isa_defs.h> 310# ifdef _LITTLE_ENDIAN 311# define _LIBCPP_LITTLE_ENDIAN 312# else 313# define _LIBCPP_BIG_ENDIAN 314# endif 315# endif // __sun__ 316 317# if defined(_AIX) && !defined(__64BIT__) 318// The size of wchar is 2 byte on 32-bit mode on AIX. 319# define _LIBCPP_SHORT_WCHAR 1 320# endif 321 322// Libc++ supports various implementations of std::random_device. 323// 324// _LIBCPP_USING_DEV_RANDOM 325// Read entropy from the given file, by default `/dev/urandom`. 326// If a token is provided, it is assumed to be the path to a file 327// to read entropy from. This is the default behavior if nothing 328// else is specified. This implementation requires storing state 329// inside `std::random_device`. 330// 331// _LIBCPP_USING_ARC4_RANDOM 332// Use arc4random(). This allows obtaining random data even when 333// using sandboxing mechanisms. On some platforms like Apple, this 334// is the recommended source of entropy for user-space programs. 335// When this option is used, the token passed to `std::random_device`'s 336// constructor *must* be "/dev/urandom" -- anything else is an error. 337// 338// _LIBCPP_USING_GETENTROPY 339// Use getentropy(). 340// When this option is used, the token passed to `std::random_device`'s 341// constructor *must* be "/dev/urandom" -- anything else is an error. 342// 343// _LIBCPP_USING_FUCHSIA_CPRNG 344// Use Fuchsia's zx_cprng_draw() system call, which is specified to 345// deliver high-quality entropy and cannot fail. 346// When this option is used, the token passed to `std::random_device`'s 347// constructor *must* be "/dev/urandom" -- anything else is an error. 348// 349// _LIBCPP_USING_NACL_RANDOM 350// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 351// including accesses to the special files under `/dev`. This implementation 352// uses the NaCL syscall `nacl_secure_random_init()` to get entropy. 353// When this option is used, the token passed to `std::random_device`'s 354// constructor *must* be "/dev/urandom" -- anything else is an error. 355// 356// _LIBCPP_USING_WIN32_RANDOM 357// Use rand_s(), for use on Windows. 358// When this option is used, the token passed to `std::random_device`'s 359// constructor *must* be "/dev/urandom" -- anything else is an error. 360# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ 361 defined(__DragonFly__) || defined(__sun__) 362# define _LIBCPP_USING_ARC4_RANDOM 363# elif defined(__wasi__) || defined(__EMSCRIPTEN__) 364# define _LIBCPP_USING_GETENTROPY 365# elif defined(__Fuchsia__) 366# define _LIBCPP_USING_FUCHSIA_CPRNG 367# elif defined(__native_client__) 368# define _LIBCPP_USING_NACL_RANDOM 369# elif defined(_LIBCPP_WIN32API) 370# define _LIBCPP_USING_WIN32_RANDOM 371# else 372# define _LIBCPP_USING_DEV_RANDOM 373# endif 374 375# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 376# include <endian.h> 377# if __BYTE_ORDER == __LITTLE_ENDIAN 378# define _LIBCPP_LITTLE_ENDIAN 379# elif __BYTE_ORDER == __BIG_ENDIAN 380# define _LIBCPP_BIG_ENDIAN 381# else // __BYTE_ORDER == __BIG_ENDIAN 382# error unable to determine endian 383# endif 384# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) 385 386# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) 387# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 388# else 389# define _LIBCPP_NO_CFI 390# endif 391 392# ifndef _LIBCPP_CXX03_LANG 393 394# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 395# define _ALIGNAS_TYPE(x) alignas(x) 396# define _ALIGNAS(x) alignas(x) 397# define _LIBCPP_NORETURN [[noreturn]] 398# define _NOEXCEPT noexcept 399# define _NOEXCEPT_(x) noexcept(x) 400 401# else 402 403# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 404# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 405# define _ALIGNAS(x) __attribute__((__aligned__(x))) 406# define _LIBCPP_NORETURN __attribute__((noreturn)) 407# define _LIBCPP_HAS_NO_NOEXCEPT 408# define nullptr __nullptr 409# define _NOEXCEPT throw() 410# define _NOEXCEPT_(x) 411 412typedef __char16_t char16_t; 413typedef __char32_t char32_t; 414 415# endif 416 417# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L 418# define _LIBCPP_NO_EXCEPTIONS 419# endif 420 421# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 422 423# if defined(_LIBCPP_COMPILER_CLANG_BASED) 424 425# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 426# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 427# endif 428 429// Objective-C++ features (opt-in) 430# if __has_feature(objc_arc) 431# define _LIBCPP_HAS_OBJC_ARC 432# endif 433 434# if __has_feature(objc_arc_weak) 435# define _LIBCPP_HAS_OBJC_ARC_WEAK 436# endif 437 438# if __has_extension(blocks) 439# define _LIBCPP_HAS_EXTENSION_BLOCKS 440# endif 441 442# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 443# define _LIBCPP_HAS_BLOCKS_RUNTIME 444# endif 445 446# if !__has_feature(address_sanitizer) 447# define _LIBCPP_HAS_NO_ASAN 448# endif 449 450// Allow for build-time disabling of unsigned integer sanitization 451# if __has_attribute(no_sanitize) 452# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 453# endif 454 455# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 456 457# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 458 459# elif defined(_LIBCPP_COMPILER_GCC) 460 461# if !defined(__SANITIZE_ADDRESS__) 462# define _LIBCPP_HAS_NO_ASAN 463# endif 464 465# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 466 467# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 468 469# elif defined(_LIBCPP_COMPILER_MSVC) 470 471# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 472 473# if _MSC_VER < 1900 474# error "MSVC versions prior to Visual Studio 2015 are not supported" 475# endif 476 477# define _LIBCPP_NORETURN __declspec(noreturn) 478 479# define _LIBCPP_WEAK 480 481# define _LIBCPP_HAS_NO_ASAN 482 483# define _LIBCPP_ALWAYS_INLINE __forceinline 484 485# define _LIBCPP_HAS_NO_VECTOR_EXTENSION 486 487# define _LIBCPP_DISABLE_EXTENSION_WARNING 488 489# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC] 490 491# if defined(_LIBCPP_OBJECT_FORMAT_COFF) 492 493# ifdef _DLL 494# define _LIBCPP_CRT_FUNC __declspec(dllimport) 495# else 496# define _LIBCPP_CRT_FUNC 497# endif 498 499# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) 500# define _LIBCPP_DLL_VIS 501# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 502# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 503# define _LIBCPP_OVERRIDABLE_FUNC_VIS 504# define _LIBCPP_EXPORTED_FROM_ABI 505# elif defined(_LIBCPP_BUILDING_LIBRARY) 506# define _LIBCPP_DLL_VIS __declspec(dllexport) 507# if defined(__MINGW32__) 508# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 509# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 510# else 511# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 512# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 513# endif 514# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 515# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 516# else 517# define _LIBCPP_DLL_VIS __declspec(dllimport) 518# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 519# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 520# define _LIBCPP_OVERRIDABLE_FUNC_VIS 521# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 522# endif 523 524# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 525# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 526# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 527# define _LIBCPP_HIDDEN 528# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 529# define _LIBCPP_TEMPLATE_VIS 530# define _LIBCPP_TEMPLATE_DATA_VIS 531# define _LIBCPP_ENUM_VIS 532 533# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 534 535# ifndef _LIBCPP_HIDDEN 536# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 537# define _LIBCPP_HIDDEN __attribute__((__visibility__("hidden"))) 538# else 539# define _LIBCPP_HIDDEN 540# endif 541# endif 542 543# ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 544# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 545// The inline should be removed once PR32114 is resolved 546# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 547# else 548# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 549# endif 550# endif 551 552# ifndef _LIBCPP_FUNC_VIS 553# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 554# define _LIBCPP_FUNC_VIS __attribute__((__visibility__("default"))) 555# else 556# define _LIBCPP_FUNC_VIS 557# endif 558# endif 559 560# ifndef _LIBCPP_TYPE_VIS 561# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 562# define _LIBCPP_TYPE_VIS __attribute__((__visibility__("default"))) 563# else 564# define _LIBCPP_TYPE_VIS 565# endif 566# endif 567 568# ifndef _LIBCPP_TEMPLATE_VIS 569# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 570# if __has_attribute(__type_visibility__) 571# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) 572# else 573# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) 574# endif 575# else 576# define _LIBCPP_TEMPLATE_VIS 577# endif 578# endif 579 580# ifndef _LIBCPP_TEMPLATE_DATA_VIS 581# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 582# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__((__visibility__("default"))) 583# else 584# define _LIBCPP_TEMPLATE_DATA_VIS 585# endif 586# endif 587 588# ifndef _LIBCPP_EXPORTED_FROM_ABI 589# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 590# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) 591# else 592# define _LIBCPP_EXPORTED_FROM_ABI 593# endif 594# endif 595 596# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 597# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS 598# endif 599 600# ifndef _LIBCPP_EXCEPTION_ABI 601# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 602# define _LIBCPP_EXCEPTION_ABI __attribute__((__visibility__("default"))) 603# else 604# define _LIBCPP_EXCEPTION_ABI 605# endif 606# endif 607 608# ifndef _LIBCPP_ENUM_VIS 609# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 610# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) 611# else 612# define _LIBCPP_ENUM_VIS 613# endif 614# endif 615 616# ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 617# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 618# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__((__visibility__("default"))) 619# else 620# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 621# endif 622# endif 623 624# ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 625# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 626# endif 627 628# if __has_attribute(internal_linkage) 629# define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage)) 630# else 631# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE 632# endif 633 634# if __has_attribute(exclude_from_explicit_instantiation) 635# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) 636# else 637// Try to approximate the effect of exclude_from_explicit_instantiation 638// (which is that entities are not assumed to be provided by explicit 639// template instantiations in the dylib) by always inlining those entities. 640# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 641# endif 642 643# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU 644# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT 645# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 646# else 647# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 648# endif 649# endif 650 651# ifndef _LIBCPP_HIDE_FROM_ABI 652# if _LIBCPP_HIDE_FROM_ABI_PER_TU 653# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE 654# else 655# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 656# endif 657# endif 658 659# ifdef _LIBCPP_BUILDING_LIBRARY 660# if _LIBCPP_ABI_VERSION > 1 661# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 662# else 663# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 664# endif 665# else 666# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 667# endif 668 669// Just so we can migrate to the new macros gradually. 670# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 671 672// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 673// clang-format off 674# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 675# define _LIBCPP_END_NAMESPACE_STD }} 676# define _VSTD std 677 678_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 679 680# if _LIBCPP_STD_VER > 14 681# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 682 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 683# else 684# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 685 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 686# endif 687 688# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} 689// clang-format on 690 691# define _VSTD_FS std::__fs::filesystem 692 693# if __has_attribute(__enable_if__) 694# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) 695# endif 696 697# ifndef __SIZEOF_INT128__ 698# define _LIBCPP_HAS_NO_INT128 699# endif 700 701# ifdef _LIBCPP_CXX03_LANG 702# define static_assert(...) _Static_assert(__VA_ARGS__) 703# define decltype(...) __decltype(__VA_ARGS__) 704# endif // _LIBCPP_CXX03_LANG 705 706# ifdef _LIBCPP_CXX03_LANG 707# define _LIBCPP_CONSTEXPR 708# else 709# define _LIBCPP_CONSTEXPR constexpr 710# endif 711 712# ifndef __cpp_consteval 713# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR 714# else 715# define _LIBCPP_CONSTEVAL consteval 716# endif 717 718# ifdef __GNUC__ 719# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 720# else 721# define _LIBCPP_NOALIAS 722# endif 723 724# if __has_attribute(using_if_exists) 725# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) 726# else 727# define _LIBCPP_USING_IF_EXISTS 728# endif 729 730# ifdef _LIBCPP_CXX03_LANG 731# define _LIBCPP_DECLARE_STRONG_ENUM(x) \ 732 struct _LIBCPP_TYPE_VIS x { \ 733 enum __lx 734// clang-format off 735# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 736 __lx __v_; \ 737 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 738 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 739 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ 740 }; 741// clang-format on 742 743# else // _LIBCPP_CXX03_LANG 744# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 745# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 746# endif // _LIBCPP_CXX03_LANG 747 748# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ 749 defined(__NetBSD__) 750# define _LIBCPP_LOCALE__L_EXTENSIONS 1 751# endif 752 753# ifdef __FreeBSD__ 754# define _DECLARE_C99_LDBL_MATH 1 755# endif 756 757// If we are getting operator new from the MSVC CRT, then allocation overloads 758// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 759# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 760# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 761# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 762// We're deferring to Microsoft's STL to provide aligned new et al. We don't 763// have it unless the language feature test macro is defined. 764# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 765# elif defined(__MVS__) 766# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 767# endif 768 769# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) 770# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 771# endif 772 773# if defined(__APPLE__) || defined(__FreeBSD__) 774# define _LIBCPP_HAS_DEFAULTRUNELOCALE 775# endif 776 777# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 778# define _LIBCPP_WCTYPE_IS_MASK 779# endif 780 781# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 782# define _LIBCPP_HAS_NO_CHAR8_T 783# endif 784 785// Deprecation macros. 786// 787// Deprecations warnings are always enabled, except when users explicitly opt-out 788// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 789# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 790# if __has_attribute(deprecated) 791# define _LIBCPP_DEPRECATED __attribute__((deprecated)) 792# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m))) 793# elif _LIBCPP_STD_VER > 11 794# define _LIBCPP_DEPRECATED [[deprecated]] 795# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]] 796# else 797# define _LIBCPP_DEPRECATED 798# define _LIBCPP_DEPRECATED_(m) 799# endif 800# else 801# define _LIBCPP_DEPRECATED 802# define _LIBCPP_DEPRECATED_(m) 803# endif 804 805# if !defined(_LIBCPP_CXX03_LANG) 806# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 807# else 808# define _LIBCPP_DEPRECATED_IN_CXX11 809# endif 810 811# if _LIBCPP_STD_VER > 11 812# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 813# else 814# define _LIBCPP_DEPRECATED_IN_CXX14 815# endif 816 817# if _LIBCPP_STD_VER > 14 818# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 819# else 820# define _LIBCPP_DEPRECATED_IN_CXX17 821# endif 822 823# if _LIBCPP_STD_VER > 17 824# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 825# else 826# define _LIBCPP_DEPRECATED_IN_CXX20 827# endif 828 829# if !defined(_LIBCPP_HAS_NO_CHAR8_T) 830# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 831# else 832# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 833# endif 834 835// Macros to enter and leave a state where deprecation warnings are suppressed. 836# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) 837# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 838 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ 839 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 840# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") 841# else 842# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 843# define _LIBCPP_SUPPRESS_DEPRECATED_POP 844# endif 845 846# if _LIBCPP_STD_VER <= 11 847# define _LIBCPP_EXPLICIT_AFTER_CXX11 848# else 849# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 850# endif 851 852# if _LIBCPP_STD_VER > 11 853# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 854# else 855# define _LIBCPP_CONSTEXPR_AFTER_CXX11 856# endif 857 858# if _LIBCPP_STD_VER > 14 859# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 860# else 861# define _LIBCPP_CONSTEXPR_AFTER_CXX14 862# endif 863 864# if _LIBCPP_STD_VER > 17 865# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr 866# else 867# define _LIBCPP_CONSTEXPR_AFTER_CXX17 868# endif 869 870# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) 871# define _LIBCPP_NODISCARD [[nodiscard]] 872# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) 873# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] 874# else 875// We can't use GCC's [[gnu::warn_unused_result]] and 876// __attribute__((warn_unused_result)), because GCC does not silence them via 877// (void) cast. 878# define _LIBCPP_NODISCARD 879# endif 880 881// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 882// specified as such as an extension. 883# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 884# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD 885# else 886# define _LIBCPP_NODISCARD_EXT 887# endif 888 889# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) 890# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD 891# else 892# define _LIBCPP_NODISCARD_AFTER_CXX17 893# endif 894 895# if __has_attribute(no_destroy) 896# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 897# else 898# define _LIBCPP_NO_DESTROY 899# endif 900 901# ifndef _LIBCPP_HAS_NO_ASAN 902 extern "C" _LIBCPP_FUNC_VIS void 903 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); 904# endif 905 906// Try to find out if RTTI is disabled. 907# if !defined(__cpp_rtti) || __cpp_rtti < 199711L 908# define _LIBCPP_NO_RTTI 909# endif 910 911# ifndef _LIBCPP_WEAK 912# define _LIBCPP_WEAK __attribute__((__weak__)) 913# endif 914 915// Thread API 916// clang-format off 917# if !defined(_LIBCPP_HAS_NO_THREADS) && \ 918 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 919 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 920 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 921 922# if defined(__FreeBSD__) || \ 923 defined(__wasi__) || \ 924 defined(__NetBSD__) || \ 925 defined(__OpenBSD__) || \ 926 defined(__NuttX__) || \ 927 defined(__linux__) || \ 928 defined(__GNU__) || \ 929 defined(__APPLE__) || \ 930 defined(__sun__) || \ 931 defined(__MVS__) || \ 932 defined(_AIX) || \ 933 defined(__EMSCRIPTEN__) 934// clang-format on 935# define _LIBCPP_HAS_THREAD_API_PTHREAD 936# elif defined(__Fuchsia__) 937// TODO(44575): Switch to C11 thread API when possible. 938# define _LIBCPP_HAS_THREAD_API_PTHREAD 939# elif defined(_LIBCPP_WIN32API) 940# define _LIBCPP_HAS_THREAD_API_WIN32 941# else 942# error "No thread API" 943# endif // _LIBCPP_HAS_THREAD_API 944# endif // _LIBCPP_HAS_NO_THREADS 945 946# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 947# if defined(__ANDROID__) && __ANDROID_API__ >= 30 948# define _LIBCPP_HAS_COND_CLOCKWAIT 949# elif defined(_LIBCPP_GLIBC_PREREQ) 950# if _LIBCPP_GLIBC_PREREQ(2, 30) 951# define _LIBCPP_HAS_COND_CLOCKWAIT 952# endif 953# endif 954# endif 955 956# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 957# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 958 _LIBCPP_HAS_NO_THREADS is not defined. 959# endif 960 961# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 962# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 963 _LIBCPP_HAS_NO_THREADS is defined. 964# endif 965 966# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 967# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 968 _LIBCPP_HAS_NO_THREADS is defined. 969# endif 970 971# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 972# define __STDCPP_THREADS__ 1 973# endif 974 975// The glibc and Bionic implementation of pthreads implements 976// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 977// mutexes have no destroy mechanism. 978// 979// This optimization can't be performed on Apple platforms, where 980// pthread_mutex_destroy can allow the kernel to release resources. 981// See https://llvm.org/D64298 for details. 982// 983// TODO(EricWF): Enable this optimization on Bionic after speaking to their 984// respective stakeholders. 985// clang-format off 986# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ 987 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 988 defined(_LIBCPP_HAS_THREAD_API_WIN32) 989// clang-format on 990# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 991# endif 992 993// Destroying a condvar is a nop on Windows. 994// 995// This optimization can't be performed on Apple platforms, where 996// pthread_cond_destroy can allow the kernel to release resources. 997// See https://llvm.org/D64298 for details. 998// 999// TODO(EricWF): This is potentially true for some pthread implementations 1000// as well. 1001# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) 1002# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1003# endif 1004 1005// Some systems do not provide gets() in their C library, for security reasons. 1006# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) 1007# define _LIBCPP_C_HAS_NO_GETS 1008# endif 1009 1010# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ 1011 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) 1012# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1013# endif 1014 1015# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 1016# define _LIBCPP_HAS_C_ATOMIC_IMP 1017# elif defined(_LIBCPP_COMPILER_GCC) 1018# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1019# endif 1020 1021# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 1022 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) 1023# define _LIBCPP_HAS_NO_ATOMIC_HEADER 1024# else 1025# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 1026# define _LIBCPP_ATOMIC_FLAG_TYPE bool 1027# endif 1028# ifdef _LIBCPP_FREESTANDING 1029# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 1030# endif 1031# endif 1032 1033# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1034# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1035# endif 1036 1037# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 1038# if defined(__clang__) && __has_attribute(acquire_capability) 1039// Work around the attribute handling in clang. When both __declspec and 1040// __attribute__ are present, the processing goes awry preventing the definition 1041// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus 1042// combining the two does work. 1043# if !defined(_MSC_VER) 1044# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1045# endif 1046# endif 1047# endif 1048 1049# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1050# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1051# else 1052# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1053# endif 1054 1055# if _LIBCPP_STD_VER > 17 1056# define _LIBCPP_CONSTINIT constinit 1057# elif __has_attribute(require_constant_initialization) 1058# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) 1059# else 1060# define _LIBCPP_CONSTINIT 1061# endif 1062 1063# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1064# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning"))) 1065# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error"))) 1066# else 1067# define _LIBCPP_DIAGNOSE_WARNING(...) 1068# define _LIBCPP_DIAGNOSE_ERROR(...) 1069# endif 1070 1071// Use a function like macro to imply that it must be followed by a semicolon 1072# if __has_cpp_attribute(fallthrough) 1073# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1074# elif __has_attribute(__fallthrough__) 1075# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 1076# else 1077# define _LIBCPP_FALLTHROUGH() ((void)0) 1078# endif 1079 1080# if __has_attribute(__nodebug__) 1081# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 1082# else 1083# define _LIBCPP_NODEBUG 1084# endif 1085 1086# if __has_attribute(__standalone_debug__) 1087# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) 1088# else 1089# define _LIBCPP_STANDALONE_DEBUG 1090# endif 1091 1092# if __has_attribute(__preferred_name__) 1093# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 1094# else 1095# define _LIBCPP_PREFERRED_NAME(x) 1096# endif 1097 1098// We often repeat things just for handling wide characters in the library. 1099// When wide characters are disabled, it can be useful to have a quick way of 1100// disabling it without having to resort to #if-#endif, which has a larger 1101// impact on readability. 1102# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) 1103# define _LIBCPP_IF_WIDE_CHARACTERS(...) 1104# else 1105# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ 1106# endif 1107 1108# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) 1109# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 1110# else 1111# define _LIBCPP_DECLSPEC_EMPTY_BASES 1112# endif 1113 1114# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 1115# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 1116# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1117# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1118# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1119# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 1120 1121# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) 1122# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS 1123# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION 1124# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS 1125# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS 1126# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR 1127# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS 1128# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES 1129 1130# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L 1131# define _LIBCPP_HAS_NO_CXX20_COROUTINES 1132# endif 1133 1134# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") 1135# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") 1136 1137# ifndef _LIBCPP_NO_AUTO_LINK 1138# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1139# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 1140# pragma comment(lib, "c++.lib") 1141# else 1142# pragma comment(lib, "libc++.lib") 1143# endif 1144# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1145# endif // _LIBCPP_NO_AUTO_LINK 1146 1147// Configures the fopen close-on-exec mode character, if any. This string will 1148// be appended to any mode string used by fstream for fopen/fdopen. 1149// 1150// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1151// do. 1152# if defined(__BIONIC__) 1153# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1154# else 1155# define _LIBCPP_FOPEN_CLOEXEC_MODE 1156# endif 1157 1158// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1159// of functions used in cstdio may not be available for low API levels when 1160// using 64-bit file offsets on LP32. 1161# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1162# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1163# endif 1164 1165# if __has_attribute(init_priority) 1166// TODO: Remove this once we drop support for building libc++ with old Clangs 1167# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ 1168 (defined(__apple_build_version__) && __apple_build_version__ < 13000000) 1169# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) 1170# else 1171# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) 1172# endif 1173# else 1174# define _LIBCPP_INIT_PRIORITY_MAX 1175# endif 1176 1177# if defined(__GNUC__) || defined(__clang__) 1178// The attribute uses 1-based indices for ordinary and static member functions. 1179// The attribute uses 2-based indices for non-static member functions. 1180# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ 1181 __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) 1182# else 1183# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ 1184# endif 1185 1186# if __has_cpp_attribute(msvc::no_unique_address) 1187// MSVC implements [[no_unique_address]] as a silent no-op currently. 1188// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) 1189// However, MSVC implements [[msvc::no_unique_address]] which does what 1190// [[no_unique_address]] is supposed to do, in general. 1191 1192// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or 1193// [[msvc::no_unique_address]] though. If/when it does implement 1194// [[msvc::no_unique_address]], this should be preferred though. 1195# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] 1196# elif __has_cpp_attribute(no_unique_address) 1197# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] 1198# else 1199# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ 1200// Note that this can be replaced by #error as soon as clang-cl 1201// implements msvc::no_unique_address, since there should be no C++20 1202// compiler that doesn't support one of the two attributes at that point. 1203// We generally don't want to use this macro outside of C++20-only code, 1204// because using it conditionally in one language version only would make 1205// the ABI inconsistent. 1206# endif 1207 1208# ifdef _LIBCPP_COMPILER_CLANG_BASED 1209# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1210# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1211# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) 1212# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1213# elif defined(_LIBCPP_COMPILER_GCC) 1214# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1215# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1216# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1217# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) 1218# else 1219# define _LIBCPP_DIAGNOSTIC_PUSH 1220# define _LIBCPP_DIAGNOSTIC_POP 1221# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1222# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1223# endif 1224 1225# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) 1226# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") 1227# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") 1228# else 1229# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ 1230# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ 1231# endif 1232 1233#endif // __cplusplus 1234 1235#endif // _LIBCPP___CONFIG 1236