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