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