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 14000
29 #ifndef _LIBCPP_ABI_VERSION
30 # define _LIBCPP_ABI_VERSION 1
33 #if __STDC_HOSTED__ == 0
34 # define _LIBCPP_FREESTANDING
37 #ifndef _LIBCPP_STD_VER
38 # if __cplusplus <= 201103L
39 # define _LIBCPP_STD_VER 11
40 # elif __cplusplus <= 201402L
41 # define _LIBCPP_STD_VER 14
42 # elif __cplusplus <= 201703L
43 # define _LIBCPP_STD_VER 17
44 # elif __cplusplus <= 202002L
45 # define _LIBCPP_STD_VER 20
47 # define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
49 #endif // _LIBCPP_STD_VER
52 # define _LIBCPP_OBJECT_FORMAT_ELF 1
53 #elif defined(__MACH__)
54 # define _LIBCPP_OBJECT_FORMAT_MACHO 1
56 # define _LIBCPP_OBJECT_FORMAT_COFF 1
57 #elif defined(__wasm__)
58 # define _LIBCPP_OBJECT_FORMAT_WASM 1
60 // ... add new file formats here ...
63 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
64 // Change short string representation so that string data starts at offset 0,
65 // improving its alignment in some cases.
66 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
67 // Fix deque iterator type in order to support incomplete types.
68 # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
69 // Fix undefined behavior in how std::list stores its linked nodes.
70 # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
71 // Fix undefined behavior in how __tree stores its end and parent nodes.
72 # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
73 // Fix undefined behavior in how __hash_table stores its pointer types.
74 # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
75 # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
76 # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
77 // Define a key function for `bad_function_call` in the library, to centralize
78 // its vtable and typeinfo to libc++ rather than having all other libraries
79 // using that class define their own copies.
80 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
81 // Override the default return value of exception::what() for
82 // bad_function_call::what() with a string that is specific to
83 // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
84 // because it changes the vtable layout of bad_function_call.
85 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
86 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
87 # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
88 // In C++20 and later, don't derive std::plus from std::binary_function,
89 // nor std::negate from std::unary_function.
90 # define _LIBCPP_ABI_NO_BINDER_BASES
91 // Give reverse_iterator<T> one data member of type T, not two.
92 // Also, in C++17 and later, don't derive iterator types from std::iterator.
93 # define _LIBCPP_ABI_NO_ITERATOR_BASES
94 // Use the smallest possible integer type to represent the index of the variant.
95 // Previously libc++ used "unsigned int" exclusively.
96 # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
97 // Unstable attempt to provide a more optimized std::function
98 # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
99 // All the regex constants must be distinct and nonzero.
100 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
101 // Use raw pointers, not wrapped ones, for std::span's iterator type.
102 # define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
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 #elif _LIBCPP_ABI_VERSION == 1
118 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
119 // Enable compiling copies of now inline methods into the dylib to support
120 // applications compiled against older libraries. This is unnecessary with
121 // COFF dllexport semantics, since dllexport forces a non-inline definition
122 // of inline functions to be emitted anyway. Our own non-inline copy would
123 // conflict with the dllexport-emitted copy, so we disable it.
124 # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
126 // Feature macros for disabling pre ABI v1 features. All of these options
128 # if defined(__FreeBSD__)
129 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
133 // By default, don't use a nullptr_t emulation type in C++03.
135 // This is technically an ABI break from previous releases, however it is
136 // very unlikely to impact anyone. If a user is impacted by this break,
137 // they can return to using the C++03 nullptr emulation by defining
138 // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION.
140 // This switch will be removed entirely in favour of never providing a
141 // C++03 emulation after one release.
143 // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE
144 // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN
145 // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION.
146 #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION
147 # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
150 #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
151 // Enable additional explicit instantiations of iostreams components. This
152 // reduces the number of weak definitions generated in programs that use
153 // iostreams by providing a single strong definition in the shared library.
154 # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
156 // Define a key function for `bad_function_call` in the library, to centralize
157 // its vtable and typeinfo to libc++ rather than having all other libraries
158 // using that class define their own copies.
159 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
162 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
163 #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
165 #ifndef _LIBCPP_ABI_NAMESPACE
166 # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
169 #if __cplusplus < 201103L
170 #define _LIBCPP_CXX03_LANG
173 #ifndef __has_attribute
174 #define __has_attribute(__x) 0
177 #ifndef __has_builtin
178 #define __has_builtin(__x) 0
181 #ifndef __has_extension
182 #define __has_extension(__x) 0
185 #ifndef __has_feature
186 #define __has_feature(__x) 0
189 #ifndef __has_cpp_attribute
190 #define __has_cpp_attribute(__x) 0
193 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
194 // the compiler and '1' otherwise.
195 #ifndef __is_identifier
196 #define __is_identifier(__x) 1
199 #ifndef __has_declspec_attribute
200 #define __has_declspec_attribute(__x) 0
203 #define __has_keyword(__x) !(__is_identifier(__x))
205 #ifndef __has_include
206 #define __has_include(...) 0
209 #if defined(__apple_build_version__)
210 # define _LIBCPP_COMPILER_CLANG_BASED
211 # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
212 #elif defined(__clang__)
213 # define _LIBCPP_COMPILER_CLANG_BASED
214 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
215 #elif defined(__GNUC__)
216 # define _LIBCPP_COMPILER_GCC
217 #elif defined(_MSC_VER)
218 # define _LIBCPP_COMPILER_MSVC
219 #elif defined(__IBMCPP__)
220 # define _LIBCPP_COMPILER_IBM
223 #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
224 #error "libc++ does not support using GCC with C++03. Please enable C++11"
227 // FIXME: ABI detection should be done via compiler builtin macros. This
228 // is just a placeholder until Clang implements such macros. For now assume
229 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
230 // and allow the user to explicitly specify the ABI to handle cases where this
231 // heuristic falls short.
232 #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
233 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
234 #elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
235 # define _LIBCPP_ABI_ITANIUM
236 #elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
237 # define _LIBCPP_ABI_MICROSOFT
239 # if defined(_WIN32) && defined(_MSC_VER)
240 # define _LIBCPP_ABI_MICROSOFT
242 # define _LIBCPP_ABI_ITANIUM
246 #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
247 # define _LIBCPP_ABI_VCRUNTIME
250 // Need to detect which libc we're using if we're on Linux.
251 #if defined(__linux__)
252 # include <features.h>
253 # if defined(__GLIBC_PREREQ)
254 # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
256 # define _LIBCPP_GLIBC_PREREQ(a, b) 0
257 # endif // defined(__GLIBC_PREREQ)
258 #endif // defined(__linux__)
261 # include <features.h> // for __NATIVE_ASCII_F
264 #ifdef __LITTLE_ENDIAN__
265 # if __LITTLE_ENDIAN__
266 # define _LIBCPP_LITTLE_ENDIAN
267 # endif // __LITTLE_ENDIAN__
268 #endif // __LITTLE_ENDIAN__
270 #ifdef __BIG_ENDIAN__
272 # define _LIBCPP_BIG_ENDIAN
273 # endif // __BIG_ENDIAN__
274 #endif // __BIG_ENDIAN__
276 #ifdef __BYTE_ORDER__
277 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
278 # define _LIBCPP_LITTLE_ENDIAN
279 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
280 # define _LIBCPP_BIG_ENDIAN
281 # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
282 #endif // __BYTE_ORDER__
285 # include <sys/endian.h>
286 # include <osreldate.h>
287 # if _BYTE_ORDER == _LITTLE_ENDIAN
288 # define _LIBCPP_LITTLE_ENDIAN
289 # else // _BYTE_ORDER == _LITTLE_ENDIAN
290 # define _LIBCPP_BIG_ENDIAN
291 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
292 #endif // __FreeBSD__
294 #if defined(__NetBSD__) || defined(__OpenBSD__)
295 # include <sys/endian.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 // defined(__NetBSD__) || defined(__OpenBSD__)
304 # define _LIBCPP_WIN32API
305 # define _LIBCPP_LITTLE_ENDIAN
306 # define _LIBCPP_SHORT_WCHAR 1
307 // Both MinGW and native MSVC provide a "MSVC"-like environment
308 # define _LIBCPP_MSVCRT_LIKE
309 // If mingw not explicitly detected, assume using MS C runtime only if
310 // a MS compatibility version is specified.
311 # if defined(_MSC_VER) && !defined(__MINGW32__)
312 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
314 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
315 # define _LIBCPP_HAS_BITSCAN64
317 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
318 # if defined(_LIBCPP_MSVCRT)
319 # define _LIBCPP_HAS_QUICK_EXIT
322 // Some CRT APIs are unavailable to store apps
323 # if defined(WINAPI_FAMILY)
324 # include <winapifamily.h>
325 # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
326 (!defined(WINAPI_PARTITION_SYSTEM) || \
327 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
328 # define _LIBCPP_WINDOWS_STORE_APP
331 #endif // defined(_WIN32)
334 # include <sys/isa_defs.h>
335 # ifdef _LITTLE_ENDIAN
336 # define _LIBCPP_LITTLE_ENDIAN
338 # define _LIBCPP_BIG_ENDIAN
342 #if defined(_AIX) && !defined(__64BIT__)
343 // The size of wchar is 2 byte on 32-bit mode on AIX.
344 # define _LIBCPP_SHORT_WCHAR 1
347 // Libc++ supports various implementations of std::random_device.
349 // _LIBCPP_USING_DEV_RANDOM
350 // Read entropy from the given file, by default `/dev/urandom`.
351 // If a token is provided, it is assumed to be the path to a file
352 // to read entropy from. This is the default behavior if nothing
353 // else is specified. This implementation requires storing state
354 // inside `std::random_device`.
356 // _LIBCPP_USING_ARC4_RANDOM
357 // Use arc4random(). This allows obtaining random data even when
358 // using sandboxing mechanisms. On some platforms like Apple, this
359 // is the recommended source of entropy for user-space programs.
360 // When this option is used, the token passed to `std::random_device`'s
361 // constructor *must* be "/dev/urandom" -- anything else is an error.
363 // _LIBCPP_USING_GETENTROPY
365 // When this option is used, the token passed to `std::random_device`'s
366 // constructor *must* be "/dev/urandom" -- anything else is an error.
368 // _LIBCPP_USING_FUCHSIA_CPRNG
369 // Use Fuchsia's zx_cprng_draw() system call, which is specified to
370 // deliver high-quality entropy and cannot fail.
371 // When this option is used, the token passed to `std::random_device`'s
372 // constructor *must* be "/dev/urandom" -- anything else is an error.
374 // _LIBCPP_USING_NACL_RANDOM
375 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
376 // including accesses to the special files under `/dev`. This implementation
377 // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
378 // When this option is used, the token passed to `std::random_device`'s
379 // constructor *must* be "/dev/urandom" -- anything else is an error.
381 // _LIBCPP_USING_WIN32_RANDOM
382 // Use rand_s(), for use on Windows.
383 // When this option is used, the token passed to `std::random_device`'s
384 // constructor *must* be "/dev/urandom" -- anything else is an error.
385 #if defined(__OpenBSD__) || defined(__APPLE__)
386 # define _LIBCPP_USING_ARC4_RANDOM
387 #elif defined(__wasi__)
388 # define _LIBCPP_USING_GETENTROPY
389 #elif defined(__Fuchsia__)
390 # define _LIBCPP_USING_FUCHSIA_CPRNG
391 #elif defined(__native_client__)
392 # define _LIBCPP_USING_NACL_RANDOM
393 #elif defined(_LIBCPP_WIN32API)
394 # define _LIBCPP_USING_WIN32_RANDOM
396 # define _LIBCPP_USING_DEV_RANDOM
399 #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
401 # if __BYTE_ORDER == __LITTLE_ENDIAN
402 # define _LIBCPP_LITTLE_ENDIAN
403 # elif __BYTE_ORDER == __BIG_ENDIAN
404 # define _LIBCPP_BIG_ENDIAN
405 # else // __BYTE_ORDER == __BIG_ENDIAN
406 # error unable to determine endian
408 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
410 #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
411 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
413 # define _LIBCPP_NO_CFI
416 // If the compiler supports using_if_exists, pretend we have those functions and they'll
417 // be picked up if the C library provides them.
419 // TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
420 // for platforms that don't have a conforming C11 library, so we can drop this whole thing.
421 #if __has_attribute(using_if_exists)
422 # define _LIBCPP_HAS_TIMESPEC_GET
423 # define _LIBCPP_HAS_QUICK_EXIT
424 # define _LIBCPP_HAS_ALIGNED_ALLOC
426 #if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
427 # if defined(__FreeBSD__)
428 # define _LIBCPP_HAS_ALIGNED_ALLOC
429 # define _LIBCPP_HAS_QUICK_EXIT
430 # if __FreeBSD_version >= 1300064 || \
431 (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
432 # define _LIBCPP_HAS_TIMESPEC_GET
434 # elif defined(__BIONIC__)
435 # if __ANDROID_API__ >= 21
436 # define _LIBCPP_HAS_QUICK_EXIT
438 # if __ANDROID_API__ >= 28
439 # define _LIBCPP_HAS_ALIGNED_ALLOC
441 # if __ANDROID_API__ >= 29
442 # define _LIBCPP_HAS_TIMESPEC_GET
444 # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
445 # define _LIBCPP_HAS_ALIGNED_ALLOC
446 # define _LIBCPP_HAS_QUICK_EXIT
447 # define _LIBCPP_HAS_TIMESPEC_GET
448 # elif defined(__OpenBSD__)
449 # define _LIBCPP_HAS_ALIGNED_ALLOC
450 # define _LIBCPP_HAS_TIMESPEC_GET
451 # elif defined(__linux__)
452 # if !defined(_LIBCPP_HAS_MUSL_LIBC)
453 # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
454 # define _LIBCPP_HAS_QUICK_EXIT
456 # if _LIBCPP_GLIBC_PREREQ(2, 17)
457 # define _LIBCPP_HAS_ALIGNED_ALLOC
458 # define _LIBCPP_HAS_TIMESPEC_GET
460 # else // defined(_LIBCPP_HAS_MUSL_LIBC)
461 # define _LIBCPP_HAS_ALIGNED_ALLOC
462 # define _LIBCPP_HAS_QUICK_EXIT
463 # define _LIBCPP_HAS_TIMESPEC_GET
465 # elif defined(_LIBCPP_MSVCRT)
466 // Using Microsoft's C Runtime library, not MinGW
467 # define _LIBCPP_HAS_TIMESPEC_GET
468 # elif defined(__APPLE__)
469 // timespec_get and aligned_alloc were introduced in macOS 10.15 and
471 # if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
472 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
473 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
474 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
475 # define _LIBCPP_HAS_ALIGNED_ALLOC
476 # define _LIBCPP_HAS_TIMESPEC_GET
480 #endif // __has_attribute(using_if_exists)
482 #ifndef _LIBCPP_CXX03_LANG
483 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
484 #elif defined(_LIBCPP_COMPILER_CLANG_BASED)
485 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
487 # error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
490 #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
492 #if defined(_LIBCPP_COMPILER_CLANG_BASED)
494 #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
495 # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
497 #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
498 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
499 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
502 #if __has_feature(cxx_alignas)
503 # define _ALIGNAS_TYPE(x) alignas(x)
504 # define _ALIGNAS(x) alignas(x)
506 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
507 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
510 #if __cplusplus < 201103L
511 typedef __char16_t char16_t;
512 typedef __char32_t char32_t;
515 #if !__has_feature(cxx_exceptions)
516 # define _LIBCPP_NO_EXCEPTIONS
519 #if !(__has_feature(cxx_strong_enums))
520 #define _LIBCPP_HAS_NO_STRONG_ENUMS
523 #if __has_feature(cxx_attributes)
524 # define _LIBCPP_NORETURN [[noreturn]]
526 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
529 #if !(__has_feature(cxx_nullptr))
530 # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
531 # define nullptr __nullptr
533 # define _LIBCPP_HAS_NO_NULLPTR
537 // Objective-C++ features (opt-in)
538 #if __has_feature(objc_arc)
539 #define _LIBCPP_HAS_OBJC_ARC
542 #if __has_feature(objc_arc_weak)
543 #define _LIBCPP_HAS_OBJC_ARC_WEAK
546 #if __has_extension(blocks)
547 # define _LIBCPP_HAS_EXTENSION_BLOCKS
550 #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
551 # define _LIBCPP_HAS_BLOCKS_RUNTIME
554 #if !(__has_feature(cxx_noexcept))
555 #define _LIBCPP_HAS_NO_NOEXCEPT
558 #if !__has_feature(address_sanitizer)
559 #define _LIBCPP_HAS_NO_ASAN
562 // Allow for build-time disabling of unsigned integer sanitization
563 #if __has_attribute(no_sanitize)
564 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
567 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
569 #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
571 #elif defined(_LIBCPP_COMPILER_GCC)
573 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
574 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
576 #define _LIBCPP_NORETURN __attribute__((noreturn))
578 #if !defined(__EXCEPTIONS)
579 # define _LIBCPP_NO_EXCEPTIONS
582 #if !defined(__SANITIZE_ADDRESS__)
583 #define _LIBCPP_HAS_NO_ASAN
586 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
588 #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
590 #elif defined(_LIBCPP_COMPILER_MSVC)
592 #define _LIBCPP_TOSTRING2(x) #x
593 #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
594 #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
597 #error "MSVC versions prior to Visual Studio 2015 are not supported"
600 #define __alignof__ __alignof
601 #define _LIBCPP_NORETURN __declspec(noreturn)
602 #define _ALIGNAS(x) __declspec(align(x))
603 #define _ALIGNAS_TYPE(x) alignas(x)
607 #define _LIBCPP_HAS_NO_ASAN
609 #define _LIBCPP_ALWAYS_INLINE __forceinline
611 #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
613 #define _LIBCPP_DISABLE_EXTENSION_WARNING
615 #elif defined(_LIBCPP_COMPILER_IBM)
617 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
618 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
619 #define _ATTRIBUTE(x) __attribute__((x))
620 #define _LIBCPP_NORETURN __attribute__((noreturn))
622 #define _LIBCPP_HAS_NO_UNICODE_CHARS
625 #define __MULTILOCALE_API
628 #define _LIBCPP_HAS_NO_ASAN
630 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
632 #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
634 #define _LIBCPP_DISABLE_EXTENSION_WARNING
636 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
638 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
641 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
643 # define _LIBCPP_CRT_FUNC
646 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
647 # define _LIBCPP_DLL_VIS
648 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
649 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
650 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
651 # define _LIBCPP_EXPORTED_FROM_ABI
652 #elif defined(_LIBCPP_BUILDING_LIBRARY)
653 # define _LIBCPP_DLL_VIS __declspec(dllexport)
654 # if defined(__MINGW32__)
655 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
656 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
658 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
659 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
661 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
662 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
664 # define _LIBCPP_DLL_VIS __declspec(dllimport)
665 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
666 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
667 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
668 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
671 #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
672 #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
673 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
674 #define _LIBCPP_HIDDEN
675 #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
676 #define _LIBCPP_TEMPLATE_VIS
677 #define _LIBCPP_TEMPLATE_DATA_VIS
678 #define _LIBCPP_ENUM_VIS
680 #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
682 #ifndef _LIBCPP_HIDDEN
683 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
684 # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
686 # define _LIBCPP_HIDDEN
690 #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
691 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
692 // The inline should be removed once PR32114 is resolved
693 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
695 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
699 #ifndef _LIBCPP_FUNC_VIS
700 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
701 # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
703 # define _LIBCPP_FUNC_VIS
707 #ifndef _LIBCPP_TYPE_VIS
708 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
709 # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
711 # define _LIBCPP_TYPE_VIS
715 #ifndef _LIBCPP_TEMPLATE_VIS
716 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
717 # if __has_attribute(__type_visibility__)
718 # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
720 # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
723 # define _LIBCPP_TEMPLATE_VIS
727 #ifndef _LIBCPP_TEMPLATE_DATA_VIS
728 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
729 # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
731 # define _LIBCPP_TEMPLATE_DATA_VIS
735 #ifndef _LIBCPP_EXPORTED_FROM_ABI
736 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
737 # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
739 # define _LIBCPP_EXPORTED_FROM_ABI
743 #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
744 #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
747 #ifndef _LIBCPP_EXCEPTION_ABI
748 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
749 # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
751 # define _LIBCPP_EXCEPTION_ABI
755 #ifndef _LIBCPP_ENUM_VIS
756 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
757 # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
759 # define _LIBCPP_ENUM_VIS
763 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
764 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
765 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
767 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
771 #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
772 #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
775 #if __has_attribute(internal_linkage)
776 # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
778 # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
781 #if __has_attribute(exclude_from_explicit_instantiation)
782 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
784 // Try to approximate the effect of exclude_from_explicit_instantiation
785 // (which is that entities are not assumed to be provided by explicit
786 // template instantiations in the dylib) by always inlining those entities.
787 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
790 #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
791 # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
792 # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
794 # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
798 #ifndef _LIBCPP_HIDE_FROM_ABI
799 # if _LIBCPP_HIDE_FROM_ABI_PER_TU
800 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
802 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
806 #ifdef _LIBCPP_BUILDING_LIBRARY
807 # if _LIBCPP_ABI_VERSION > 1
808 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
810 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
813 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
816 // Just so we can migrate to the new macros gradually.
817 #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
819 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
820 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
821 #define _LIBCPP_END_NAMESPACE_STD } }
822 #define _VSTD std::_LIBCPP_ABI_NAMESPACE
823 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
825 #if _LIBCPP_STD_VER >= 17
826 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
827 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
829 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
830 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
833 #define _LIBCPP_END_NAMESPACE_FILESYSTEM \
834 _LIBCPP_END_NAMESPACE_STD } }
836 #define _VSTD_FS _VSTD::__fs::filesystem
838 #if __has_attribute(__enable_if__)
839 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
842 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
843 # define _NOEXCEPT noexcept
844 # define _NOEXCEPT_(x) noexcept(x)
846 # define _NOEXCEPT throw()
847 # define _NOEXCEPT_(x)
850 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
851 typedef unsigned short char16_t;
852 typedef unsigned int char32_t;
855 #ifndef __SIZEOF_INT128__
856 #define _LIBCPP_HAS_NO_INT128
859 #ifdef _LIBCPP_CXX03_LANG
860 # define static_assert(...) _Static_assert(__VA_ARGS__)
861 # define decltype(...) __decltype(__VA_ARGS__)
862 #endif // _LIBCPP_CXX03_LANG
864 #ifdef _LIBCPP_CXX03_LANG
865 # define _LIBCPP_CONSTEXPR
867 # define _LIBCPP_CONSTEXPR constexpr
870 #ifndef __cpp_consteval
871 # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
873 # define _LIBCPP_CONSTEVAL consteval
876 #if !defined(__cpp_concepts) || __cpp_concepts < 201907L
877 #define _LIBCPP_HAS_NO_CONCEPTS
880 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS)
881 #define _LIBCPP_HAS_NO_RANGES
885 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
887 # define _LIBCPP_NOALIAS
890 #if __has_attribute(using_if_exists)
891 # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
893 # define _LIBCPP_USING_IF_EXISTS
896 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
897 # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
898 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
900 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
901 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
902 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
904 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
905 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
906 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
907 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
909 // _LIBCPP_DEBUG potential values:
910 // - undefined: No assertions. This is the default.
911 // - 0: Basic assertions
912 // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
913 # if !defined(_LIBCPP_DEBUG)
914 # define _LIBCPP_DEBUG_LEVEL 0
915 # elif _LIBCPP_DEBUG == 0
916 # define _LIBCPP_DEBUG_LEVEL 1
917 # elif _LIBCPP_DEBUG == 1
918 # define _LIBCPP_DEBUG_LEVEL 2
920 # error Supported values for _LIBCPP_DEBUG are 0 and 1
923 # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
924 # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
927 # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
928 # if defined(_LIBCPP_CXX03_LANG)
929 # error Support for unspecified stability is only for C++11 and higher
931 # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
933 if (!__builtin_is_constant_evaluated()) \
934 _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
937 # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
942 // Libc++ allows disabling extern template instantiation declarations by
943 // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
945 // Furthermore, when the Debug mode is enabled, we disable extern declarations
946 // when building user code because we don't want to use the functions compiled
947 // in the library, which might not have had the debug mode enabled when built.
948 // However, some extern declarations need to be used, because code correctness
949 // depends on it (several instances in <locale>). Those special declarations
950 // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
951 // even when the debug mode is enabled.
952 #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
953 # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
954 # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
955 #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
956 # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
957 # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
959 # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
960 # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
963 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
964 defined(__sun__) || defined(__NetBSD__)
965 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
969 #define _DECLARE_C99_LDBL_MATH 1
972 // If we are getting operator new from the MSVC CRT, then allocation overloads
973 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
974 #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
975 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
976 #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
977 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
978 // have it unless the language feature test macro is defined.
979 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
980 #elif defined(__MVS__)
981 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
984 #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
985 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
986 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
989 #if defined(__APPLE__) || defined(__FreeBSD__)
990 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
993 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
994 #define _LIBCPP_WCTYPE_IS_MASK
997 #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
998 #define _LIBCPP_HAS_NO_CHAR8_T
1001 // Deprecation macros.
1003 // Deprecations warnings are always enabled, except when users explicitly opt-out
1004 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
1005 #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
1006 # if __has_attribute(deprecated)
1007 # define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
1008 # elif _LIBCPP_STD_VER > 11
1009 # define _LIBCPP_DEPRECATED [[deprecated]]
1011 # define _LIBCPP_DEPRECATED
1014 # define _LIBCPP_DEPRECATED
1017 #if !defined(_LIBCPP_CXX03_LANG)
1018 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
1020 # define _LIBCPP_DEPRECATED_IN_CXX11
1023 #if _LIBCPP_STD_VER >= 14
1024 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
1026 # define _LIBCPP_DEPRECATED_IN_CXX14
1029 #if _LIBCPP_STD_VER >= 17
1030 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
1032 # define _LIBCPP_DEPRECATED_IN_CXX17
1035 #if _LIBCPP_STD_VER > 17
1036 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
1038 # define _LIBCPP_DEPRECATED_IN_CXX20
1041 #if !defined(_LIBCPP_HAS_NO_CHAR8_T)
1042 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
1044 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
1047 // Macros to enter and leave a state where deprecation warnings are suppressed.
1048 #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
1049 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
1050 _Pragma("GCC diagnostic push") \
1051 _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
1052 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1053 # define _LIBCPP_SUPPRESS_DEPRECATED_POP \
1054 _Pragma("GCC diagnostic pop")
1056 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1057 # define _LIBCPP_SUPPRESS_DEPRECATED_POP
1060 #if _LIBCPP_STD_VER <= 11
1061 # define _LIBCPP_EXPLICIT_AFTER_CXX11
1063 # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
1066 #if _LIBCPP_STD_VER > 11
1067 # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
1069 # define _LIBCPP_CONSTEXPR_AFTER_CXX11
1072 #if _LIBCPP_STD_VER > 14
1073 # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
1075 # define _LIBCPP_CONSTEXPR_AFTER_CXX14
1078 #if _LIBCPP_STD_VER > 17
1079 # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
1081 # define _LIBCPP_CONSTEXPR_AFTER_CXX17
1084 #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1085 # define _LIBCPP_NODISCARD [[nodiscard]]
1086 #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
1087 # define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
1089 // We can't use GCC's [[gnu::warn_unused_result]] and
1090 // __attribute__((warn_unused_result)), because GCC does not silence them via
1092 # define _LIBCPP_NODISCARD
1095 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1096 // specified as such as an extension.
1097 #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1098 # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1100 # define _LIBCPP_NODISCARD_EXT
1103 #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1104 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1105 # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1107 # define _LIBCPP_NODISCARD_AFTER_CXX17
1110 #if __has_attribute(no_destroy)
1111 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1113 # define _LIBCPP_NO_DESTROY
1116 #ifndef _LIBCPP_HAS_NO_ASAN
1117 extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
1118 const void *, const void *, const void *, const void *);
1121 // Try to find out if RTTI is disabled.
1122 #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
1123 # define _LIBCPP_NO_RTTI
1124 #elif defined(__GNUC__) && !defined(__GXX_RTTI)
1125 # define _LIBCPP_NO_RTTI
1126 #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
1127 # define _LIBCPP_NO_RTTI
1130 #ifndef _LIBCPP_WEAK
1131 #define _LIBCPP_WEAK __attribute__((__weak__))
1135 #if !defined(_LIBCPP_HAS_NO_THREADS) && \
1136 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1137 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1138 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1139 # if defined(__FreeBSD__) || \
1140 defined(__wasi__) || \
1141 defined(__NetBSD__) || \
1142 defined(__OpenBSD__) || \
1143 defined(__NuttX__) || \
1144 defined(__linux__) || \
1145 defined(__GNU__) || \
1146 defined(__APPLE__) || \
1147 defined(__sun__) || \
1148 defined(__MVS__) || \
1150 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1151 # elif defined(__Fuchsia__)
1152 // TODO(44575): Switch to C11 thread API when possible.
1153 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1154 # elif defined(_LIBCPP_WIN32API)
1155 # define _LIBCPP_HAS_THREAD_API_WIN32
1157 # error "No thread API"
1158 # endif // _LIBCPP_HAS_THREAD_API
1159 #endif // _LIBCPP_HAS_NO_THREADS
1161 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1162 #if defined(__ANDROID__) && __ANDROID_API__ >= 30
1163 #define _LIBCPP_HAS_COND_CLOCKWAIT
1164 #elif defined(_LIBCPP_GLIBC_PREREQ)
1165 #if _LIBCPP_GLIBC_PREREQ(2, 30)
1166 #define _LIBCPP_HAS_COND_CLOCKWAIT
1171 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1172 #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1173 _LIBCPP_HAS_NO_THREADS is not defined.
1176 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1177 #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1178 _LIBCPP_HAS_NO_THREADS is defined.
1181 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1182 #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1183 _LIBCPP_HAS_NO_THREADS is defined.
1186 #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1187 #define __STDCPP_THREADS__ 1
1190 // The glibc and Bionic implementation of pthreads implements
1191 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1192 // mutexes have no destroy mechanism.
1194 // This optimization can't be performed on Apple platforms, where
1195 // pthread_mutex_destroy can allow the kernel to release resources.
1196 // See https://llvm.org/D64298 for details.
1198 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
1199 // respective stakeholders.
1200 #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1201 || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
1202 || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1203 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1206 // Destroying a condvar is a nop on Windows.
1208 // This optimization can't be performed on Apple platforms, where
1209 // pthread_cond_destroy can allow the kernel to release resources.
1210 // See https://llvm.org/D64298 for details.
1212 // TODO(EricWF): This is potentially true for some pthread implementations
1214 #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1215 defined(_LIBCPP_HAS_THREAD_API_WIN32)
1216 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1219 // Some systems do not provide gets() in their C library, for security reasons.
1220 #if defined(_LIBCPP_MSVCRT) || \
1221 (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
1222 defined(__OpenBSD__)
1223 # define _LIBCPP_C_HAS_NO_GETS
1226 #if defined(__BIONIC__) || defined(__NuttX__) || \
1227 defined(__Fuchsia__) || defined(__wasi__) || \
1228 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1229 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1232 #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1233 # define _LIBCPP_HAS_C_ATOMIC_IMP
1234 #elif defined(_LIBCPP_COMPILER_GCC)
1235 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
1238 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1239 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1240 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1241 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
1243 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1244 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
1246 # ifdef _LIBCPP_FREESTANDING
1247 # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1251 #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1252 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1255 #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1256 # if defined(__clang__) && __has_attribute(acquire_capability)
1257 // Work around the attribute handling in clang. When both __declspec and
1258 // __attribute__ are present, the processing goes awry preventing the definition
1260 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1261 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1266 #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1267 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1269 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1272 #if __has_attribute(require_constant_initialization)
1273 # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1275 # define _LIBCPP_SAFE_STATIC
1278 #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1279 # define _LIBCPP_DIAGNOSE_WARNING(...) \
1280 __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1281 # define _LIBCPP_DIAGNOSE_ERROR(...) \
1282 __attribute__((diagnose_if(__VA_ARGS__, "error")))
1284 # define _LIBCPP_DIAGNOSE_WARNING(...)
1285 # define _LIBCPP_DIAGNOSE_ERROR(...)
1288 // Use a function like macro to imply that it must be followed by a semicolon
1289 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1290 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1291 #elif __has_cpp_attribute(clang::fallthrough)
1292 # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1293 #elif __has_attribute(__fallthrough__)
1294 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1296 # define _LIBCPP_FALLTHROUGH() ((void)0)
1299 #if __has_attribute(__nodebug__)
1300 #define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1302 #define _LIBCPP_NODEBUG
1305 #if __has_attribute(__standalone_debug__)
1306 #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1308 #define _LIBCPP_STANDALONE_DEBUG
1311 #if __has_attribute(__preferred_name__)
1312 #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1314 #define _LIBCPP_PREFERRED_NAME(x)
1317 // We often repeat things just for handling wide characters in the library.
1318 // When wide characters are disabled, it can be useful to have a quick way of
1319 // disabling it without having to resort to #if-#endif, which has a larger
1320 // impact on readability.
1321 #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1322 # define _LIBCPP_IF_WIDE_CHARACTERS(...)
1324 # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1327 #if defined(_LIBCPP_ABI_MICROSOFT) && \
1328 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1329 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1331 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1334 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1335 #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1336 #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1337 #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1338 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1339 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1341 #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1342 #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1343 #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1344 #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1345 #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1346 #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1347 #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1349 #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
1350 #define _LIBCPP_HAS_NO_CXX20_COROUTINES
1353 #if defined(_LIBCPP_COMPILER_IBM)
1354 #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1357 #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1358 # define _LIBCPP_PUSH_MACROS
1359 # define _LIBCPP_POP_MACROS
1361 // Don't warn about macro conflicts when we can restore them at the
1362 // end of the header.
1363 # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1364 # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1366 # if defined(_LIBCPP_COMPILER_MSVC)
1367 # define _LIBCPP_PUSH_MACROS \
1368 __pragma(push_macro("min")) \
1369 __pragma(push_macro("max"))
1370 # define _LIBCPP_POP_MACROS \
1371 __pragma(pop_macro("min")) \
1372 __pragma(pop_macro("max"))
1374 # define _LIBCPP_PUSH_MACROS \
1375 _Pragma("push_macro(\"min\")") \
1376 _Pragma("push_macro(\"max\")")
1377 # define _LIBCPP_POP_MACROS \
1378 _Pragma("pop_macro(\"min\")") \
1379 _Pragma("pop_macro(\"max\")")
1381 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1383 #ifndef _LIBCPP_NO_AUTO_LINK
1384 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1385 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1386 # pragma comment(lib, "c++.lib")
1388 # pragma comment(lib, "libc++.lib")
1390 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1391 #endif // _LIBCPP_NO_AUTO_LINK
1393 // Configures the fopen close-on-exec mode character, if any. This string will
1394 // be appended to any mode string used by fstream for fopen/fdopen.
1396 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
1398 #if defined(__BIONIC__)
1399 # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1401 # define _LIBCPP_FOPEN_CLOEXEC_MODE
1404 // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1405 // of functions used in cstdio may not be available for low API levels when
1406 // using 64-bit file offsets on LP32.
1407 #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1408 #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1411 #if __has_attribute(init_priority)
1412 // TODO: Remove this once we drop support for building libc++ with old Clangs
1413 # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
1414 (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
1415 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1417 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
1420 # define _LIBCPP_INIT_PRIORITY_MAX
1423 #if defined(__GNUC__) || defined(__clang__)
1424 // The attribute uses 1-based indices for ordinary and static member functions.
1425 // The attribute uses 2-based indices for non-static member functions.
1426 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1427 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1429 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1432 #endif // __cplusplus
1434 #endif // _LIBCPP_CONFIG