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
25 #if defined(__apple_build_version__)
26 // Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
27 # define _LIBCPP_COMPILER_CLANG_BASED
28 # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
29 #elif defined(__clang__)
30 # define _LIBCPP_COMPILER_CLANG_BASED
31 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
32 #elif defined(__GNUC__)
33 # define _LIBCPP_COMPILER_GCC
38 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
40 // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
41 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
43 # define _LIBCPP_VERSION 180000
45 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
46 # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
48 // Valid C++ identifier that revs with every libc++ version. This can be used to
49 // generate identifiers that must be unique for every released libc++ version.
50 # define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
52 # if __STDC_HOSTED__ == 0
53 # define _LIBCPP_FREESTANDING
56 // NOLINTBEGIN(libcpp-cpp-version-check)
57 # ifndef _LIBCPP_STD_VER
58 # if __cplusplus <= 201103L
59 # define _LIBCPP_STD_VER 11
60 # elif __cplusplus <= 201402L
61 # define _LIBCPP_STD_VER 14
62 # elif __cplusplus <= 201703L
63 # define _LIBCPP_STD_VER 17
64 # elif __cplusplus <= 202002L
65 # define _LIBCPP_STD_VER 20
66 # elif __cplusplus <= 202302L
67 # define _LIBCPP_STD_VER 23
69 // Expected release year of the next C++ standard
70 # define _LIBCPP_STD_VER 26
72 # endif // _LIBCPP_STD_VER
73 // NOLINTEND(libcpp-cpp-version-check)
76 # define _LIBCPP_OBJECT_FORMAT_ELF 1
77 # elif defined(__MACH__)
78 # define _LIBCPP_OBJECT_FORMAT_MACHO 1
79 # elif defined(_WIN32)
80 # define _LIBCPP_OBJECT_FORMAT_COFF 1
81 # elif defined(__wasm__)
82 # define _LIBCPP_OBJECT_FORMAT_WASM 1
84 # define _LIBCPP_OBJECT_FORMAT_XCOFF 1
86 // ... add new file formats here ...
91 # if _LIBCPP_ABI_VERSION >= 2
92 // Change short string representation so that string data starts at offset 0,
93 // improving its alignment in some cases.
94 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
95 // Fix deque iterator type in order to support incomplete types.
96 # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
97 // Fix undefined behavior in how std::list stores its linked nodes.
98 # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
99 // Fix undefined behavior in how __tree stores its end and parent nodes.
100 # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
101 // Fix undefined behavior in how __hash_table stores its pointer types.
102 # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
103 # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
104 # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
105 // Define a key function for `bad_function_call` in the library, to centralize
106 // its vtable and typeinfo to libc++ rather than having all other libraries
107 // using that class define their own copies.
108 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
109 // Override the default return value of exception::what() for
110 // bad_function_call::what() with a string that is specific to
111 // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
112 // because it changes the vtable layout of bad_function_call.
113 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
114 // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
115 # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
116 // Give reverse_iterator<T> one data member of type T, not two.
117 // Also, in C++17 and later, don't derive iterator types from std::iterator.
118 # define _LIBCPP_ABI_NO_ITERATOR_BASES
119 // Use the smallest possible integer type to represent the index of the variant.
120 // Previously libc++ used "unsigned int" exclusively.
121 # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
122 // Unstable attempt to provide a more optimized std::function
123 # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
124 // All the regex constants must be distinct and nonzero.
125 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
126 // Re-worked external template instantiations for std::string with a focus on
127 // performance and fast-path inlining.
128 # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
129 // Enable clang::trivial_abi on std::unique_ptr.
130 # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
131 // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
132 # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
133 // std::random_device holds some state when it uses an implementation that gets
134 // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
135 // implementation to another one on a platform that has already shipped
136 // std::random_device, one needs to retain the same object layout to remain ABI
137 // compatible. This switch removes these workarounds for platforms that don't care
138 // about ABI compatibility.
139 # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
140 // Don't export the legacy __basic_string_common class and its methods from the built library.
141 # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
142 // Don't export the legacy __vector_base_common class and its methods from the built library.
143 # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
144 // According to the Standard, `bitset::operator[] const` returns bool
145 # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
146 // Fix the implementation of CityHash used for std::hash<fundamental-type>.
147 // This is an ABI break because `std::hash` will return a different result,
148 // which means that hashing the same object in translation units built against
149 // different versions of libc++ can return inconsistent results. This is especially
150 // tricky since std::hash is used in the implementation of unordered containers.
152 // The incorrect implementation of CityHash has the problem that it drops some
153 // bits on the floor.
154 # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
155 // Remove the base 10 implementation of std::to_chars from the dylib.
156 // The implementation moved to the header, but we still export the symbols from
157 // the dylib for backwards compatibility.
158 # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
159 # elif _LIBCPP_ABI_VERSION == 1
160 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
161 // Enable compiling copies of now inline methods into the dylib to support
162 // applications compiled against older libraries. This is unnecessary with
163 // COFF dllexport semantics, since dllexport forces a non-inline definition
164 // of inline functions to be emitted anyway. Our own non-inline copy would
165 // conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
166 // the linker will take issue with the symbols in the shared object if the
167 // weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
169 # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
171 // Feature macros for disabling pre ABI v1 features. All of these options
173 # if defined(__FreeBSD__)
174 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
176 // For XCOFF linkers, we have problems if we see a weak hidden version of a symbol
177 // in user code (like you get with -fvisibility-inlines-hidden) and then a strong def
178 // in the library, so we need to always rely on the library version.
180 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
184 # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
185 // Enable additional explicit instantiations of iostreams components. This
186 // reduces the number of weak definitions generated in programs that use
187 // iostreams by providing a single strong definition in the shared library.
188 # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
190 // Define a key function for `bad_function_call` in the library, to centralize
191 // its vtable and typeinfo to libc++ rather than having all other libraries
192 // using that class define their own copies.
193 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
196 // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
197 // within the bounds of the original container and asserts it on every dereference.
199 // ABI impact: changes the iterator type of the relevant containers.
201 // Supported containers:
205 // #define _LIBCPP_ABI_BOUNDED_ITERATORS
211 // TODO(hardening): remove this in LLVM 18.
212 // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
213 // equivalent to setting the hardened mode.
214 # ifdef _LIBCPP_ENABLE_ASSERTIONS
215 # warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_ENABLE_HARDENED_MODE instead."
216 # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
217 # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
219 # if _LIBCPP_ENABLE_ASSERTIONS
220 # define _LIBCPP_ENABLE_HARDENED_MODE 1
224 // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes
225 // security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with
226 // `_LIBCPP_ENABLE_DEBUG_MODE`.
228 // #define _LIBCPP_ENABLE_HARDENED_MODE 1
230 // Enables the debug mode which contains all the checks from the hardened mode and additionally more expensive checks
231 // that may affect the complexity of algorithms. The debug mode is intended to be used for testing, not in production.
232 // Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE`.
234 // #define _LIBCPP_ENABLE_DEBUG_MODE 1
236 // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These
237 // macros are only for internal use -- users should only pick one of the high-level hardening modes described above.
239 // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and
240 // a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid:
241 // - the sentinel is reachable from the begin iterator;
242 // - TODO(hardening): both iterators refer to the same container.
244 // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through
245 // the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access
246 // a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like
247 // `optional` and `function` are considered one-element containers for the purposes of this check.
249 // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
250 // given ranges do not overlap.
252 // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
253 // the containers have compatible allocators.
255 // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on
258 // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet.
260 # ifndef _LIBCPP_ENABLE_HARDENED_MODE
261 # define _LIBCPP_ENABLE_HARDENED_MODE _LIBCPP_ENABLE_HARDENED_MODE_DEFAULT
263 # if _LIBCPP_ENABLE_HARDENED_MODE != 0 && _LIBCPP_ENABLE_HARDENED_MODE != 1
264 # error "_LIBCPP_ENABLE_HARDENED_MODE must be set to 0 or 1."
267 # ifndef _LIBCPP_ENABLE_DEBUG_MODE
268 # define _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT
270 # if _LIBCPP_ENABLE_DEBUG_MODE != 0 && _LIBCPP_ENABLE_DEBUG_MODE != 1
271 # error "_LIBCPP_ENABLE_DEBUG_MODE must be set to 0 or 1."
274 # if _LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_DEBUG_MODE
275 # error "Only one of _LIBCPP_ENABLE_HARDENED_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled."
278 // Hardened mode checks.
281 # if _LIBCPP_ENABLE_HARDENED_MODE
284 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
285 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
287 // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
289 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
290 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
291 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
292 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
294 // Debug mode checks.
296 # elif _LIBCPP_ENABLE_DEBUG_MODE
298 // All checks enabled.
299 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
300 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
301 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
302 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
303 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
304 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
306 // Disable all checks if hardening is not enabled.
310 // All checks disabled.
311 # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression)
312 # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression)
313 # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
314 # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
315 # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
316 # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
318 # endif // _LIBCPP_ENABLE_HARDENED_MODE
323 # define _LIBCPP_TOSTRING2(x) #x
324 # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
326 // NOLINTNEXTLINE(libcpp-cpp-version-check)
327 # if __cplusplus < 201103L
328 # define _LIBCPP_CXX03_LANG
331 # ifndef __has_attribute
332 # define __has_attribute(__x) 0
335 # ifndef __has_builtin
336 # define __has_builtin(__x) 0
339 # ifndef __has_extension
340 # define __has_extension(__x) 0
343 # ifndef __has_feature
344 # define __has_feature(__x) 0
347 # ifndef __has_cpp_attribute
348 # define __has_cpp_attribute(__x) 0
351 # ifndef __has_constexpr_builtin
352 # define __has_constexpr_builtin(x) 0
355 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
356 // the compiler and '1' otherwise.
357 # ifndef __is_identifier
358 # define __is_identifier(__x) 1
361 # ifndef __has_declspec_attribute
362 # define __has_declspec_attribute(__x) 0
365 # define __has_keyword(__x) !(__is_identifier(__x))
367 # ifndef __has_include
368 # define __has_include(...) 0
371 # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
372 # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
375 // FIXME: ABI detection should be done via compiler builtin macros. This
376 // is just a placeholder until Clang implements such macros. For now assume
377 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
378 // and allow the user to explicitly specify the ABI to handle cases where this
379 // heuristic falls short.
380 # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
381 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
382 # elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
383 # define _LIBCPP_ABI_ITANIUM
384 # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
385 # define _LIBCPP_ABI_MICROSOFT
387 # if defined(_WIN32) && defined(_MSC_VER)
388 # define _LIBCPP_ABI_MICROSOFT
390 # define _LIBCPP_ABI_ITANIUM
394 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
395 # define _LIBCPP_ABI_VCRUNTIME
398 # if __has_feature(experimental_library)
399 # ifndef _LIBCPP_ENABLE_EXPERIMENTAL
400 # define _LIBCPP_ENABLE_EXPERIMENTAL
404 // Incomplete features get their own specific disabling flags. This makes it
405 // easier to grep for target specific flags once the feature is complete.
406 # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
407 # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
410 # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
411 # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
414 // Need to detect which libc we're using if we're on Linux.
415 # if defined(__linux__)
416 # include <features.h>
417 # if defined(__GLIBC_PREREQ)
418 # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
420 # define _LIBCPP_GLIBC_PREREQ(a, b) 0
421 # endif // defined(__GLIBC_PREREQ)
422 # endif // defined(__linux__)
424 # if defined(__MVS__)
425 # include <features.h> // for __NATIVE_ASCII_F
428 # ifdef __LITTLE_ENDIAN__
429 # if __LITTLE_ENDIAN__
430 # define _LIBCPP_LITTLE_ENDIAN
431 # endif // __LITTLE_ENDIAN__
432 # endif // __LITTLE_ENDIAN__
434 # ifdef __BIG_ENDIAN__
436 # define _LIBCPP_BIG_ENDIAN
437 # endif // __BIG_ENDIAN__
438 # endif // __BIG_ENDIAN__
440 # ifdef __BYTE_ORDER__
441 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
442 # define _LIBCPP_LITTLE_ENDIAN
443 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
444 # define _LIBCPP_BIG_ENDIAN
445 # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
446 # endif // __BYTE_ORDER__
449 # include <osreldate.h>
450 # include <sys/endian.h>
451 # if _BYTE_ORDER == _LITTLE_ENDIAN
452 # define _LIBCPP_LITTLE_ENDIAN
453 # else // _BYTE_ORDER == _LITTLE_ENDIAN
454 # define _LIBCPP_BIG_ENDIAN
455 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
456 # endif // __FreeBSD__
458 # if defined(__NetBSD__) || defined(__OpenBSD__)
459 # include <sys/endian.h>
460 # if _BYTE_ORDER == _LITTLE_ENDIAN
461 # define _LIBCPP_LITTLE_ENDIAN
462 # else // _BYTE_ORDER == _LITTLE_ENDIAN
463 # define _LIBCPP_BIG_ENDIAN
464 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
465 # endif // defined(__NetBSD__) || defined(__OpenBSD__)
468 # define _LIBCPP_WIN32API
469 # define _LIBCPP_LITTLE_ENDIAN
470 # define _LIBCPP_SHORT_WCHAR 1
471 // Both MinGW and native MSVC provide a "MSVC"-like environment
472 # define _LIBCPP_MSVCRT_LIKE
473 // If mingw not explicitly detected, assume using MS C runtime only if
474 // a MS compatibility version is specified.
475 # if defined(_MSC_VER) && !defined(__MINGW32__)
476 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
478 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
479 # define _LIBCPP_HAS_BITSCAN64
481 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
482 # endif // defined(_WIN32)
484 # if defined(_AIX) && !defined(__64BIT__)
485 // The size of wchar is 2 byte on 32-bit mode on AIX.
486 # define _LIBCPP_SHORT_WCHAR 1
489 // Libc++ supports various implementations of std::random_device.
491 // _LIBCPP_USING_DEV_RANDOM
492 // Read entropy from the given file, by default `/dev/urandom`.
493 // If a token is provided, it is assumed to be the path to a file
494 // to read entropy from. This is the default behavior if nothing
495 // else is specified. This implementation requires storing state
496 // inside `std::random_device`.
498 // _LIBCPP_USING_ARC4_RANDOM
499 // Use arc4random(). This allows obtaining random data even when
500 // using sandboxing mechanisms. On some platforms like Apple, this
501 // is the recommended source of entropy for user-space programs.
502 // When this option is used, the token passed to `std::random_device`'s
503 // constructor *must* be "/dev/urandom" -- anything else is an error.
505 // _LIBCPP_USING_GETENTROPY
507 // When this option is used, the token passed to `std::random_device`'s
508 // constructor *must* be "/dev/urandom" -- anything else is an error.
510 // _LIBCPP_USING_FUCHSIA_CPRNG
511 // Use Fuchsia's zx_cprng_draw() system call, which is specified to
512 // deliver high-quality entropy and cannot fail.
513 // When this option is used, the token passed to `std::random_device`'s
514 // constructor *must* be "/dev/urandom" -- anything else is an error.
516 // _LIBCPP_USING_NACL_RANDOM
517 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
518 // including accesses to the special files under `/dev`. This implementation
519 // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
520 // When this option is used, the token passed to `std::random_device`'s
521 // constructor *must* be "/dev/urandom" -- anything else is an error.
523 // _LIBCPP_USING_WIN32_RANDOM
524 // Use rand_s(), for use on Windows.
525 // When this option is used, the token passed to `std::random_device`'s
526 // constructor *must* be "/dev/urandom" -- anything else is an error.
527 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
528 defined(__DragonFly__)
529 # define _LIBCPP_USING_ARC4_RANDOM
530 # elif defined(__wasi__) || defined(__EMSCRIPTEN__)
531 # define _LIBCPP_USING_GETENTROPY
532 # elif defined(__Fuchsia__)
533 # define _LIBCPP_USING_FUCHSIA_CPRNG
534 # elif defined(__native_client__)
535 # define _LIBCPP_USING_NACL_RANDOM
536 # elif defined(_LIBCPP_WIN32API)
537 # define _LIBCPP_USING_WIN32_RANDOM
539 # define _LIBCPP_USING_DEV_RANDOM
542 # if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
544 # if __BYTE_ORDER == __LITTLE_ENDIAN
545 # define _LIBCPP_LITTLE_ENDIAN
546 # elif __BYTE_ORDER == __BIG_ENDIAN
547 # define _LIBCPP_BIG_ENDIAN
548 # else // __BYTE_ORDER == __BIG_ENDIAN
549 # error unable to determine endian
551 # endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
553 # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
554 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
556 # define _LIBCPP_NO_CFI
559 # ifndef _LIBCPP_CXX03_LANG
561 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
562 # define _ALIGNAS_TYPE(x) alignas(x)
563 # define _ALIGNAS(x) alignas(x)
564 # define _LIBCPP_NORETURN [[noreturn]]
565 # define _NOEXCEPT noexcept
566 # define _NOEXCEPT_(x) noexcept(x)
567 # define _LIBCPP_CONSTEXPR constexpr
571 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
572 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
573 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
574 # define _LIBCPP_NORETURN __attribute__((__noreturn__))
575 # define _LIBCPP_HAS_NO_NOEXCEPT
576 # define nullptr __nullptr
577 # define _NOEXCEPT throw()
578 # define _NOEXCEPT_(x)
579 # define static_assert(...) _Static_assert(__VA_ARGS__)
580 # define decltype(...) __decltype(__VA_ARGS__)
581 # define _LIBCPP_CONSTEXPR
583 typedef __char16_t char16_t;
584 typedef __char32_t char32_t;
588 # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
589 # define _LIBCPP_HAS_NO_EXCEPTIONS
592 # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
594 # if defined(_LIBCPP_COMPILER_CLANG_BASED)
596 # if defined(__APPLE__)
597 # if defined(__i386__) || defined(__x86_64__)
598 // use old string layout on x86_64 and i386
599 # elif defined(__arm__)
600 // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs
601 # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2
602 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
605 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
609 // Objective-C++ features (opt-in)
610 # if __has_feature(objc_arc)
611 # define _LIBCPP_HAS_OBJC_ARC
614 # if __has_feature(objc_arc_weak)
615 # define _LIBCPP_HAS_OBJC_ARC_WEAK
618 # if __has_extension(blocks)
619 # define _LIBCPP_HAS_EXTENSION_BLOCKS
622 # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
623 # define _LIBCPP_HAS_BLOCKS_RUNTIME
626 # if !__has_feature(address_sanitizer)
627 # define _LIBCPP_HAS_NO_ASAN
630 // Allow for build-time disabling of unsigned integer sanitization
631 # if __has_attribute(no_sanitize)
632 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
635 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
637 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
639 # elif defined(_LIBCPP_COMPILER_GCC)
641 # if !defined(__SANITIZE_ADDRESS__)
642 # define _LIBCPP_HAS_NO_ASAN
645 # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
647 # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
649 # endif // _LIBCPP_COMPILER_[CLANG|GCC]
651 # if defined(_LIBCPP_OBJECT_FORMAT_COFF)
654 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
656 # define _LIBCPP_CRT_FUNC
659 # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
660 # define _LIBCPP_DLL_VIS
661 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
662 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
663 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
664 # define _LIBCPP_EXPORTED_FROM_ABI
665 # elif defined(_LIBCPP_BUILDING_LIBRARY)
666 # define _LIBCPP_DLL_VIS __declspec(dllexport)
667 # if defined(__MINGW32__)
668 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
669 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
671 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
672 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
674 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
675 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
677 # define _LIBCPP_DLL_VIS __declspec(dllimport)
678 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
679 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
680 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
681 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
684 # define _LIBCPP_HIDDEN
685 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
686 # define _LIBCPP_TEMPLATE_VIS
687 # define _LIBCPP_TEMPLATE_DATA_VIS
688 # define _LIBCPP_ENUM_VIS
692 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
693 # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
695 # define _LIBCPP_VISIBILITY(vis)
698 # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
699 # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
700 # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
701 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
702 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
704 // TODO: Make this a proper customization point or remove the option to override it.
705 # ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
706 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
709 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
710 // The inline should be removed once PR32114 is resolved
711 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
713 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_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
726 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
727 # define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
729 # define _LIBCPP_ENUM_VIS
732 # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
734 # if __has_attribute(exclude_from_explicit_instantiation)
735 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
737 // Try to approximate the effect of exclude_from_explicit_instantiation
738 // (which is that entities are not assumed to be provided by explicit
739 // template instantiations in the dylib) by always inlining those entities.
740 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
743 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
745 // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
746 // symbols from their dynamic library by means of using the libc++ headers. This ensures
747 // that those symbols stay private to the dynamic library in which it is defined.
749 // 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures
750 // that no ODR violation can arise from mixing two TUs compiled with different versions
751 // of libc++ where we would have changed the definition of a symbol. If the symbols shared
752 // the same name, the ODR would require that their definitions be token-by-token equivalent,
753 // which basically prevents us from being able to make any change to any function in our
754 // headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at
755 // each release, which lets us change the definition of these symbols at our leisure.
756 // Note that historically, this has been achieved in various ways, including force-inlining
757 // all functions or giving internal linkage to all functions. Both these (previous) solutions
758 // suffer from drawbacks that lead notably to code bloat.
760 // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
761 // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
763 // Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
764 // instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
765 // name of a virtual function is part of its ABI, since some architectures like arm64e can sign
766 // the virtual function pointer in the vtable based on the mangled name of the function. Since
767 // we use an ABI tag that changes with each released version, the mangled name of the virtual
768 // function would change, which is incorrect. Note that it doesn't make much sense to change
769 // the implementation of a virtual function in an ABI-incompatible way in the first place,
770 // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
772 // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
773 // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
774 // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
775 # ifndef _LIBCPP_NO_ABI_TAG
776 # define _LIBCPP_HIDE_FROM_ABI \
777 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
778 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
780 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
782 # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
784 // This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
785 // "C" function, as those lack mangling.
786 # define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
788 # ifdef _LIBCPP_BUILDING_LIBRARY
789 # if _LIBCPP_ABI_VERSION > 1
790 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
792 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
795 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
798 // Just so we can migrate to the new macros gradually.
799 # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
801 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
803 # define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
804 # define _LIBCPP_END_NAMESPACE_STD }}
807 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
809 # if _LIBCPP_STD_VER >= 17
810 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
811 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
813 # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
814 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
817 # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
820 # define _VSTD_FS std::__fs::filesystem
822 # if __has_attribute(__enable_if__)
823 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
826 # if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
827 # define _LIBCPP_HAS_NO_INT128
830 # if __has_attribute(__malloc__)
831 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
833 # define _LIBCPP_NOALIAS
836 # if __has_attribute(__using_if_exists__)
837 # define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
839 # define _LIBCPP_USING_IF_EXISTS
842 # ifdef _LIBCPP_CXX03_LANG
843 # define _LIBCPP_DECLARE_STRONG_ENUM(x) \
844 struct _LIBCPP_EXPORTED_FROM_ABI x { \
847 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
849 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
850 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
851 _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
855 # else // _LIBCPP_CXX03_LANG
856 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
857 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
858 # endif // _LIBCPP_CXX03_LANG
860 # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
861 # define _LIBCPP_LOCALE__L_EXTENSIONS 1
865 # define _DECLARE_C99_LDBL_MATH 1
868 // If we are getting operator new from the MSVC CRT, then allocation overloads
869 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
870 # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
871 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
872 # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
873 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
874 // have it unless the language feature test macro is defined.
875 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
876 # elif defined(__MVS__)
877 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
880 # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
881 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
884 // It is not yet possible to use aligned_alloc() on all Apple platforms since
885 // 10.15 was the first version to ship an implementation of aligned_alloc().
886 # if defined(__APPLE__)
887 # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
888 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
889 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
891 # elif defined(__ANDROID__) && __ANDROID_API__ < 28
892 // Android only provides aligned_alloc when targeting API 28 or higher.
893 # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
896 # if defined(__APPLE__) || defined(__FreeBSD__)
897 # define _LIBCPP_HAS_DEFAULTRUNELOCALE
900 # if defined(__APPLE__) || defined(__FreeBSD__)
901 # define _LIBCPP_WCTYPE_IS_MASK
904 # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
905 # define _LIBCPP_HAS_NO_CHAR8_T
908 // Deprecation macros.
910 // Deprecations warnings are always enabled, except when users explicitly opt-out
911 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
912 # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
913 # if __has_attribute(__deprecated__)
914 # define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
915 # define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
916 # elif _LIBCPP_STD_VER >= 14
917 # define _LIBCPP_DEPRECATED [[deprecated]]
918 # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
920 # define _LIBCPP_DEPRECATED
921 # define _LIBCPP_DEPRECATED_(m)
924 # define _LIBCPP_DEPRECATED
925 # define _LIBCPP_DEPRECATED_(m)
928 # if !defined(_LIBCPP_CXX03_LANG)
929 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
931 # define _LIBCPP_DEPRECATED_IN_CXX11
934 # if _LIBCPP_STD_VER >= 14
935 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
937 # define _LIBCPP_DEPRECATED_IN_CXX14
940 # if _LIBCPP_STD_VER >= 17
941 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
943 # define _LIBCPP_DEPRECATED_IN_CXX17
946 # if _LIBCPP_STD_VER >= 20
947 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
949 # define _LIBCPP_DEPRECATED_IN_CXX20
952 # if _LIBCPP_STD_VER >= 23
953 # define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
955 # define _LIBCPP_DEPRECATED_IN_CXX23
958 # if !defined(_LIBCPP_HAS_NO_CHAR8_T)
959 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
961 # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
964 // Macros to enter and leave a state where deprecation warnings are suppressed.
965 # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
966 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
967 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
968 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
969 # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
971 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
972 # define _LIBCPP_SUPPRESS_DEPRECATED_POP
975 # if _LIBCPP_STD_VER <= 11
976 # define _LIBCPP_EXPLICIT_SINCE_CXX14
978 # define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
981 # if _LIBCPP_STD_VER >= 23
982 # define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
984 # define _LIBCPP_EXPLICIT_SINCE_CXX23
987 # if _LIBCPP_STD_VER >= 14
988 # define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
990 # define _LIBCPP_CONSTEXPR_SINCE_CXX14
993 # if _LIBCPP_STD_VER >= 17
994 # define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
996 # define _LIBCPP_CONSTEXPR_SINCE_CXX17
999 # if _LIBCPP_STD_VER >= 20
1000 # define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
1002 # define _LIBCPP_CONSTEXPR_SINCE_CXX20
1005 # if _LIBCPP_STD_VER >= 23
1006 # define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
1008 # define _LIBCPP_CONSTEXPR_SINCE_CXX23
1011 # if __has_cpp_attribute(nodiscard)
1012 # define _LIBCPP_NODISCARD [[__nodiscard__]]
1014 // We can't use GCC's [[gnu::warn_unused_result]] and
1015 // __attribute__((warn_unused_result)), because GCC does not silence them via
1017 # define _LIBCPP_NODISCARD
1020 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1021 // specified as such as an extension.
1022 # if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1023 # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1025 # define _LIBCPP_NODISCARD_EXT
1028 # if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1029 # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1031 # define _LIBCPP_NODISCARD_AFTER_CXX17
1034 # if __has_attribute(__no_destroy__)
1035 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1037 # define _LIBCPP_NO_DESTROY
1040 # ifndef _LIBCPP_HAS_NO_ASAN
1041 extern "C" _LIBCPP_EXPORTED_FROM_ABI void
1042 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
1043 # if _LIBCPP_CLANG_VER >= 1600
1044 extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
1045 const void*, const void*, const void*, const void*, const void*, const void*);
1046 extern "C" _LIBCPP_EXPORTED_FROM_ABI int
1047 __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
1051 // Try to find out if RTTI is disabled.
1052 # if !defined(__cpp_rtti) || __cpp_rtti < 199711L
1053 # define _LIBCPP_HAS_NO_RTTI
1056 # ifndef _LIBCPP_WEAK
1057 # define _LIBCPP_WEAK __attribute__((__weak__))
1062 # if !defined(_LIBCPP_HAS_NO_THREADS) && \
1063 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1064 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1065 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1067 # if defined(__FreeBSD__) || \
1068 defined(__wasi__) || \
1069 defined(__NetBSD__) || \
1070 defined(__OpenBSD__) || \
1071 defined(__NuttX__) || \
1072 defined(__linux__) || \
1073 defined(__GNU__) || \
1074 defined(__APPLE__) || \
1075 defined(__MVS__) || \
1077 defined(__EMSCRIPTEN__)
1079 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1080 # elif defined(__Fuchsia__)
1081 // TODO(44575): Switch to C11 thread API when possible.
1082 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1083 # elif defined(_LIBCPP_WIN32API)
1084 # define _LIBCPP_HAS_THREAD_API_WIN32
1086 # error "No thread API"
1087 # endif // _LIBCPP_HAS_THREAD_API
1088 # endif // _LIBCPP_HAS_NO_THREADS
1090 # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1091 # if defined(__ANDROID__) && __ANDROID_API__ >= 30
1092 # define _LIBCPP_HAS_COND_CLOCKWAIT
1093 # elif defined(_LIBCPP_GLIBC_PREREQ)
1094 # if _LIBCPP_GLIBC_PREREQ(2, 30)
1095 # define _LIBCPP_HAS_COND_CLOCKWAIT
1100 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1101 # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1102 _LIBCPP_HAS_NO_THREADS is not defined.
1105 # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1106 # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1107 _LIBCPP_HAS_NO_THREADS is defined.
1110 # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1111 # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1112 _LIBCPP_HAS_NO_THREADS is defined.
1115 # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1116 # define __STDCPP_THREADS__ 1
1119 // The glibc and Bionic implementation of pthreads implements
1120 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1121 // mutexes have no destroy mechanism.
1123 // This optimization can't be performed on Apple platforms, where
1124 // pthread_mutex_destroy can allow the kernel to release resources.
1125 // See https://llvm.org/D64298 for details.
1127 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
1128 // respective stakeholders.
1130 # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
1131 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1132 defined(_LIBCPP_HAS_THREAD_API_WIN32)
1134 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1137 // Destroying a condvar is a nop on Windows.
1139 // This optimization can't be performed on Apple platforms, where
1140 // pthread_cond_destroy can allow the kernel to release resources.
1141 // See https://llvm.org/D64298 for details.
1143 // TODO(EricWF): This is potentially true for some pthread implementations
1145 # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1146 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1149 // Some systems do not provide gets() in their C library, for security reasons.
1150 # if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
1151 # define _LIBCPP_C_HAS_NO_GETS
1154 # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
1155 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1156 # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1159 # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1160 # define _LIBCPP_HAS_C_ATOMIC_IMP
1161 # elif defined(_LIBCPP_COMPILER_GCC)
1162 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
1165 # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1166 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1167 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
1169 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1170 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
1172 # ifdef _LIBCPP_FREESTANDING
1173 # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1177 # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1178 # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1181 # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
1182 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__))
1184 # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
1187 # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1188 # if defined(__clang__) && __has_attribute(acquire_capability)
1189 // Work around the attribute handling in clang. When both __declspec and
1190 // __attribute__ are present, the processing goes awry preventing the definition
1191 // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
1192 // combining the two does work.
1193 # if !defined(_MSC_VER)
1194 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1199 # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1200 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1202 # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1205 # if _LIBCPP_STD_VER >= 20
1206 # define _LIBCPP_CONSTINIT constinit
1207 # elif __has_attribute(__require_constant_initialization__)
1208 # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1210 # define _LIBCPP_CONSTINIT
1213 # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1214 # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
1216 # define _LIBCPP_DIAGNOSE_WARNING(...)
1219 // Use a function like macro to imply that it must be followed by a semicolon
1220 # if __has_cpp_attribute(fallthrough)
1221 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1222 # elif __has_attribute(__fallthrough__)
1223 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1225 # define _LIBCPP_FALLTHROUGH() ((void)0)
1228 # if __has_cpp_attribute(_Clang::__lifetimebound__)
1229 # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1231 # define _LIBCPP_LIFETIMEBOUND
1234 # if __has_attribute(__nodebug__)
1235 # define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1237 # define _LIBCPP_NODEBUG
1240 # if __has_attribute(__standalone_debug__)
1241 # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1243 # define _LIBCPP_STANDALONE_DEBUG
1246 # if __has_attribute(__preferred_name__)
1247 # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1249 # define _LIBCPP_PREFERRED_NAME(x)
1252 # if __has_attribute(__no_sanitize__)
1253 # define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1255 # define _LIBCPP_NO_SANITIZE(...)
1258 // We often repeat things just for handling wide characters in the library.
1259 // When wide characters are disabled, it can be useful to have a quick way of
1260 // disabling it without having to resort to #if-#endif, which has a larger
1261 // impact on readability.
1262 # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1263 # define _LIBCPP_IF_WIDE_CHARACTERS(...)
1265 # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1268 # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1269 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1271 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1274 # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1275 # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1276 # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1277 # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1278 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1279 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1280 # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1282 # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1283 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1284 # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1285 # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1286 # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1287 # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1288 # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1289 # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1292 # 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()\")")
1293 # 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()\")")
1296 # ifndef _LIBCPP_NO_AUTO_LINK
1297 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1298 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1299 # pragma comment(lib, "c++.lib")
1301 # pragma comment(lib, "libc++.lib")
1303 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1304 # endif // _LIBCPP_NO_AUTO_LINK
1306 // Configures the fopen close-on-exec mode character, if any. This string will
1307 // be appended to any mode string used by fstream for fopen/fdopen.
1309 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
1311 # if defined(__BIONIC__)
1312 # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1314 # define _LIBCPP_FOPEN_CLOEXEC_MODE
1317 // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1318 // of functions used in cstdio may not be available for low API levels when
1319 // using 64-bit file offsets on LP32.
1320 # if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1321 # define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1324 # if __has_attribute(__init_priority__)
1325 # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1327 # define _LIBCPP_INIT_PRIORITY_MAX
1330 # if __has_attribute(__format__)
1331 // The attribute uses 1-based indices for ordinary and static member functions.
1332 // The attribute uses 2-based indices for non-static member functions.
1333 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1334 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1336 # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1339 # if __has_cpp_attribute(msvc::no_unique_address)
1340 // MSVC implements [[no_unique_address]] as a silent no-op currently.
1341 // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1342 // However, MSVC implements [[msvc::no_unique_address]] which does what
1343 // [[no_unique_address]] is supposed to do, in general.
1345 // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1346 // [[msvc::no_unique_address]] though. If/when it does implement
1347 // [[msvc::no_unique_address]], this should be preferred though.
1348 # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1349 # elif __has_cpp_attribute(no_unique_address)
1350 # define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1352 # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1353 // Note that this can be replaced by #error as soon as clang-cl
1354 // implements msvc::no_unique_address, since there should be no C++20
1355 // compiler that doesn't support one of the two attributes at that point.
1356 // We generally don't want to use this macro outside of C++20-only code,
1357 // because using it conditionally in one language version only would make
1358 // the ABI inconsistent.
1361 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1362 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1363 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1364 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1365 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1366 # elif defined(_LIBCPP_COMPILER_GCC)
1367 # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1368 # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1369 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1370 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1372 # define _LIBCPP_DIAGNOSTIC_PUSH
1373 # define _LIBCPP_DIAGNOSTIC_POP
1374 # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1375 # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1378 # if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
1379 # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
1380 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
1382 # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
1383 # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
1386 # if __has_attribute(__packed__)
1387 # define _LIBCPP_PACKED __attribute__((__packed__))
1389 # define _LIBCPP_PACKED
1392 // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1393 // functions is gradually being added to existing C libraries. The conditions
1394 // below check for known C library versions and conditions under which these
1395 // functions are declared by the C library.
1396 # define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1397 // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1398 // __cpp_char8_t is defined or if C2X extensions are enabled. Determining
1399 // the latter depends on internal GNU libc details that are not appropriate
1400 // to depend on here, so any declarations present when __cpp_char8_t is not
1401 // defined are ignored.
1402 # if defined(_LIBCPP_GLIBC_PREREQ)
1403 # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
1404 # undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1408 // There are a handful of public standard library types that are intended to
1409 // support CTAD but don't need any explicit deduction guides to do so. This
1410 // macro is used to mark them as such, which suppresses the
1411 // '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
1412 // with these classes.
1413 # if _LIBCPP_STD_VER >= 17
1414 # ifdef _LIBCPP_COMPILER_CLANG_BASED
1415 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
1416 template <class... _Tag> \
1417 [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
1419 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
1420 template <class... _Tag> \
1421 ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
1424 # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1427 // TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
1428 // compiler intrinsics in the Objective-C++ mode.
1430 # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1433 # define _PSTL_PRAGMA(x) _Pragma(#x)
1435 // Enable SIMD for compilers that support OpenMP 4.0
1436 # if (defined(_OPENMP) && _OPENMP >= 201307)
1438 # define _PSTL_UDR_PRESENT
1439 # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
1440 # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
1441 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
1442 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
1443 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
1444 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
1446 // Declaration of reduction functor, where
1447 // NAME - the name of the functor
1448 // OP - type of the callable object with the reduction operation
1449 // omp_in - refers to the local partial result
1450 // omp_out - refers to the final value of the combiner operator
1451 // omp_priv - refers to the private copy of the initial value
1452 // omp_orig - refers to the original variable to be reduced
1453 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
1454 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
1456 # elif defined(_LIBCPP_COMPILER_CLANG_BASED)
1458 # define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
1459 # define _PSTL_PRAGMA_DECLARE_SIMD
1460 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1461 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1462 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1463 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1464 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1466 # else // (defined(_OPENMP) && _OPENMP >= 201307)
1468 # define _PSTL_PRAGMA_SIMD
1469 # define _PSTL_PRAGMA_DECLARE_SIMD
1470 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
1471 # define _PSTL_PRAGMA_SIMD_SCAN(PRM)
1472 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1473 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1474 # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1476 # endif // (defined(_OPENMP) && _OPENMP >= 201307)
1478 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
1480 #endif // __cplusplus
1482 #endif // _LIBCPP___CONFIG