2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CONFIG
11 #define _LIBCPP___CONFIG
13 #include <__config_site>
15 #if defined(_MSC_VER) && !defined(__clang__)
16 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
21 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
22 # pragma GCC system_header
27 # define _LIBCPP_VERSION 15001
29 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
30 # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
32 // Valid C++ identifier that revs with every libc++ version. This can be used to
33 // generate identifiers that must be unique for every released libc++ version.
34 # define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
36 # if __STDC_HOSTED__ == 0
37 # define _LIBCPP_FREESTANDING
40 # ifndef _LIBCPP_STD_VER
41 # if __cplusplus <= 201103L
42 # define _LIBCPP_STD_VER 11
43 # elif __cplusplus <= 201402L
44 # define _LIBCPP_STD_VER 14
45 # elif __cplusplus <= 201703L
46 # define _LIBCPP_STD_VER 17
47 # elif __cplusplus <= 202002L
48 # define _LIBCPP_STD_VER 20
50 # define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
52 # endif // _LIBCPP_STD_VER
55 # define _LIBCPP_OBJECT_FORMAT_ELF 1
56 # elif defined(__MACH__)
57 # define _LIBCPP_OBJECT_FORMAT_MACHO 1
58 # elif defined(_WIN32)
59 # define _LIBCPP_OBJECT_FORMAT_COFF 1
60 # elif defined(__wasm__)
61 # define _LIBCPP_OBJECT_FORMAT_WASM 1
63 # define _LIBCPP_OBJECT_FORMAT_XCOFF 1
65 // ... add new file formats here ...
68 # if _LIBCPP_ABI_VERSION >= 2
69 // Change short string representation so that string data starts at offset 0,
70 // improving its alignment in some cases.
71 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
72 // Fix deque iterator type in order to support incomplete types.
73 # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
74 // Fix undefined behavior in how std::list stores its linked nodes.
75 # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
76 // Fix undefined behavior in how __tree stores its end and parent nodes.
77 # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
78 // Fix undefined behavior in how __hash_table stores its pointer types.
79 # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
80 # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
81 # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
82 // Define a key function for `bad_function_call` in the library, to centralize
83 // its vtable and typeinfo to libc++ rather than having all other libraries
84 // using that class define their own copies.
85 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
86 // Override the default return value of exception::what() for
87 // bad_function_call::what() with a string that is specific to
88 // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
89 // because it changes the vtable layout of bad_function_call.
90 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
91 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
92 # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
93 // Give reverse_iterator<T> one data member of type T, not two.
94 // Also, in C++17 and later, don't derive iterator types from std::iterator.
95 # define _LIBCPP_ABI_NO_ITERATOR_BASES
96 // Use the smallest possible integer type to represent the index of the variant.
97 // Previously libc++ used "unsigned int" exclusively.
98 # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
99 // Unstable attempt to provide a more optimized std::function
100 # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
101 // All the regex constants must be distinct and nonzero.
102 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
103 // Re-worked external template instantiations for std::string with a focus on
104 // performance and fast-path inlining.
105 # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
106 // Enable clang::trivial_abi on std::unique_ptr.
107 # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
108 // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
109 # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
110 // std::random_device holds some state when it uses an implementation that gets
111 // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
112 // implementation to another one on a platform that has already shipped
113 // std::random_device, one needs to retain the same object layout to remain ABI
114 // compatible. This switch removes these workarounds for platforms that don't care
115 // about ABI compatibility.
116 # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
117 // Don't export the legacy __basic_string_common class and its methods from the built library.
118 # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
119 // Don't export the legacy __vector_base_common class and its methods from the built library.
120 # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
121 // According to the Standard, `bitset::operator[] const` returns bool
122 # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
123 // Remove the base 10 implementation of std::to_chars from the dylib.
124 // The implementation moved to the header, but we still export the symbols from
125 // the dylib for backwards compatibility.
126 # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
127 # elif _LIBCPP_ABI_VERSION == 1
128 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
129 // Enable compiling copies of now inline methods into the dylib to support
130 // applications compiled against older libraries. This is unnecessary with
131 // COFF dllexport semantics, since dllexport forces a non-inline definition
132 // of inline functions to be emitted anyway. Our own non-inline copy would
133 // conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
134 // the linker will take issue with the symbols in the shared object if the
135 // weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
137 # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
139 // Feature macros for disabling pre ABI v1 features. All of these options
141 # if defined(__FreeBSD__)
142 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
146 # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
147 // Enable additional explicit instantiations of iostreams components. This
148 // reduces the number of weak definitions generated in programs that use
149 // iostreams by providing a single strong definition in the shared library.
150 # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
152 // Define a key function for `bad_function_call` in the library, to centralize
153 // its vtable and typeinfo to libc++ rather than having all other libraries
154 // using that class define their own copies.
155 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
158 # define _LIBCPP_TOSTRING2(x) # x
159 # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
161 # if __cplusplus < 201103L
162 # define _LIBCPP_CXX03_LANG
165 # ifndef __has_attribute
166 # define __has_attribute(__x) 0
169 # ifndef __has_builtin
170 # define __has_builtin(__x) 0
173 # ifndef __has_extension
174 # define __has_extension(__x) 0
177 # ifndef __has_feature
178 # define __has_feature(__x) 0
181 # ifndef __has_cpp_attribute
182 # define __has_cpp_attribute(__x) 0
185 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
186 // the compiler and '1' otherwise.
187 # ifndef __is_identifier
188 # define __is_identifier(__x) 1
191 # ifndef __has_declspec_attribute
192 # define __has_declspec_attribute(__x) 0
195 # define __has_keyword(__x) !(__is_identifier(__x))
197 # ifndef __has_include
198 # define __has_include(...) 0
201 # if defined(__apple_build_version__)
202 # define _LIBCPP_COMPILER_CLANG_BASED
203 # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
204 # elif defined(__clang__)
205 # define _LIBCPP_COMPILER_CLANG_BASED
206 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
207 # elif defined(__GNUC__)
208 # define _LIBCPP_COMPILER_GCC
209 # elif defined(_MSC_VER)
210 # define _LIBCPP_COMPILER_MSVC
213 # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
214 # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
217 # ifdef _LIBCPP_COMPILER_MSVC
218 # error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
219 changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
220 If there are users of this configuration we are happy to provide support.
223 // FIXME: ABI detection should be done via compiler builtin macros. This
224 // is just a placeholder until Clang implements such macros. For now assume
225 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
226 // and allow the user to explicitly specify the ABI to handle cases where this
227 // heuristic falls short.
228 # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
229 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
230 # elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
231 # define _LIBCPP_ABI_ITANIUM
232 # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
233 # define _LIBCPP_ABI_MICROSOFT
235 # if defined(_WIN32) && defined(_MSC_VER)
236 # define _LIBCPP_ABI_MICROSOFT
238 # define _LIBCPP_ABI_ITANIUM
242 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
243 # define _LIBCPP_ABI_VCRUNTIME
246 # if __has_feature(experimental_library)
247 # ifndef _LIBCPP_ENABLE_EXPERIMENTAL
248 # define _LIBCPP_ENABLE_EXPERIMENTAL
252 // Incomplete features get their own specific disabling flags. This makes it
253 // easier to grep for target specific flags once the feature is complete.
254 # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
255 # define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
256 # define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
259 // Need to detect which libc we're using if we're on Linux.
260 # if defined(__linux__)
261 # include <features.h>
262 # if defined(__GLIBC_PREREQ)
263 # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
265 # define _LIBCPP_GLIBC_PREREQ(a, b) 0
266 # endif // defined(__GLIBC_PREREQ)
267 # endif // defined(__linux__)
269 # if defined(__MVS__)
270 # include <features.h> // for __NATIVE_ASCII_F
273 # ifdef __LITTLE_ENDIAN__
274 # if __LITTLE_ENDIAN__
275 # define _LIBCPP_LITTLE_ENDIAN
276 # endif // __LITTLE_ENDIAN__
277 # endif // __LITTLE_ENDIAN__
279 # ifdef __BIG_ENDIAN__
281 # define _LIBCPP_BIG_ENDIAN
282 # endif // __BIG_ENDIAN__
283 # endif // __BIG_ENDIAN__
285 # ifdef __BYTE_ORDER__
286 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
287 # define _LIBCPP_LITTLE_ENDIAN
288 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
289 # define _LIBCPP_BIG_ENDIAN
290 # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
291 # endif // __BYTE_ORDER__
294 # include <sys/endian.h>
295 # include <osreldate.h>
296 # if _BYTE_ORDER == _LITTLE_ENDIAN
297 # define _LIBCPP_LITTLE_ENDIAN
298 # else // _BYTE_ORDER == _LITTLE_ENDIAN
299 # define _LIBCPP_BIG_ENDIAN
300 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
301 # endif // __FreeBSD__
303 # if defined(__NetBSD__) || defined(__OpenBSD__)
304 # include <sys/endian.h>
305 # if _BYTE_ORDER == _LITTLE_ENDIAN
306 # define _LIBCPP_LITTLE_ENDIAN
307 # else // _BYTE_ORDER == _LITTLE_ENDIAN
308 # define _LIBCPP_BIG_ENDIAN
309 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
310 # endif // defined(__NetBSD__) || defined(__OpenBSD__)
313 # define _LIBCPP_WIN32API
314 # define _LIBCPP_LITTLE_ENDIAN
315 # define _LIBCPP_SHORT_WCHAR 1
316 // Both MinGW and native MSVC provide a "MSVC"-like environment
317 # define _LIBCPP_MSVCRT_LIKE
318 // If mingw not explicitly detected, assume using MS C runtime only if
319 // a MS compatibility version is specified.
320 # if defined(_MSC_VER) && !defined(__MINGW32__)
321 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
323 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
324 # define _LIBCPP_HAS_BITSCAN64
326 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
327 # endif // defined(_WIN32)
330 # include <sys/isa_defs.h>
331 # ifdef _LITTLE_ENDIAN
332 # define _LIBCPP_LITTLE_ENDIAN
334 # define _LIBCPP_BIG_ENDIAN
338 # if defined(_AIX) && !defined(__64BIT__)
339 // The size of wchar is 2 byte on 32-bit mode on AIX.
340 # define _LIBCPP_SHORT_WCHAR 1
343 // Libc++ supports various implementations of std::random_device.
345 // _LIBCPP_USING_DEV_RANDOM
346 // Read entropy from the given file, by default `/dev/urandom`.
347 // If a token is provided, it is assumed to be the path to a file
348 // to read entropy from. This is the default behavior if nothing
349 // else is specified. This implementation requires storing state
350 // inside `std::random_device`.
352 // _LIBCPP_USING_ARC4_RANDOM
353 // Use arc4random(). This allows obtaining random data even when
354 // using sandboxing mechanisms. On some platforms like Apple, this
355 // is the recommended source of entropy for user-space programs.
356 // When this option is used, the token passed to `std::random_device`'s
357 // constructor *must* be "/dev/urandom" -- anything else is an error.
359 // _LIBCPP_USING_GETENTROPY
361 // When this option is used, the token passed to `std::random_device`'s
362 // constructor *must* be "/dev/urandom" -- anything else is an error.
364 // _LIBCPP_USING_FUCHSIA_CPRNG
365 // Use Fuchsia's zx_cprng_draw() system call, which is specified to
366 // deliver high-quality entropy and cannot fail.
367 // When this option is used, the token passed to `std::random_device`'s
368 // constructor *must* be "/dev/urandom" -- anything else is an error.
370 // _LIBCPP_USING_NACL_RANDOM
371 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
372 // including accesses to the special files under `/dev`. This implementation
373 // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
374 // When this option is used, the token passed to `std::random_device`'s
375 // constructor *must* be "/dev/urandom" -- anything else is an error.
377 // _LIBCPP_USING_WIN32_RANDOM
378 // Use rand_s(), for use on Windows.
379 // When this option is used, the token passed to `std::random_device`'s
380 // constructor *must* be "/dev/urandom" -- anything else is an error.
381 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
382 defined(__DragonFly__) || defined(__sun__)
383 # define _LIBCPP_USING_ARC4_RANDOM
384 # elif defined(__wasi__) || defined(__EMSCRIPTEN__)
385 # define _LIBCPP_USING_GETENTROPY
386 # elif defined(__Fuchsia__)
387 # define _LIBCPP_USING_FUCHSIA_CPRNG
388 # elif defined(__native_client__)
389 # define _LIBCPP_USING_NACL_RANDOM
390 # elif defined(_LIBCPP_WIN32API)
391 # define _LIBCPP_USING_WIN32_RANDOM
393 # define _LIBCPP_USING_DEV_RANDOM
396 # if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
398 # if __BYTE_ORDER == __LITTLE_ENDIAN
399 # define _LIBCPP_LITTLE_ENDIAN
400 # elif __BYTE_ORDER == __BIG_ENDIAN
401 # define _LIBCPP_BIG_ENDIAN
402 # else // __BYTE_ORDER == __BIG_ENDIAN
403 # error unable to determine endian
405 # endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
407 # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
408 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
410 # define _LIBCPP_NO_CFI
413 # ifndef _LIBCPP_CXX03_LANG
415 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
416 # define _ALIGNAS_TYPE(x) alignas(x)
417 # define _ALIGNAS(x) alignas(x)
418 # define _LIBCPP_NORETURN [[noreturn]]
419 # define _NOEXCEPT noexcept
420 # define _NOEXCEPT_(x) noexcept(x)
424 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
425 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
426 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
427 # define _LIBCPP_NORETURN __attribute__((noreturn))
428 # define _LIBCPP_HAS_NO_NOEXCEPT
429 # define nullptr __nullptr
430 # define _NOEXCEPT throw()
431 # define _NOEXCEPT_(x)
433 typedef __char16_t char16_t;
434 typedef __char32_t char32_t;
438 # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
439 # define _LIBCPP_NO_EXCEPTIONS
442 # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
444 # if defined(_LIBCPP_COMPILER_CLANG_BASED)
446 # if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
447 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
450 // Objective-C++ features (opt-in)
451 # if __has_feature(objc_arc)
452 # define _LIBCPP_HAS_OBJC_ARC
455 # if __has_feature(objc_arc_weak)
456 # define _LIBCPP_HAS_OBJC_ARC_WEAK
459 # if __has_extension(blocks)
460 # define _LIBCPP_HAS_EXTENSION_BLOCKS
463 # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
464 # define _LIBCPP_HAS_BLOCKS_RUNTIME
467 # if !__has_feature(address_sanitizer)
468 # define _LIBCPP_HAS_NO_ASAN
471 // Allow for build-time disabling of unsigned integer sanitization
472 # if __has_attribute(no_sanitize)
473 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
476 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
478 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
480 # elif defined(_LIBCPP_COMPILER_GCC)
482 # if !defined(__SANITIZE_ADDRESS__)
483 # define _LIBCPP_HAS_NO_ASAN
486 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
488 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
490 # elif defined(_LIBCPP_COMPILER_MSVC)
492 # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
495 # error "MSVC versions prior to Visual Studio 2015 are not supported"
498 # define _LIBCPP_NORETURN __declspec(noreturn)
500 # define _LIBCPP_WEAK
502 # define _LIBCPP_HAS_NO_ASAN
504 # define _LIBCPP_ALWAYS_INLINE __forceinline
506 # define _LIBCPP_HAS_NO_VECTOR_EXTENSION
508 # define _LIBCPP_DISABLE_EXTENSION_WARNING
510 # endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
512 # if defined(_LIBCPP_OBJECT_FORMAT_COFF)
515 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
517 # define _LIBCPP_CRT_FUNC
520 # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
521 # define _LIBCPP_DLL_VIS
522 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
523 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
524 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
525 # define _LIBCPP_EXPORTED_FROM_ABI
526 # elif defined(_LIBCPP_BUILDING_LIBRARY)
527 # define _LIBCPP_DLL_VIS __declspec(dllexport)
528 # if defined(__MINGW32__)
529 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
530 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
532 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
533 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
535 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
536 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
538 # define _LIBCPP_DLL_VIS __declspec(dllimport)
539 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
540 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
541 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
542 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
545 # define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
546 # define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
547 # define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
548 # define _LIBCPP_HIDDEN
549 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
550 # define _LIBCPP_TEMPLATE_VIS
551 # define _LIBCPP_TEMPLATE_DATA_VIS
552 # define _LIBCPP_ENUM_VIS
556 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
557 # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
559 # define _LIBCPP_VISIBILITY(vis)
562 # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
563 # define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default")
564 # define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default")
565 # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
566 # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
567 # define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default")
568 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
569 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
571 // TODO: Make this a proper customization point or remove the option to override it.
572 # ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
573 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
576 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
577 // The inline should be removed once PR32114 is resolved
578 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
580 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
583 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
584 # if __has_attribute(__type_visibility__)
585 # define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default")))
587 # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
590 # define _LIBCPP_TEMPLATE_VIS
593 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
594 # define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
596 # define _LIBCPP_ENUM_VIS
599 # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
601 # if __has_attribute(exclude_from_explicit_instantiation)
602 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
604 // Try to approximate the effect of exclude_from_explicit_instantiation
605 // (which is that entities are not assumed to be provided by explicit
606 // template instantiations in the dylib) by always inlining those entities.
607 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
610 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
612 // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
613 // symbols from their dynamic library by means of using the libc++ headers. This ensures
614 // that those symbols stay private to the dynamic library in which it is defined.
616 // 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures
617 // that no ODR violation can arise from mixing two TUs compiled with different versions
618 // of libc++ where we would have changed the definition of a symbol. If the symbols shared
619 // the same name, the ODR would require that their definitions be token-by-token equivalent,
620 // which basically prevents us from being able to make any change to any function in our
621 // headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at
622 // each release, which lets us change the definition of these symbols at our leisure.
623 // Note that historically, this has been achieved in various ways, including force-inlining
624 // all functions or giving internal linkage to all functions. Both these (previous) solutions
625 // suffer from drawbacks that lead notably to code bloat.
627 // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
628 // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
630 // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
631 // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
632 // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
633 # ifndef _LIBCPP_NO_ABI_TAG
634 # define _LIBCPP_HIDE_FROM_ABI \
635 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
636 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
638 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
641 # ifdef _LIBCPP_BUILDING_LIBRARY
642 # if _LIBCPP_ABI_VERSION > 1
643 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
645 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
648 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
651 // Just so we can migrate to the new macros gradually.
652 # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
654 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
656 # define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
657 # define _LIBCPP_END_NAMESPACE_STD }}
660 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
662 # if _LIBCPP_STD_VER > 14
663 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
664 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
666 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
667 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
670 # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
673 # define _VSTD_FS std::__fs::filesystem
675 # if __has_attribute(__enable_if__)
676 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
679 # ifndef __SIZEOF_INT128__
680 # define _LIBCPP_HAS_NO_INT128
683 # ifdef _LIBCPP_CXX03_LANG
684 # define static_assert(...) _Static_assert(__VA_ARGS__)
685 # define decltype(...) __decltype(__VA_ARGS__)
686 # endif // _LIBCPP_CXX03_LANG
688 # ifdef _LIBCPP_CXX03_LANG
689 # define _LIBCPP_CONSTEXPR
691 # define _LIBCPP_CONSTEXPR constexpr
694 # ifndef __cpp_consteval
695 # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
697 # define _LIBCPP_CONSTEVAL consteval
701 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
703 # define _LIBCPP_NOALIAS
706 # if __has_attribute(using_if_exists)
707 # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
709 # define _LIBCPP_USING_IF_EXISTS
712 # ifdef _LIBCPP_CXX03_LANG
713 # define _LIBCPP_DECLARE_STRONG_ENUM(x) \
714 struct _LIBCPP_TYPE_VIS x { \
717 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
719 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
720 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
721 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
725 # else // _LIBCPP_CXX03_LANG
726 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
727 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
728 # endif // _LIBCPP_CXX03_LANG
730 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
732 # define _LIBCPP_LOCALE__L_EXTENSIONS 1
736 # define _DECLARE_C99_LDBL_MATH 1
739 // If we are getting operator new from the MSVC CRT, then allocation overloads
740 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
741 # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
742 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
743 # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
744 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
745 // have it unless the language feature test macro is defined.
746 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
747 # elif defined(__MVS__)
748 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
751 # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
752 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
755 # if defined(__APPLE__) || defined(__FreeBSD__)
756 # define _LIBCPP_HAS_DEFAULTRUNELOCALE
759 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
760 # define _LIBCPP_WCTYPE_IS_MASK
763 # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
764 # define _LIBCPP_HAS_NO_CHAR8_T
767 // Deprecation macros.
769 // Deprecations warnings are always enabled, except when users explicitly opt-out
770 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
771 # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
772 # if __has_attribute(deprecated)
773 # define _LIBCPP_DEPRECATED __attribute__((deprecated))
774 # define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
775 # elif _LIBCPP_STD_VER > 11
776 # define _LIBCPP_DEPRECATED [[deprecated]]
777 # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
779 # define _LIBCPP_DEPRECATED
780 # define _LIBCPP_DEPRECATED_(m)
783 # define _LIBCPP_DEPRECATED
784 # define _LIBCPP_DEPRECATED_(m)
787 # if !defined(_LIBCPP_CXX03_LANG)
788 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
790 # define _LIBCPP_DEPRECATED_IN_CXX11
793 # if _LIBCPP_STD_VER > 11
794 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
796 # define _LIBCPP_DEPRECATED_IN_CXX14
799 # if _LIBCPP_STD_VER > 14
800 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
802 # define _LIBCPP_DEPRECATED_IN_CXX17
805 # if _LIBCPP_STD_VER > 17
806 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
808 # define _LIBCPP_DEPRECATED_IN_CXX20
811 # if !defined(_LIBCPP_HAS_NO_CHAR8_T)
812 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
814 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
817 // Macros to enter and leave a state where deprecation warnings are suppressed.
818 # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
819 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
820 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
821 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
822 # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
824 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
825 # define _LIBCPP_SUPPRESS_DEPRECATED_POP
828 # if _LIBCPP_STD_VER <= 11
829 # define _LIBCPP_EXPLICIT_AFTER_CXX11
831 # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
834 # if _LIBCPP_STD_VER > 11
835 # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
837 # define _LIBCPP_CONSTEXPR_AFTER_CXX11
840 # if _LIBCPP_STD_VER > 14
841 # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
843 # define _LIBCPP_CONSTEXPR_AFTER_CXX14
846 # if _LIBCPP_STD_VER > 17
847 # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
849 # define _LIBCPP_CONSTEXPR_AFTER_CXX17
852 # if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
853 # define _LIBCPP_NODISCARD [[nodiscard]]
854 # elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
855 # define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
857 // We can't use GCC's [[gnu::warn_unused_result]] and
858 // __attribute__((warn_unused_result)), because GCC does not silence them via
860 # define _LIBCPP_NODISCARD
863 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
864 // specified as such as an extension.
865 # if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
866 # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
868 # define _LIBCPP_NODISCARD_EXT
871 # if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
872 # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
874 # define _LIBCPP_NODISCARD_AFTER_CXX17
877 # if __has_attribute(no_destroy)
878 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
880 # define _LIBCPP_NO_DESTROY
883 # ifndef _LIBCPP_HAS_NO_ASAN
884 extern "C" _LIBCPP_FUNC_VIS void
885 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
888 // Try to find out if RTTI is disabled.
889 # if !defined(__cpp_rtti) || __cpp_rtti < 199711L
890 # define _LIBCPP_NO_RTTI
893 # ifndef _LIBCPP_WEAK
894 # define _LIBCPP_WEAK __attribute__((__weak__))
899 # if !defined(_LIBCPP_HAS_NO_THREADS) && \
900 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
901 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
902 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
904 # if defined(__FreeBSD__) || \
905 defined(__wasi__) || \
906 defined(__NetBSD__) || \
907 defined(__OpenBSD__) || \
908 defined(__NuttX__) || \
909 defined(__linux__) || \
910 defined(__GNU__) || \
911 defined(__APPLE__) || \
912 defined(__sun__) || \
913 defined(__MVS__) || \
915 defined(__EMSCRIPTEN__)
917 # define _LIBCPP_HAS_THREAD_API_PTHREAD
918 # elif defined(__Fuchsia__)
919 // TODO(44575): Switch to C11 thread API when possible.
920 # define _LIBCPP_HAS_THREAD_API_PTHREAD
921 # elif defined(_LIBCPP_WIN32API)
922 # define _LIBCPP_HAS_THREAD_API_WIN32
924 # error "No thread API"
925 # endif // _LIBCPP_HAS_THREAD_API
926 # endif // _LIBCPP_HAS_NO_THREADS
928 # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
929 # if defined(__ANDROID__) && __ANDROID_API__ >= 30
930 # define _LIBCPP_HAS_COND_CLOCKWAIT
931 # elif defined(_LIBCPP_GLIBC_PREREQ)
932 # if _LIBCPP_GLIBC_PREREQ(2, 30)
933 # define _LIBCPP_HAS_COND_CLOCKWAIT
938 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
939 # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
940 _LIBCPP_HAS_NO_THREADS is not defined.
943 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
944 # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
945 _LIBCPP_HAS_NO_THREADS is defined.
948 # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
949 # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
950 _LIBCPP_HAS_NO_THREADS is defined.
953 # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
954 # define __STDCPP_THREADS__ 1
957 // The glibc and Bionic implementation of pthreads implements
958 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
959 // mutexes have no destroy mechanism.
961 // This optimization can't be performed on Apple platforms, where
962 // pthread_mutex_destroy can allow the kernel to release resources.
963 // See https://llvm.org/D64298 for details.
965 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
966 // respective stakeholders.
968 # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
969 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
970 defined(_LIBCPP_HAS_THREAD_API_WIN32)
972 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
975 // Destroying a condvar is a nop on Windows.
977 // This optimization can't be performed on Apple platforms, where
978 // pthread_cond_destroy can allow the kernel to release resources.
979 // See https://llvm.org/D64298 for details.
981 // TODO(EricWF): This is potentially true for some pthread implementations
983 # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
984 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
987 // Some systems do not provide gets() in their C library, for security reasons.
988 # if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
989 # define _LIBCPP_C_HAS_NO_GETS
992 # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
993 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
994 # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
997 # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
998 # define _LIBCPP_HAS_C_ATOMIC_IMP
999 # elif defined(_LIBCPP_COMPILER_GCC)
1000 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
1003 # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1004 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1005 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
1007 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1008 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
1010 # ifdef _LIBCPP_FREESTANDING
1011 # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1015 # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1016 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1019 # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1020 # if defined(__clang__) && __has_attribute(acquire_capability)
1021 // Work around the attribute handling in clang. When both __declspec and
1022 // __attribute__ are present, the processing goes awry preventing the definition
1023 // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
1024 // combining the two does work.
1025 # if !defined(_MSC_VER)
1026 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1031 # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1032 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1034 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1037 # if _LIBCPP_STD_VER > 17
1038 # define _LIBCPP_CONSTINIT constinit
1039 # elif __has_attribute(require_constant_initialization)
1040 # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1042 # define _LIBCPP_CONSTINIT
1045 # if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1046 # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1047 # define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
1049 # define _LIBCPP_DIAGNOSE_WARNING(...)
1050 # define _LIBCPP_DIAGNOSE_ERROR(...)
1053 // Use a function like macro to imply that it must be followed by a semicolon
1054 # if __has_cpp_attribute(fallthrough)
1055 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1056 # elif __has_attribute(__fallthrough__)
1057 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1059 # define _LIBCPP_FALLTHROUGH() ((void)0)
1062 # if __has_attribute(__nodebug__)
1063 # define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1065 # define _LIBCPP_NODEBUG
1068 # if __has_attribute(__standalone_debug__)
1069 # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1071 # define _LIBCPP_STANDALONE_DEBUG
1074 # if __has_attribute(__preferred_name__)
1075 # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1077 # define _LIBCPP_PREFERRED_NAME(x)
1080 // We often repeat things just for handling wide characters in the library.
1081 // When wide characters are disabled, it can be useful to have a quick way of
1082 // disabling it without having to resort to #if-#endif, which has a larger
1083 // impact on readability.
1084 # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1085 # define _LIBCPP_IF_WIDE_CHARACTERS(...)
1087 # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1090 # if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1091 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1093 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1096 # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1097 # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1098 # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1099 # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1100 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1101 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1102 # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1104 // Leave the deprecation notices in by default, but don't remove unary_function and
1105 // binary_function entirely just yet. That way, folks will have one release to act
1106 // on the deprecation warnings.
1107 # ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1108 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1111 # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1112 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1113 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1114 # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1115 # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1116 # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1117 # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1118 # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1120 # if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
1121 # define _LIBCPP_HAS_NO_CXX20_COROUTINES
1124 # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
1125 # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
1127 # ifndef _LIBCPP_NO_AUTO_LINK
1128 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1129 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1130 # pragma comment(lib, "c++.lib")
1132 # pragma comment(lib, "libc++.lib")
1134 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1135 # endif // _LIBCPP_NO_AUTO_LINK
1137 // Configures the fopen close-on-exec mode character, if any. This string will
1138 // be appended to any mode string used by fstream for fopen/fdopen.
1140 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
1142 # if defined(__BIONIC__)
1143 # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1145 # define _LIBCPP_FOPEN_CLOEXEC_MODE
1148 // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1149 // of functions used in cstdio may not be available for low API levels when
1150 // using 64-bit file offsets on LP32.
1151 # if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1152 # define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1155 # if __has_attribute(init_priority)
1156 // TODO: Remove this once we drop support for building libc++ with old Clangs
1157 # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
1158 (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
1159 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1161 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
1164 # define _LIBCPP_INIT_PRIORITY_MAX
1167 # if defined(__GNUC__) || defined(__clang__)
1168 // The attribute uses 1-based indices for ordinary and static member functions.
1169 // The attribute uses 2-based indices for non-static member functions.
1170 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1171 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1173 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1176 # if __has_cpp_attribute(msvc::no_unique_address)
1177 // MSVC implements [[no_unique_address]] as a silent no-op currently.
1178 // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1179 // However, MSVC implements [[msvc::no_unique_address]] which does what
1180 // [[no_unique_address]] is supposed to do, in general.
1182 // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1183 // [[msvc::no_unique_address]] though. If/when it does implement
1184 // [[msvc::no_unique_address]], this should be preferred though.
1185 # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1186 # elif __has_cpp_attribute(no_unique_address)
1187 # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
1189 # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1190 // Note that this can be replaced by #error as soon as clang-cl
1191 // implements msvc::no_unique_address, since there should be no C++20
1192 // compiler that doesn't support one of the two attributes at that point.
1193 // We generally don't want to use this macro outside of C++20-only code,
1194 // because using it conditionally in one language version only would make
1195 // the ABI inconsistent.
1198 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1199 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1200 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1201 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1202 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1203 # elif defined(_LIBCPP_COMPILER_GCC)
1204 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1205 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1206 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1207 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1209 # define _LIBCPP_DIAGNOSTIC_PUSH
1210 # define _LIBCPP_DIAGNOSTIC_POP
1211 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1212 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1215 # if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
1216 # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
1217 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
1219 # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
1220 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
1223 # if __has_attribute(__packed__)
1224 # define _LIBCPP_PACKED __attribute__((__packed__))
1226 # define _LIBCPP_PACKED
1229 #endif // __cplusplus
1231 #endif // _LIBCPP___CONFIG