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 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16 # pragma GCC system_header
19 #if defined(__apple_build_version__)
20 // Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
21 # define _LIBCPP_COMPILER_CLANG_BASED
22 # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
23 #elif defined(__clang__)
24 # define _LIBCPP_COMPILER_CLANG_BASED
25 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
26 #elif defined(__GNUC__)
27 # define _LIBCPP_COMPILER_GCC
28 # define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
33 // Warn if a compiler version is used that is not supported anymore
34 // LLVM RELEASE Update the minimum compiler versions
35 # if defined(_LIBCPP_CLANG_VER)
36 # if _LIBCPP_CLANG_VER < 1500
37 # warning "Libc++ only supports Clang 15 and later"
39 # elif defined(_LIBCPP_APPLE_CLANG_VER)
40 # if _LIBCPP_APPLE_CLANG_VER < 1500
41 # warning "Libc++ only supports AppleClang 15 and later"
43 # elif defined(_LIBCPP_GCC_VER)
44 # if _LIBCPP_GCC_VER < 1300
45 # warning "Libc++ only supports GCC 13 and later"
49 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
51 // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
52 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
54 # define _LIBCPP_VERSION 180000
56 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
57 # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
59 # if __STDC_HOSTED__ == 0
60 # define _LIBCPP_FREESTANDING
63 // NOLINTBEGIN(libcpp-cpp-version-check)
64 # ifndef _LIBCPP_STD_VER
65 # if __cplusplus <= 201103L
66 # define _LIBCPP_STD_VER 11
67 # elif __cplusplus <= 201402L
68 # define _LIBCPP_STD_VER 14
69 # elif __cplusplus <= 201703L
70 # define _LIBCPP_STD_VER 17
71 # elif __cplusplus <= 202002L
72 # define _LIBCPP_STD_VER 20
73 # elif __cplusplus <= 202302L
74 # define _LIBCPP_STD_VER 23
76 // Expected release year of the next C++ standard
77 # define _LIBCPP_STD_VER 26
79 # endif // _LIBCPP_STD_VER
80 // NOLINTEND(libcpp-cpp-version-check)
83 # define _LIBCPP_OBJECT_FORMAT_ELF 1
84 # elif defined(__MACH__)
85 # define _LIBCPP_OBJECT_FORMAT_MACHO 1
86 # elif defined(_WIN32)
87 # define _LIBCPP_OBJECT_FORMAT_COFF 1
88 # elif defined(__wasm__)
89 # define _LIBCPP_OBJECT_FORMAT_WASM 1
91 # define _LIBCPP_OBJECT_FORMAT_XCOFF 1
93 // ... add new file formats here ...
98 # if _LIBCPP_ABI_VERSION >= 2
99 // Change short string representation so that string data starts at offset 0,
100 // improving its alignment in some cases.
101 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
102 // Fix deque iterator type in order to support incomplete types.
103 # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
104 // Fix undefined behavior in how std::list stores its linked nodes.
105 # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
106 // Fix undefined behavior in how __tree stores its end and parent nodes.
107 # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
108 // Fix undefined behavior in how __hash_table stores its pointer types.
109 # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
110 # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
111 # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
112 // Define a key function for `bad_function_call` in the library, to centralize
113 // its vtable and typeinfo to libc++ rather than having all other libraries
114 // using that class define their own copies.
115 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
116 // Override the default return value of exception::what() for
117 // bad_function_call::what() with a string that is specific to
118 // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
119 // because it changes the vtable layout of bad_function_call.
120 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
121 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
122 # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
123 // Give reverse_iterator<T> one data member of type T, not two.
124 // Also, in C++17 and later, don't derive iterator types from std::iterator.
125 # define _LIBCPP_ABI_NO_ITERATOR_BASES
126 // Use the smallest possible integer type to represent the index of the variant.
127 // Previously libc++ used "unsigned int" exclusively.
128 # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
129 // Unstable attempt to provide a more optimized std::function
130 # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
131 // All the regex constants must be distinct and nonzero.
132 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
133 // Re-worked external template instantiations for std::string with a focus on
134 // performance and fast-path inlining.
135 # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
136 // Enable clang::trivial_abi on std::unique_ptr.
137 # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
138 // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
139 # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
140 // std::random_device holds some state when it uses an implementation that gets
141 // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
142 // implementation to another one on a platform that has already shipped
143 // std::random_device, one needs to retain the same object layout to remain ABI
144 // compatible. This switch removes these workarounds for platforms that don't care
145 // about ABI compatibility.
146 # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
147 // Don't export the legacy __basic_string_common class and its methods from the built library.
148 # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
149 // Don't export the legacy __vector_base_common class and its methods from the built library.
150 # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
151 // According to the Standard, `bitset::operator[] const` returns bool
152 # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
153 // Fix the implementation of CityHash used for std::hash<fundamental-type>.
154 // This is an ABI break because `std::hash` will return a different result,
155 // which means that hashing the same object in translation units built against
156 // different versions of libc++ can return inconsistent results. This is especially
157 // tricky since std::hash is used in the implementation of unordered containers.
159 // The incorrect implementation of CityHash has the problem that it drops some
160 // bits on the floor.
161 # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
162 // Remove the base 10 implementation of std::to_chars from the dylib.
163 // The implementation moved to the header, but we still export the symbols from
164 // the dylib for backwards compatibility.
165 # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
166 // Save memory by providing the allocator more freedom to allocate the most
167 // efficient size class by dropping the alignment requirements for std::string's
168 // pointer from 16 to 8. This changes the output of std::string::max_size,
169 // which makes it ABI breaking
170 # define _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
171 # elif _LIBCPP_ABI_VERSION == 1
172 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
173 // Enable compiling copies of now inline methods into the dylib to support
174 // applications compiled against older libraries. This is unnecessary with
175 // COFF dllexport semantics, since dllexport forces a non-inline definition
176 // of inline functions to be emitted anyway. Our own non-inline copy would
177 // conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
178 // the linker will take issue with the symbols in the shared object if the
179 // weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
181 # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
183 // Feature macros for disabling pre ABI v1 features. All of these options
185 # if defined(__FreeBSD__) && __FreeBSD__ < 14
186 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
188 // For XCOFF linkers, we have problems if we see a weak hidden version of a symbol
189 // in user code (like you get with -fvisibility-inlines-hidden) and then a strong def
190 // in the library, so we need to always rely on the library version.
192 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
196 # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
197 // Define a key function for `bad_function_call` in the library, to centralize
198 // its vtable and typeinfo to libc++ rather than having all other libraries
199 // using that class define their own copies.
200 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
203 // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
204 // within the bounds of the original container and asserts it on every dereference.
206 // ABI impact: changes the iterator type of the relevant containers.
208 // Supported containers:
212 // #define _LIBCPP_ABI_BOUNDED_ITERATORS
218 // TODO(hardening): deprecate this in LLVM 19.
219 // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
220 // equivalent to setting the safe mode.
221 # ifdef _LIBCPP_ENABLE_ASSERTIONS
222 # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
223 # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
225 # if _LIBCPP_ENABLE_ASSERTIONS
226 # define _LIBCPP_ENABLE_SAFE_MODE 1
230 // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes
231 // security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with
232 // `_LIBCPP_ENABLE_SAFE_MODE` and `_LIBCPP_ENABLE_DEBUG_MODE`.
234 // #define _LIBCPP_ENABLE_HARDENED_MODE 1
236 // Enables the safe mode which extends the hardened mode with checks that are relatively cheap and prevent common types
237 // of errors but are not security-critical. Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE` and
238 // `_LIBCPP_ENABLE_DEBUG_MODE`.
240 // #define _LIBCPP_ENABLE_SAFE_MODE 1
242 // Enables the debug mode which contains all the checks from the hardened mode and additionally more expensive checks
243 // that may affect the complexity of algorithms. The debug mode is intended to be used for testing, not in production.
244 // Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE` and `_LIBCPP_ENABLE_SAFE_MODE`.
246 // #define _LIBCPP_ENABLE_DEBUG_MODE 1
248 // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These
249 // macros are only for internal use -- users should only pick one of the high-level hardening modes described above.
251 // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and
252 // a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid:
253 // - the sentinel is reachable from the begin iterator;
254 // - TODO(hardening): both iterators refer to the same container.
256 // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through
257 // the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access
258 // a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like
259 // `optional` and `function` are considered one-element containers for the purposes of this check.
261 // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
262 // given ranges do not overlap.
264 // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
265 // the containers have compatible allocators.
267 // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on
270 // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet.
272 # ifndef _LIBCPP_ENABLE_HARDENED_MODE
273 # define _LIBCPP_ENABLE_HARDENED_MODE _LIBCPP_ENABLE_HARDENED_MODE_DEFAULT
275 # if _LIBCPP_ENABLE_HARDENED_MODE != 0 && _LIBCPP_ENABLE_HARDENED_MODE != 1
276 # error "_LIBCPP_ENABLE_HARDENED_MODE must be set to 0 or 1."
279 # ifndef _LIBCPP_ENABLE_SAFE_MODE
280 # define _LIBCPP_ENABLE_SAFE_MODE _LIBCPP_ENABLE_SAFE_MODE_DEFAULT
282 # if _LIBCPP_ENABLE_SAFE_MODE != 0 && _LIBCPP_ENABLE_SAFE_MODE != 1
283 # error "_LIBCPP_ENABLE_SAFE_MODE must be set to 0 or 1."
286 # ifndef _LIBCPP_ENABLE_DEBUG_MODE
287 # define _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT
289 # if _LIBCPP_ENABLE_DEBUG_MODE != 0 && _LIBCPP_ENABLE_DEBUG_MODE != 1
290 # error "_LIBCPP_ENABLE_DEBUG_MODE must be set to 0 or 1."
293 # if (_LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_SAFE_MODE) || \
294 (_LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_DEBUG_MODE) || \
295 (_LIBCPP_ENABLE_SAFE_MODE && _LIBCPP_ENABLE_DEBUG_MODE)
297 "Only one of _LIBCPP_ENABLE_HARDENED_MODE, _LIBCPP_ENABLE_SAFE_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled."
301 // Hardened mode checks.
303 # if _LIBCPP_ENABLE_HARDENED_MODE
306 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
307 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
309 // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
311 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
312 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
313 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
314 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
318 # elif _LIBCPP_ENABLE_SAFE_MODE
321 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
322 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
323 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
324 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
325 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
327 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
329 // Debug mode checks.
331 # elif _LIBCPP_ENABLE_DEBUG_MODE
333 // All checks enabled.
334 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
335 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
336 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
337 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
338 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
339 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
341 // Disable all checks if hardening is not enabled.
345 // All checks disabled.
346 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression)
347 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression)
348 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
349 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
350 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
351 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
353 # endif // _LIBCPP_ENABLE_HARDENED_MODE
358 # define _LIBCPP_TOSTRING2(x) #x
359 # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
361 // NOLINTNEXTLINE(libcpp-cpp-version-check)
362 # if __cplusplus < 201103L
363 # define _LIBCPP_CXX03_LANG
366 # ifndef __has_attribute
367 # define __has_attribute(__x) 0
370 # ifndef __has_builtin
371 # define __has_builtin(__x) 0
374 # ifndef __has_extension
375 # define __has_extension(__x) 0
378 # ifndef __has_feature
379 # define __has_feature(__x) 0
382 # ifndef __has_cpp_attribute
383 # define __has_cpp_attribute(__x) 0
386 # ifndef __has_constexpr_builtin
387 # define __has_constexpr_builtin(x) 0
390 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
391 // the compiler and '1' otherwise.
392 # ifndef __is_identifier
393 # define __is_identifier(__x) 1
396 # ifndef __has_declspec_attribute
397 # define __has_declspec_attribute(__x) 0
400 # define __has_keyword(__x) !(__is_identifier(__x))
402 # ifndef __has_include
403 # define __has_include(...) 0
406 # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
407 # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
410 // FIXME: ABI detection should be done via compiler builtin macros. This
411 // is just a placeholder until Clang implements such macros. For now assume
412 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
413 // and allow the user to explicitly specify the ABI to handle cases where this
414 // heuristic falls short.
415 # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
416 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
417 # elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
418 # define _LIBCPP_ABI_ITANIUM
419 # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
420 # define _LIBCPP_ABI_MICROSOFT
422 # if defined(_WIN32) && defined(_MSC_VER)
423 # define _LIBCPP_ABI_MICROSOFT
425 # define _LIBCPP_ABI_ITANIUM
429 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
430 # define _LIBCPP_ABI_VCRUNTIME
433 # if __has_feature(experimental_library)
434 # ifndef _LIBCPP_ENABLE_EXPERIMENTAL
435 # define _LIBCPP_ENABLE_EXPERIMENTAL
439 // Incomplete features get their own specific disabling flags. This makes it
440 // easier to grep for target specific flags once the feature is complete.
441 # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
442 # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
443 # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
444 # define _LIBCPP_HAS_NO_INCOMPLETE_TZDB
447 // Need to detect which libc we're using if we're on Linux.
448 # if defined(__linux__)
449 # include <features.h>
450 # if defined(__GLIBC_PREREQ)
451 # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
453 # define _LIBCPP_GLIBC_PREREQ(a, b) 0
454 # endif // defined(__GLIBC_PREREQ)
455 # endif // defined(__linux__)
457 # if defined(__MVS__)
458 # include <features.h> // for __NATIVE_ASCII_F
461 # ifndef __BYTE_ORDER__
463 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
466 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
467 # define _LIBCPP_LITTLE_ENDIAN
468 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
469 # define _LIBCPP_BIG_ENDIAN
470 # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
473 # define _LIBCPP_WIN32API
474 # define _LIBCPP_SHORT_WCHAR 1
475 // Both MinGW and native MSVC provide a "MSVC"-like environment
476 # define _LIBCPP_MSVCRT_LIKE
477 // If mingw not explicitly detected, assume using MS C runtime only if
478 // a MS compatibility version is specified.
479 # if defined(_MSC_VER) && !defined(__MINGW32__)
480 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
482 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
483 # define _LIBCPP_HAS_BITSCAN64
485 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
486 # endif // defined(_WIN32)
488 # if defined(_AIX) && !defined(__64BIT__)
489 // The size of wchar is 2 byte on 32-bit mode on AIX.
490 # define _LIBCPP_SHORT_WCHAR 1
493 // Libc++ supports various implementations of std::random_device.
495 // _LIBCPP_USING_DEV_RANDOM
496 // Read entropy from the given file, by default `/dev/urandom`.
497 // If a token is provided, it is assumed to be the path to a file
498 // to read entropy from. This is the default behavior if nothing
499 // else is specified. This implementation requires storing state
500 // inside `std::random_device`.
502 // _LIBCPP_USING_ARC4_RANDOM
503 // Use arc4random(). This allows obtaining random data even when
504 // using sandboxing mechanisms. On some platforms like Apple, this
505 // is the recommended source of entropy for user-space programs.
506 // When this option is used, the token passed to `std::random_device`'s
507 // constructor *must* be "/dev/urandom" -- anything else is an error.
509 // _LIBCPP_USING_GETENTROPY
511 // When this option is used, the token passed to `std::random_device`'s
512 // constructor *must* be "/dev/urandom" -- anything else is an error.
514 // _LIBCPP_USING_FUCHSIA_CPRNG
515 // Use Fuchsia's zx_cprng_draw() system call, which is specified to
516 // deliver high-quality entropy and cannot fail.
517 // When this option is used, the token passed to `std::random_device`'s
518 // constructor *must* be "/dev/urandom" -- anything else is an error.
520 // _LIBCPP_USING_NACL_RANDOM
521 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
522 // including accesses to the special files under `/dev`. This implementation
523 // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
524 // When this option is used, the token passed to `std::random_device`'s
525 // constructor *must* be "/dev/urandom" -- anything else is an error.
527 // _LIBCPP_USING_WIN32_RANDOM
528 // Use rand_s(), for use on Windows.
529 // When this option is used, the token passed to `std::random_device`'s
530 // constructor *must* be "/dev/urandom" -- anything else is an error.
531 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
532 defined(__DragonFly__)
533 # define _LIBCPP_USING_ARC4_RANDOM
534 # elif defined(__wasi__) || defined(__EMSCRIPTEN__)
535 # define _LIBCPP_USING_GETENTROPY
536 # elif defined(__Fuchsia__)
537 # define _LIBCPP_USING_FUCHSIA_CPRNG
538 # elif defined(__native_client__)
539 # define _LIBCPP_USING_NACL_RANDOM
540 # elif defined(_LIBCPP_WIN32API)
541 # define _LIBCPP_USING_WIN32_RANDOM
543 # define _LIBCPP_USING_DEV_RANDOM
546 # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
547 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
549 # define _LIBCPP_NO_CFI
552 # ifndef _LIBCPP_CXX03_LANG
554 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
555 # define _ALIGNAS_TYPE(x) alignas(x)
556 # define _ALIGNAS(x) alignas(x)
557 # define _LIBCPP_NORETURN [[noreturn]]
558 # define _NOEXCEPT noexcept
559 # define _NOEXCEPT_(x) noexcept(x)
560 # define _LIBCPP_CONSTEXPR constexpr
564 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
565 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
566 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
567 # define _LIBCPP_NORETURN __attribute__((__noreturn__))
568 # define _LIBCPP_HAS_NO_NOEXCEPT
569 # define nullptr __nullptr
570 # define _NOEXCEPT throw()
571 # define _NOEXCEPT_(x)
572 # define static_assert(...) _Static_assert(__VA_ARGS__)
573 # define decltype(...) __decltype(__VA_ARGS__)
574 # define _LIBCPP_CONSTEXPR
576 typedef __char16_t char16_t;
577 typedef __char32_t char32_t;
581 # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
582 # define _LIBCPP_HAS_NO_EXCEPTIONS
585 # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
587 # if defined(_LIBCPP_COMPILER_CLANG_BASED)
589 # if defined(__APPLE__)
590 # if defined(__i386__) || defined(__x86_64__)
591 // use old string layout on x86_64 and i386
592 # elif defined(__arm__)
593 // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs
594 # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2
595 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
598 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
602 // Objective-C++ features (opt-in)
603 # if __has_feature(objc_arc)
604 # define _LIBCPP_HAS_OBJC_ARC
607 # if __has_feature(objc_arc_weak)
608 # define _LIBCPP_HAS_OBJC_ARC_WEAK
611 # if __has_extension(blocks)
612 # define _LIBCPP_HAS_EXTENSION_BLOCKS
615 # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
616 # define _LIBCPP_HAS_BLOCKS_RUNTIME
619 # if !__has_feature(address_sanitizer)
620 # define _LIBCPP_HAS_NO_ASAN
623 // Allow for build-time disabling of unsigned integer sanitization
624 # if __has_attribute(no_sanitize)
625 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
628 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
630 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
632 # elif defined(_LIBCPP_COMPILER_GCC)
634 # if !defined(__SANITIZE_ADDRESS__)
635 # define _LIBCPP_HAS_NO_ASAN
638 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
640 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
642 # endif // _LIBCPP_COMPILER_[CLANG|GCC]
644 # if defined(_LIBCPP_OBJECT_FORMAT_COFF)
647 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
649 # define _LIBCPP_CRT_FUNC
652 # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
653 # define _LIBCPP_DLL_VIS
654 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
655 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
656 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
657 # define _LIBCPP_EXPORTED_FROM_ABI
658 # elif defined(_LIBCPP_BUILDING_LIBRARY)
659 # define _LIBCPP_DLL_VIS __declspec(dllexport)
660 # if defined(__MINGW32__)
661 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
662 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
664 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
665 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
667 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
668 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
670 # define _LIBCPP_DLL_VIS __declspec(dllimport)
671 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
672 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
673 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
674 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
677 # define _LIBCPP_HIDDEN
678 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
679 # define _LIBCPP_TEMPLATE_VIS
680 # define _LIBCPP_TEMPLATE_DATA_VIS
681 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT
685 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
686 # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
688 # define _LIBCPP_VISIBILITY(vis)
691 # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
692 # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
693 # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
694 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
695 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
697 // TODO: Make this a proper customization point or remove the option to override it.
698 # ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
699 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
702 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
703 // The inline should be removed once PR32114 is resolved
704 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
706 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
709 // GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates
710 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__)
711 # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
713 # define _LIBCPP_TEMPLATE_VIS
716 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
717 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default")))
719 # define _LIBCPP_TYPE_VISIBILITY_DEFAULT
722 # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
724 # if __has_attribute(exclude_from_explicit_instantiation)
725 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
727 // Try to approximate the effect of exclude_from_explicit_instantiation
728 // (which is that entities are not assumed to be provided by explicit
729 // template instantiations in the dylib) by always inlining those entities.
730 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
733 # if _LIBCPP_ENABLE_HARDENED_MODE
734 # define _LIBCPP_HARDENING_SIG h
735 # elif _LIBCPP_ENABLE_SAFE_MODE
736 # define _LIBCPP_HARDENING_SIG s
737 # elif _LIBCPP_ENABLE_DEBUG_MODE
738 # define _LIBCPP_HARDENING_SIG d
740 # define _LIBCPP_HARDENING_SIG u // for unchecked
743 # ifdef _LIBCPP_HAS_NO_EXCEPTIONS
744 # define _LIBCPP_EXCEPTIONS_SIG n
746 # define _LIBCPP_EXCEPTIONS_SIG e
749 # define _LIBCPP_ODR_SIGNATURE \
750 _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
752 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
754 // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
755 // symbols from their dynamic library by means of using the libc++ headers. This ensures
756 // that those symbols stay private to the dynamic library in which it is defined.
758 // 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
759 // This ensures that no ODR violation can arise from mixing two TUs compiled with different
760 // versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
761 // program contains two definitions of a function, the ODR requires them to be token-by-token
762 // equivalent, and the linker is allowed to pick either definition and discard the other one.
764 // For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
765 // *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
766 // compiled with different settings), the two definitions are both visible by the linker and they
767 // have the same name, but they have a meaningfully different implementation (one throws an exception
768 // and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
769 // practice what will happen is that the linker will pick one of the definitions at random and will
770 // discard the other one. This can quite clearly lead to incorrect program behavior.
772 // A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
773 // property that causes the code of a function to differ from the code in another configuration
774 // can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
775 // tag, but we encode the ones that we think are most important: library version, exceptions, and
778 // Note that historically, solving this problem has been achieved in various ways, including
779 // force-inlining all functions or giving internal linkage to all functions. Both these previous
780 // solutions suffer from drawbacks that lead notably to code bloat.
782 // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
783 // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
785 // Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
786 // instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
787 // name of a virtual function is part of its ABI, since some architectures like arm64e can sign
788 // the virtual function pointer in the vtable based on the mangled name of the function. Since
789 // we use an ABI tag that changes with each released version, the mangled name of the virtual
790 // function would change, which is incorrect. Note that it doesn't make much sense to change
791 // the implementation of a virtual function in an ABI-incompatible way in the first place,
792 // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
794 // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
795 // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
796 // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
797 # ifndef _LIBCPP_NO_ABI_TAG
798 # define _LIBCPP_HIDE_FROM_ABI \
799 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
800 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
802 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
804 # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
806 // This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
807 // "C" function, as those lack mangling.
808 # define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
810 # ifdef _LIBCPP_BUILDING_LIBRARY
811 # if _LIBCPP_ABI_VERSION > 1
812 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
814 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
817 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
820 // Just so we can migrate to the new macros gradually.
821 # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
823 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
825 # define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
826 inline namespace _LIBCPP_ABI_NAMESPACE {
827 # define _LIBCPP_END_NAMESPACE_STD }}
830 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
832 # if _LIBCPP_STD_VER >= 17
833 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
834 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
836 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
837 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
840 # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
843 # define _VSTD_FS std::__fs::filesystem
845 # if __has_attribute(__enable_if__)
846 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
849 # if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
850 # define _LIBCPP_HAS_NO_INT128
853 # if __has_attribute(__malloc__)
854 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
856 # define _LIBCPP_NOALIAS
859 # if __has_attribute(__using_if_exists__)
860 # define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
862 # define _LIBCPP_USING_IF_EXISTS
865 # ifdef _LIBCPP_CXX03_LANG
866 # define _LIBCPP_DECLARE_STRONG_ENUM(x) \
867 struct _LIBCPP_EXPORTED_FROM_ABI x { \
870 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
872 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
873 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
874 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
878 # else // _LIBCPP_CXX03_LANG
879 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
880 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
881 # endif // _LIBCPP_CXX03_LANG
883 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
884 # define _LIBCPP_LOCALE__L_EXTENSIONS 1
888 # define _DECLARE_C99_LDBL_MATH 1
891 // If we are getting operator new from the MSVC CRT, then allocation overloads
892 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
893 # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
894 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
895 # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
896 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
897 // have it unless the language feature test macro is defined.
898 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
899 # elif defined(__MVS__)
900 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
903 # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
904 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
907 // It is not yet possible to use aligned_alloc() on all Apple platforms since
908 // 10.15 was the first version to ship an implementation of aligned_alloc().
909 # if defined(__APPLE__)
910 # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
911 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
912 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
914 # elif defined(__ANDROID__) && __ANDROID_API__ < 28
915 // Android only provides aligned_alloc when targeting API 28 or higher.
916 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
919 # if defined(__APPLE__) || defined(__FreeBSD__)
920 # define _LIBCPP_HAS_DEFAULTRUNELOCALE
923 # if defined(__APPLE__) || defined(__FreeBSD__)
924 # define _LIBCPP_WCTYPE_IS_MASK
927 # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
928 # define _LIBCPP_HAS_NO_CHAR8_T
931 // Deprecation macros.
933 // Deprecations warnings are always enabled, except when users explicitly opt-out
934 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
935 # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
936 # if __has_attribute(__deprecated__)
937 # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
938 # define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
939 # elif _LIBCPP_STD_VER >= 14
940 # define _LIBCPP_DEPRECATED [[deprecated]]
941 # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
943 # define _LIBCPP_DEPRECATED
944 # define _LIBCPP_DEPRECATED_(m)
947 # define _LIBCPP_DEPRECATED
948 # define _LIBCPP_DEPRECATED_(m)
951 # if !defined(_LIBCPP_CXX03_LANG)
952 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
954 # define _LIBCPP_DEPRECATED_IN_CXX11
957 # if _LIBCPP_STD_VER >= 14
958 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
960 # define _LIBCPP_DEPRECATED_IN_CXX14
963 # if _LIBCPP_STD_VER >= 17
964 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
966 # define _LIBCPP_DEPRECATED_IN_CXX17
969 # if _LIBCPP_STD_VER >= 20
970 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
972 # define _LIBCPP_DEPRECATED_IN_CXX20
975 # if _LIBCPP_STD_VER >= 23
976 # define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
978 # define _LIBCPP_DEPRECATED_IN_CXX23
981 # if !defined(_LIBCPP_HAS_NO_CHAR8_T)
982 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
984 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
987 // Macros to enter and leave a state where deprecation warnings are suppressed.
988 # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
989 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
990 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
991 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
992 # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
994 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
995 # define _LIBCPP_SUPPRESS_DEPRECATED_POP
998 # if _LIBCPP_STD_VER <= 11
999 # define _LIBCPP_EXPLICIT_SINCE_CXX14
1001 # define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
1004 # if _LIBCPP_STD_VER >= 23
1005 # define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
1007 # define _LIBCPP_EXPLICIT_SINCE_CXX23
1010 # if _LIBCPP_STD_VER >= 14
1011 # define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
1013 # define _LIBCPP_CONSTEXPR_SINCE_CXX14
1016 # if _LIBCPP_STD_VER >= 17
1017 # define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
1019 # define _LIBCPP_CONSTEXPR_SINCE_CXX17
1022 # if _LIBCPP_STD_VER >= 20
1023 # define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
1025 # define _LIBCPP_CONSTEXPR_SINCE_CXX20
1028 # if _LIBCPP_STD_VER >= 23
1029 # define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
1031 # define _LIBCPP_CONSTEXPR_SINCE_CXX23
1034 # if __has_cpp_attribute(nodiscard)
1035 # define _LIBCPP_NODISCARD [[__nodiscard__]]
1037 // We can't use GCC's [[gnu::warn_unused_result]] and
1038 // __attribute__((warn_unused_result)), because GCC does not silence them via
1040 # define _LIBCPP_NODISCARD
1043 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1044 // specified as such as an extension.
1045 # if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1046 # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1048 # define _LIBCPP_NODISCARD_EXT
1051 # if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1052 # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1054 # define _LIBCPP_NODISCARD_AFTER_CXX17
1057 # if __has_attribute(__no_destroy__)
1058 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1060 # define _LIBCPP_NO_DESTROY
1063 # ifndef _LIBCPP_HAS_NO_ASAN
1064 extern "C" _LIBCPP_EXPORTED_FROM_ABI void
1065 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
1066 # if _LIBCPP_CLANG_VER >= 1600
1067 extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
1068 const void*, const void*, const void*, const void*, const void*, const void*);
1069 extern "C" _LIBCPP_EXPORTED_FROM_ABI int
1070 __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
1074 // Try to find out if RTTI is disabled.
1075 # if !defined(__cpp_rtti) || __cpp_rtti < 199711L
1076 # define _LIBCPP_HAS_NO_RTTI
1079 # ifndef _LIBCPP_WEAK
1080 # define _LIBCPP_WEAK __attribute__((__weak__))
1085 # if !defined(_LIBCPP_HAS_NO_THREADS) && \
1086 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1087 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1088 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1090 # if defined(__FreeBSD__) || \
1091 defined(__wasi__) || \
1092 defined(__NetBSD__) || \
1093 defined(__OpenBSD__) || \
1094 defined(__NuttX__) || \
1095 defined(__linux__) || \
1096 defined(__GNU__) || \
1097 defined(__APPLE__) || \
1098 defined(__MVS__) || \
1100 defined(__EMSCRIPTEN__)
1102 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1103 # elif defined(__Fuchsia__)
1104 // TODO(44575): Switch to C11 thread API when possible.
1105 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1106 # elif defined(_LIBCPP_WIN32API)
1107 # define _LIBCPP_HAS_THREAD_API_WIN32
1109 # error "No thread API"
1110 # endif // _LIBCPP_HAS_THREAD_API
1111 # endif // _LIBCPP_HAS_NO_THREADS
1113 # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1114 # if defined(__ANDROID__) && __ANDROID_API__ >= 30
1115 # define _LIBCPP_HAS_COND_CLOCKWAIT
1116 # elif defined(_LIBCPP_GLIBC_PREREQ)
1117 # if _LIBCPP_GLIBC_PREREQ(2, 30)
1118 # define _LIBCPP_HAS_COND_CLOCKWAIT
1123 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1124 # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1125 _LIBCPP_HAS_NO_THREADS is not defined.
1128 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1129 # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1130 _LIBCPP_HAS_NO_THREADS is defined.
1133 # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1134 # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1135 _LIBCPP_HAS_NO_THREADS is defined.
1138 # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1139 # define __STDCPP_THREADS__ 1
1142 // The glibc and Bionic implementation of pthreads implements
1143 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1144 // mutexes have no destroy mechanism.
1146 // This optimization can't be performed on Apple platforms, where
1147 // pthread_mutex_destroy can allow the kernel to release resources.
1148 // See https://llvm.org/D64298 for details.
1150 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
1151 // respective stakeholders.
1153 # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
1154 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1155 defined(_LIBCPP_HAS_THREAD_API_WIN32)
1157 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1160 // Destroying a condvar is a nop on Windows.
1162 // This optimization can't be performed on Apple platforms, where
1163 // pthread_cond_destroy can allow the kernel to release resources.
1164 // See https://llvm.org/D64298 for details.
1166 // TODO(EricWF): This is potentially true for some pthread implementations
1168 # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1169 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1172 // Some systems do not provide gets() in their C library, for security reasons.
1173 # if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
1174 # define _LIBCPP_C_HAS_NO_GETS
1177 # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
1178 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1179 # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1182 # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1183 # define _LIBCPP_HAS_C_ATOMIC_IMP
1184 # elif defined(_LIBCPP_COMPILER_GCC)
1185 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
1188 # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1189 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1190 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
1192 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1193 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
1195 # ifdef _LIBCPP_FREESTANDING
1196 # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1200 # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1201 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1204 # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
1205 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__))
1207 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
1210 # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1211 # if defined(__clang__) && __has_attribute(acquire_capability)
1212 // Work around the attribute handling in clang. When both __declspec and
1213 // __attribute__ are present, the processing goes awry preventing the definition
1214 // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
1215 // combining the two does work.
1216 # if !defined(_MSC_VER)
1217 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1222 # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1223 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1225 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1228 # if _LIBCPP_STD_VER >= 20
1229 # define _LIBCPP_CONSTINIT constinit
1230 # elif __has_attribute(__require_constant_initialization__)
1231 # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1233 # define _LIBCPP_CONSTINIT
1236 # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1237 # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
1239 # define _LIBCPP_DIAGNOSE_WARNING(...)
1242 // Use a function like macro to imply that it must be followed by a semicolon
1243 # if __has_cpp_attribute(fallthrough)
1244 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1245 # elif __has_attribute(__fallthrough__)
1246 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1248 # define _LIBCPP_FALLTHROUGH() ((void)0)
1251 # if __has_cpp_attribute(_Clang::__lifetimebound__)
1252 # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1254 # define _LIBCPP_LIFETIMEBOUND
1257 # if __has_attribute(__nodebug__)
1258 # define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1260 # define _LIBCPP_NODEBUG
1263 # if __has_attribute(__standalone_debug__)
1264 # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1266 # define _LIBCPP_STANDALONE_DEBUG
1269 # if __has_attribute(__preferred_name__)
1270 # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1272 # define _LIBCPP_PREFERRED_NAME(x)
1275 # if __has_attribute(__no_sanitize__)
1276 # define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1278 # define _LIBCPP_NO_SANITIZE(...)
1281 // We often repeat things just for handling wide characters in the library.
1282 // When wide characters are disabled, it can be useful to have a quick way of
1283 // disabling it without having to resort to #if-#endif, which has a larger
1284 // impact on readability.
1285 # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1286 # define _LIBCPP_IF_WIDE_CHARACTERS(...)
1288 # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1291 # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1292 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1294 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1297 # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1298 # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1299 # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1300 # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1301 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1302 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1303 # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1305 # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1306 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1307 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1308 # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1309 # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1310 # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1311 # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1312 # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1315 # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh()\")") _Pragma("push_macro(\"move(int, int)\")") _Pragma("push_macro(\"erase()\")")
1316 # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh()\")") _Pragma("pop_macro(\"move(int, int)\")") _Pragma("pop_macro(\"erase()\")")
1319 # ifndef _LIBCPP_NO_AUTO_LINK
1320 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1321 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1322 # pragma comment(lib, "c++.lib")
1324 # pragma comment(lib, "libc++.lib")
1326 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1327 # endif // _LIBCPP_NO_AUTO_LINK
1329 // Configures the fopen close-on-exec mode character, if any. This string will
1330 // be appended to any mode string used by fstream for fopen/fdopen.
1332 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
1334 # if defined(__BIONIC__)
1335 # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1337 # define _LIBCPP_FOPEN_CLOEXEC_MODE
1340 // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1341 // of functions used in cstdio may not be available for low API levels when
1342 // using 64-bit file offsets on LP32.
1343 # if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1344 # define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1347 # if __has_attribute(__init_priority__)
1348 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1350 # define _LIBCPP_INIT_PRIORITY_MAX
1353 # if __has_attribute(__format__)
1354 // The attribute uses 1-based indices for ordinary and static member functions.
1355 // The attribute uses 2-based indices for non-static member functions.
1356 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1357 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1359 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1362 # if __has_cpp_attribute(msvc::no_unique_address)
1363 // MSVC implements [[no_unique_address]] as a silent no-op currently.
1364 // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1365 // However, MSVC implements [[msvc::no_unique_address]] which does what
1366 // [[no_unique_address]] is supposed to do, in general.
1368 // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1369 // [[msvc::no_unique_address]] though. If/when it does implement
1370 // [[msvc::no_unique_address]], this should be preferred though.
1371 # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1372 # elif __has_cpp_attribute(no_unique_address)
1373 # define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1375 # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1376 // Note that this can be replaced by #error as soon as clang-cl
1377 // implements msvc::no_unique_address, since there should be no C++20
1378 // compiler that doesn't support one of the two attributes at that point.
1379 // We generally don't want to use this macro outside of C++20-only code,
1380 // because using it conditionally in one language version only would make
1381 // the ABI inconsistent.
1384 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1385 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1386 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1387 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1388 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1389 # elif defined(_LIBCPP_COMPILER_GCC)
1390 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1391 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1392 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1393 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1395 # define _LIBCPP_DIAGNOSTIC_PUSH
1396 # define _LIBCPP_DIAGNOSTIC_POP
1397 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1398 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1401 # if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
1402 # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
1403 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
1405 # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
1406 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
1409 # if __has_attribute(__packed__)
1410 # define _LIBCPP_PACKED __attribute__((__packed__))
1412 # define _LIBCPP_PACKED
1415 // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1416 // functions is gradually being added to existing C libraries. The conditions
1417 // below check for known C library versions and conditions under which these
1418 // functions are declared by the C library.
1419 # define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1420 // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1421 // __cpp_char8_t is defined or if C2X extensions are enabled. Determining
1422 // the latter depends on internal GNU libc details that are not appropriate
1423 // to depend on here, so any declarations present when __cpp_char8_t is not
1424 // defined are ignored.
1425 # if defined(_LIBCPP_GLIBC_PREREQ)
1426 # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
1427 # undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1431 // There are a handful of public standard library types that are intended to
1432 // support CTAD but don't need any explicit deduction guides to do so. This
1433 // macro is used to mark them as such, which suppresses the
1434 // '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
1435 // with these classes.
1436 # if _LIBCPP_STD_VER >= 17
1437 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1438 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
1439 template <class... _Tag> \
1440 [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
1442 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
1443 template <class... _Tag> \
1444 ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
1447 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1450 // TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
1451 // compiler intrinsics in the Objective-C++ mode.
1453 # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1456 # define _PSTL_PRAGMA(x) _Pragma(#x)
1458 // Enable SIMD for compilers that support OpenMP 4.0
1459 # if (defined(_OPENMP) && _OPENMP >= 201307)
1461 # define _PSTL_UDR_PRESENT
1462 # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
1463 # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
1464 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
1465 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
1466 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
1467 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
1469 // Declaration of reduction functor, where
1470 // NAME - the name of the functor
1471 // OP - type of the callable object with the reduction operation
1472 // omp_in - refers to the local partial result
1473 // omp_out - refers to the final value of the combiner operator
1474 // omp_priv - refers to the private copy of the initial value
1475 // omp_orig - refers to the original variable to be reduced
1476 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
1477 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
1479 # elif defined(_LIBCPP_COMPILER_CLANG_BASED)
1481 # define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
1482 # define _PSTL_PRAGMA_DECLARE_SIMD
1483 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1484 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1485 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1486 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1487 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1489 # else // (defined(_OPENMP) && _OPENMP >= 201307)
1491 # define _PSTL_PRAGMA_SIMD
1492 # define _PSTL_PRAGMA_DECLARE_SIMD
1493 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
1494 # define _PSTL_PRAGMA_SIMD_SCAN(PRM)
1495 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1496 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1497 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1499 # endif // (defined(_OPENMP) && _OPENMP >= 201307)
1501 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
1503 #endif // __cplusplus
1505 #endif // _LIBCPP___CONFIG