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_GCC) && __cplusplus < 201103L 212# error "libc++ does not support using GCC with C++03. 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# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) 394# elif defined(_LIBCPP_COMPILER_CLANG_BASED) 395# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) 396# else 397# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" 398# endif 399 400# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) 401 402# if defined(_LIBCPP_COMPILER_CLANG_BASED) 403 404# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) 405# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 406# endif 407 408# if __has_feature(cxx_alignas) 409# define _ALIGNAS_TYPE(x) alignas(x) 410# define _ALIGNAS(x) alignas(x) 411# else 412# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 413# define _ALIGNAS(x) __attribute__((__aligned__(x))) 414# endif 415 416# if __cplusplus < 201103L 417typedef __char16_t char16_t; 418typedef __char32_t char32_t; 419# endif 420 421# if !__has_feature(cxx_exceptions) 422# define _LIBCPP_NO_EXCEPTIONS 423# endif 424 425# if __has_feature(cxx_attributes) 426# define _LIBCPP_NORETURN [[noreturn]] 427# else 428# define _LIBCPP_NORETURN __attribute__((noreturn)) 429# endif 430 431# ifdef _LIBCPP_CXX03_LANG 432# define nullptr __nullptr 433# endif 434 435// Objective-C++ features (opt-in) 436# if __has_feature(objc_arc) 437# define _LIBCPP_HAS_OBJC_ARC 438# endif 439 440# if __has_feature(objc_arc_weak) 441# define _LIBCPP_HAS_OBJC_ARC_WEAK 442# endif 443 444# if __has_extension(blocks) 445# define _LIBCPP_HAS_EXTENSION_BLOCKS 446# endif 447 448# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) 449# define _LIBCPP_HAS_BLOCKS_RUNTIME 450# endif 451 452# if !(__has_feature(cxx_noexcept)) 453# define _LIBCPP_HAS_NO_NOEXCEPT 454# endif 455 456# if !__has_feature(address_sanitizer) 457# define _LIBCPP_HAS_NO_ASAN 458# endif 459 460// Allow for build-time disabling of unsigned integer sanitization 461# if __has_attribute(no_sanitize) 462# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 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_GCC) 470 471# define _ALIGNAS(x) __attribute__((__aligned__(x))) 472# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) 473 474# define _LIBCPP_NORETURN __attribute__((noreturn)) 475 476# if !defined(__EXCEPTIONS) 477# define _LIBCPP_NO_EXCEPTIONS 478# endif 479 480# if !defined(__SANITIZE_ADDRESS__) 481# define _LIBCPP_HAS_NO_ASAN 482# endif 483 484# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) 485 486# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ 487 488# elif defined(_LIBCPP_COMPILER_MSVC) 489 490# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 491 492# if _MSC_VER < 1900 493# error "MSVC versions prior to Visual Studio 2015 are not supported" 494# endif 495 496# define __alignof__ __alignof 497# define _LIBCPP_NORETURN __declspec(noreturn) 498# define _ALIGNAS(x) __declspec(align(x)) 499# define _ALIGNAS_TYPE(x) alignas(x) 500 501# define _LIBCPP_WEAK 502 503# define _LIBCPP_HAS_NO_ASAN 504 505# define _LIBCPP_ALWAYS_INLINE __forceinline 506 507# define _LIBCPP_HAS_NO_VECTOR_EXTENSION 508 509# define _LIBCPP_DISABLE_EXTENSION_WARNING 510 511# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC] 512 513# if defined(_LIBCPP_OBJECT_FORMAT_COFF) 514 515# ifdef _DLL 516# define _LIBCPP_CRT_FUNC __declspec(dllimport) 517# else 518# define _LIBCPP_CRT_FUNC 519# endif 520 521# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) 522# define _LIBCPP_DLL_VIS 523# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 524# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 525# define _LIBCPP_OVERRIDABLE_FUNC_VIS 526# define _LIBCPP_EXPORTED_FROM_ABI 527# elif defined(_LIBCPP_BUILDING_LIBRARY) 528# define _LIBCPP_DLL_VIS __declspec(dllexport) 529# if defined(__MINGW32__) 530# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 531# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 532# else 533# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 534# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 535# endif 536# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 537# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) 538# else 539# define _LIBCPP_DLL_VIS __declspec(dllimport) 540# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 541# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 542# define _LIBCPP_OVERRIDABLE_FUNC_VIS 543# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) 544# endif 545 546# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 547# define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 548# define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 549# define _LIBCPP_HIDDEN 550# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 551# define _LIBCPP_TEMPLATE_VIS 552# define _LIBCPP_TEMPLATE_DATA_VIS 553# define _LIBCPP_ENUM_VIS 554 555# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 556 557# ifndef _LIBCPP_HIDDEN 558# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 559# define _LIBCPP_HIDDEN __attribute__((__visibility__("hidden"))) 560# else 561# define _LIBCPP_HIDDEN 562# endif 563# endif 564 565# ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 566# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 567// The inline should be removed once PR32114 is resolved 568# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN 569# else 570# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 571# endif 572# endif 573 574# ifndef _LIBCPP_FUNC_VIS 575# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 576# define _LIBCPP_FUNC_VIS __attribute__((__visibility__("default"))) 577# else 578# define _LIBCPP_FUNC_VIS 579# endif 580# endif 581 582# ifndef _LIBCPP_TYPE_VIS 583# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 584# define _LIBCPP_TYPE_VIS __attribute__((__visibility__("default"))) 585# else 586# define _LIBCPP_TYPE_VIS 587# endif 588# endif 589 590# ifndef _LIBCPP_TEMPLATE_VIS 591# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 592# if __has_attribute(__type_visibility__) 593# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) 594# else 595# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) 596# endif 597# else 598# define _LIBCPP_TEMPLATE_VIS 599# endif 600# endif 601 602# ifndef _LIBCPP_TEMPLATE_DATA_VIS 603# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 604# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__((__visibility__("default"))) 605# else 606# define _LIBCPP_TEMPLATE_DATA_VIS 607# endif 608# endif 609 610# ifndef _LIBCPP_EXPORTED_FROM_ABI 611# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 612# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) 613# else 614# define _LIBCPP_EXPORTED_FROM_ABI 615# endif 616# endif 617 618# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 619# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS 620# endif 621 622# ifndef _LIBCPP_EXCEPTION_ABI 623# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 624# define _LIBCPP_EXCEPTION_ABI __attribute__((__visibility__("default"))) 625# else 626# define _LIBCPP_EXCEPTION_ABI 627# endif 628# endif 629 630# ifndef _LIBCPP_ENUM_VIS 631# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 632# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) 633# else 634# define _LIBCPP_ENUM_VIS 635# endif 636# endif 637 638# ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 639# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 640# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__((__visibility__("default"))) 641# else 642# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 643# endif 644# endif 645 646# ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 647# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 648# endif 649 650# if __has_attribute(internal_linkage) 651# define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage)) 652# else 653# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE 654# endif 655 656# if __has_attribute(exclude_from_explicit_instantiation) 657# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) 658# else 659// Try to approximate the effect of exclude_from_explicit_instantiation 660// (which is that entities are not assumed to be provided by explicit 661// template instantiations in the dylib) by always inlining those entities. 662# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE 663# endif 664 665# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU 666# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT 667# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 668# else 669# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 670# endif 671# endif 672 673# ifndef _LIBCPP_HIDE_FROM_ABI 674# if _LIBCPP_HIDE_FROM_ABI_PER_TU 675# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE 676# else 677# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION 678# endif 679# endif 680 681# ifdef _LIBCPP_BUILDING_LIBRARY 682# if _LIBCPP_ABI_VERSION > 1 683# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 684# else 685# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 686# endif 687# else 688# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI 689# endif 690 691// Just so we can migrate to the new macros gradually. 692# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI 693 694// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. 695// clang-format off 696# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { 697# define _LIBCPP_END_NAMESPACE_STD }} 698# define _VSTD std 699 700_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD 701 702# if _LIBCPP_STD_VER > 14 703# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 704 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { 705# else 706# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ 707 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { 708# endif 709 710# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} 711// clang-format on 712 713# define _VSTD_FS std::__fs::filesystem 714 715# if __has_attribute(__enable_if__) 716# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) 717# endif 718 719# ifndef _LIBCPP_HAS_NO_NOEXCEPT 720# define _NOEXCEPT noexcept 721# define _NOEXCEPT_(x) noexcept(x) 722# else 723# define _NOEXCEPT throw() 724# define _NOEXCEPT_(x) 725# endif 726 727# ifndef __SIZEOF_INT128__ 728# define _LIBCPP_HAS_NO_INT128 729# endif 730 731# ifdef _LIBCPP_CXX03_LANG 732# define static_assert(...) _Static_assert(__VA_ARGS__) 733# define decltype(...) __decltype(__VA_ARGS__) 734# endif // _LIBCPP_CXX03_LANG 735 736# ifdef _LIBCPP_CXX03_LANG 737# define _LIBCPP_CONSTEXPR 738# else 739# define _LIBCPP_CONSTEXPR constexpr 740# endif 741 742# ifndef __cpp_consteval 743# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR 744# else 745# define _LIBCPP_CONSTEVAL consteval 746# endif 747 748# ifdef __GNUC__ 749# define _LIBCPP_NOALIAS __attribute__((__malloc__)) 750# else 751# define _LIBCPP_NOALIAS 752# endif 753 754# if __has_attribute(using_if_exists) 755# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) 756# else 757# define _LIBCPP_USING_IF_EXISTS 758# endif 759 760# ifdef _LIBCPP_CXX03_LANG 761# define _LIBCPP_DECLARE_STRONG_ENUM(x) \ 762 struct _LIBCPP_TYPE_VIS x { \ 763 enum __lx 764// clang-format off 765# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 766 __lx __v_; \ 767 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ 768 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 769 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ 770 }; 771// clang-format on 772 773# else // _LIBCPP_CXX03_LANG 774# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 775# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 776# endif // _LIBCPP_CXX03_LANG 777 778# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ 779 defined(__NetBSD__) 780# define _LIBCPP_LOCALE__L_EXTENSIONS 1 781# endif 782 783# ifdef __FreeBSD__ 784# define _DECLARE_C99_LDBL_MATH 1 785# endif 786 787// If we are getting operator new from the MSVC CRT, then allocation overloads 788// for align_val_t were added in 19.12, aka VS 2017 version 15.3. 789# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 790# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 791# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) 792// We're deferring to Microsoft's STL to provide aligned new et al. We don't 793// have it unless the language feature test macro is defined. 794# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 795# elif defined(__MVS__) 796# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION 797# endif 798 799# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) 800# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 801# endif 802 803# if defined(__APPLE__) || defined(__FreeBSD__) 804# define _LIBCPP_HAS_DEFAULTRUNELOCALE 805# endif 806 807# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 808# define _LIBCPP_WCTYPE_IS_MASK 809# endif 810 811# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) 812# define _LIBCPP_HAS_NO_CHAR8_T 813# endif 814 815// Deprecation macros. 816// 817// Deprecations warnings are always enabled, except when users explicitly opt-out 818// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. 819# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) 820# if __has_attribute(deprecated) 821# define _LIBCPP_DEPRECATED __attribute__((deprecated)) 822# elif _LIBCPP_STD_VER > 11 823# define _LIBCPP_DEPRECATED [[deprecated]] 824# else 825# define _LIBCPP_DEPRECATED 826# endif 827# else 828# define _LIBCPP_DEPRECATED 829# endif 830 831# if !defined(_LIBCPP_CXX03_LANG) 832# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED 833# else 834# define _LIBCPP_DEPRECATED_IN_CXX11 835# endif 836 837# if _LIBCPP_STD_VER > 11 838# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED 839# else 840# define _LIBCPP_DEPRECATED_IN_CXX14 841# endif 842 843# if _LIBCPP_STD_VER > 14 844# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED 845# else 846# define _LIBCPP_DEPRECATED_IN_CXX17 847# endif 848 849# if _LIBCPP_STD_VER > 17 850# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED 851# else 852# define _LIBCPP_DEPRECATED_IN_CXX20 853# endif 854 855# if !defined(_LIBCPP_HAS_NO_CHAR8_T) 856# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED 857# else 858# define _LIBCPP_DEPRECATED_WITH_CHAR8_T 859# endif 860 861// Macros to enter and leave a state where deprecation warnings are suppressed. 862# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) 863# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ 864 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ 865 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 866# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") 867# else 868# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 869# define _LIBCPP_SUPPRESS_DEPRECATED_POP 870# endif 871 872# if _LIBCPP_STD_VER <= 11 873# define _LIBCPP_EXPLICIT_AFTER_CXX11 874# else 875# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 876# endif 877 878# if _LIBCPP_STD_VER > 11 879# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 880# else 881# define _LIBCPP_CONSTEXPR_AFTER_CXX11 882# endif 883 884# if _LIBCPP_STD_VER > 14 885# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 886# else 887# define _LIBCPP_CONSTEXPR_AFTER_CXX14 888# endif 889 890# if _LIBCPP_STD_VER > 17 891# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr 892# else 893# define _LIBCPP_CONSTEXPR_AFTER_CXX17 894# endif 895 896# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) 897# define _LIBCPP_NODISCARD [[nodiscard]] 898# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) 899# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] 900# else 901// We can't use GCC's [[gnu::warn_unused_result]] and 902// __attribute__((warn_unused_result)), because GCC does not silence them via 903// (void) cast. 904# define _LIBCPP_NODISCARD 905# endif 906 907// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not 908// specified as such as an extension. 909# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) 910# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD 911# else 912# define _LIBCPP_NODISCARD_EXT 913# endif 914 915# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) 916# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD 917# else 918# define _LIBCPP_NODISCARD_AFTER_CXX17 919# endif 920 921# if __has_attribute(no_destroy) 922# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) 923# else 924# define _LIBCPP_NO_DESTROY 925# endif 926 927# ifndef _LIBCPP_HAS_NO_ASAN 928extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, 929 const void*); 930# endif 931 932// Try to find out if RTTI is disabled. 933# if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) 934# define _LIBCPP_NO_RTTI 935# elif defined(__GNUC__) && !defined(__GXX_RTTI) 936# define _LIBCPP_NO_RTTI 937# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) 938# define _LIBCPP_NO_RTTI 939# endif 940 941# ifndef _LIBCPP_WEAK 942# define _LIBCPP_WEAK __attribute__((__weak__)) 943# endif 944 945// Thread API 946// clang-format off 947# if !defined(_LIBCPP_HAS_NO_THREADS) && \ 948 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ 949 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ 950 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 951 952# if defined(__FreeBSD__) || \ 953 defined(__wasi__) || \ 954 defined(__NetBSD__) || \ 955 defined(__OpenBSD__) || \ 956 defined(__NuttX__) || \ 957 defined(__linux__) || \ 958 defined(__GNU__) || \ 959 defined(__APPLE__) || \ 960 defined(__sun__) || \ 961 defined(__MVS__) || \ 962 defined(_AIX) || \ 963 defined(__EMSCRIPTEN__) 964// clang-format on 965# define _LIBCPP_HAS_THREAD_API_PTHREAD 966# elif defined(__Fuchsia__) 967// TODO(44575): Switch to C11 thread API when possible. 968# define _LIBCPP_HAS_THREAD_API_PTHREAD 969# elif defined(_LIBCPP_WIN32API) 970# define _LIBCPP_HAS_THREAD_API_WIN32 971# else 972# error "No thread API" 973# endif // _LIBCPP_HAS_THREAD_API 974# endif // _LIBCPP_HAS_NO_THREADS 975 976# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 977# if defined(__ANDROID__) && __ANDROID_API__ >= 30 978# define _LIBCPP_HAS_COND_CLOCKWAIT 979# elif defined(_LIBCPP_GLIBC_PREREQ) 980# if _LIBCPP_GLIBC_PREREQ(2, 30) 981# define _LIBCPP_HAS_COND_CLOCKWAIT 982# endif 983# endif 984# endif 985 986# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 987# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 988 _LIBCPP_HAS_NO_THREADS is not defined. 989# endif 990 991# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 992# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ 993 _LIBCPP_HAS_NO_THREADS is defined. 994# endif 995 996# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 997# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 998 _LIBCPP_HAS_NO_THREADS is defined. 999# endif 1000 1001# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) 1002# define __STDCPP_THREADS__ 1 1003# endif 1004 1005// The glibc and Bionic implementation of pthreads implements 1006// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 1007// mutexes have no destroy mechanism. 1008// 1009// This optimization can't be performed on Apple platforms, where 1010// pthread_mutex_destroy can allow the kernel to release resources. 1011// See https://llvm.org/D64298 for details. 1012// 1013// TODO(EricWF): Enable this optimization on Bionic after speaking to their 1014// respective stakeholders. 1015// clang-format off 1016# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ 1017 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ 1018 defined(_LIBCPP_HAS_THREAD_API_WIN32) 1019// clang-format on 1020# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1021# endif 1022 1023// Destroying a condvar is a nop on Windows. 1024// 1025// This optimization can't be performed on Apple platforms, where 1026// pthread_cond_destroy can allow the kernel to release resources. 1027// See https://llvm.org/D64298 for details. 1028// 1029// TODO(EricWF): This is potentially true for some pthread implementations 1030// as well. 1031# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) 1032# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1033# endif 1034 1035// Some systems do not provide gets() in their C library, for security reasons. 1036# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) 1037# define _LIBCPP_C_HAS_NO_GETS 1038# endif 1039 1040# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ 1041 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) 1042# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 1043# endif 1044 1045# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) 1046# define _LIBCPP_HAS_C_ATOMIC_IMP 1047# elif defined(_LIBCPP_COMPILER_GCC) 1048# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1049# endif 1050 1051# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ 1052 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) 1053# define _LIBCPP_HAS_NO_ATOMIC_HEADER 1054# else 1055# ifndef _LIBCPP_ATOMIC_FLAG_TYPE 1056# define _LIBCPP_ATOMIC_FLAG_TYPE bool 1057# endif 1058# ifdef _LIBCPP_FREESTANDING 1059# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS 1060# endif 1061# endif 1062 1063# ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1064# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1065# endif 1066 1067# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 1068# if defined(__clang__) && __has_attribute(acquire_capability) 1069// Work around the attribute handling in clang. When both __declspec and 1070// __attribute__ are present, the processing goes awry preventing the definition 1071// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus 1072// combining the two does work. 1073# if !defined(_MSC_VER) 1074# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1075# endif 1076# endif 1077# endif 1078 1079# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1080# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) 1081# else 1082# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) 1083# endif 1084 1085# if _LIBCPP_STD_VER > 17 1086# define _LIBCPP_CONSTINIT constinit 1087# elif __has_attribute(require_constant_initialization) 1088# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) 1089# else 1090# define _LIBCPP_CONSTINIT 1091# endif 1092 1093# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) 1094# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning"))) 1095# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error"))) 1096# else 1097# define _LIBCPP_DIAGNOSE_WARNING(...) 1098# define _LIBCPP_DIAGNOSE_ERROR(...) 1099# endif 1100 1101// Use a function like macro to imply that it must be followed by a semicolon 1102# if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough) 1103# define _LIBCPP_FALLTHROUGH() [[fallthrough]] 1104# elif __has_cpp_attribute(clang::fallthrough) 1105# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] 1106# elif __has_attribute(__fallthrough__) 1107# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) 1108# else 1109# define _LIBCPP_FALLTHROUGH() ((void)0) 1110# endif 1111 1112# if __has_attribute(__nodebug__) 1113# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) 1114# else 1115# define _LIBCPP_NODEBUG 1116# endif 1117 1118# if __has_attribute(__standalone_debug__) 1119# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) 1120# else 1121# define _LIBCPP_STANDALONE_DEBUG 1122# endif 1123 1124# if __has_attribute(__preferred_name__) 1125# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) 1126# else 1127# define _LIBCPP_PREFERRED_NAME(x) 1128# endif 1129 1130// We often repeat things just for handling wide characters in the library. 1131// When wide characters are disabled, it can be useful to have a quick way of 1132// disabling it without having to resort to #if-#endif, which has a larger 1133// impact on readability. 1134# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) 1135# define _LIBCPP_IF_WIDE_CHARACTERS(...) 1136# else 1137# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ 1138# endif 1139 1140# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) 1141# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) 1142# else 1143# define _LIBCPP_DECLSPEC_EMPTY_BASES 1144# endif 1145 1146# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) 1147# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR 1148# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS 1149# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 1150# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS 1151# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 1152 1153# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) 1154# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS 1155# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION 1156# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS 1157# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS 1158# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR 1159# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS 1160# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES 1161 1162# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L 1163# define _LIBCPP_HAS_NO_CXX20_COROUTINES 1164# endif 1165 1166# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") 1167# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") 1168 1169# ifndef _LIBCPP_NO_AUTO_LINK 1170# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1171# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 1172# pragma comment(lib, "c++.lib") 1173# else 1174# pragma comment(lib, "libc++.lib") 1175# endif 1176# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) 1177# endif // _LIBCPP_NO_AUTO_LINK 1178 1179// Configures the fopen close-on-exec mode character, if any. This string will 1180// be appended to any mode string used by fstream for fopen/fdopen. 1181// 1182// Not all platforms support this, but it helps avoid fd-leaks on platforms that 1183// do. 1184# if defined(__BIONIC__) 1185# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" 1186# else 1187# define _LIBCPP_FOPEN_CLOEXEC_MODE 1188# endif 1189 1190// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set 1191// of functions used in cstdio may not be available for low API levels when 1192// using 64-bit file offsets on LP32. 1193# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 1194# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS 1195# endif 1196 1197# if __has_attribute(init_priority) 1198// TODO: Remove this once we drop support for building libc++ with old Clangs 1199# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ 1200 (defined(__apple_build_version__) && __apple_build_version__ < 13000000) 1201# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) 1202# else 1203# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) 1204# endif 1205# else 1206# define _LIBCPP_INIT_PRIORITY_MAX 1207# endif 1208 1209# if defined(__GNUC__) || defined(__clang__) 1210// The attribute uses 1-based indices for ordinary and static member functions. 1211// The attribute uses 2-based indices for non-static member functions. 1212# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ 1213 __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) 1214# else 1215# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ 1216# endif 1217 1218# if __has_cpp_attribute(msvc::no_unique_address) 1219// MSVC implements [[no_unique_address]] as a silent no-op currently. 1220// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) 1221// However, MSVC implements [[msvc::no_unique_address]] which does what 1222// [[no_unique_address]] is supposed to do, in general. 1223 1224// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or 1225// [[msvc::no_unique_address]] though. If/when it does implement 1226// [[msvc::no_unique_address]], this should be preferred though. 1227# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] 1228# elif __has_cpp_attribute(no_unique_address) 1229# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] 1230# else 1231# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ 1232// Note that this can be replaced by #error as soon as clang-cl 1233// implements msvc::no_unique_address, since there should be no C++20 1234// compiler that doesn't support one of the two attributes at that point. 1235// We generally don't want to use this macro outside of C++20-only code, 1236// because using it conditionally in one language version only would make 1237// the ABI inconsistent. 1238# endif 1239 1240# ifdef _LIBCPP_COMPILER_CLANG_BASED 1241# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") 1242# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") 1243# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) 1244# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1245# elif defined(_LIBCPP_COMPILER_GCC) 1246# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") 1247# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") 1248# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1249# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) 1250# else 1251# define _LIBCPP_DIAGNOSTIC_PUSH 1252# define _LIBCPP_DIAGNOSTIC_POP 1253# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) 1254# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) 1255# endif 1256 1257# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) 1258# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") 1259# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") 1260# else 1261# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ 1262# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ 1263# endif 1264 1265#endif // __cplusplus 1266 1267#endif // _LIBCPP___CONFIG 1268