]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/libcxx/include/__config
Tentatively merge https://github.com/llvm/llvm-project/pull/77242
[FreeBSD/FreeBSD.git] / contrib / llvm-project / libcxx / include / __config
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef _LIBCPP___CONFIG
11 #define _LIBCPP___CONFIG
12
13 #include <__config_site>
14
15 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16 #  pragma GCC system_header
17 #endif
18
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__)
29 #endif
30
31 #ifdef __cplusplus
32
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 < 1600
37 #      warning "Libc++ only supports Clang 16 and later"
38 #    endif
39 #  elif defined(_LIBCPP_APPLE_CLANG_VER)
40 #    if _LIBCPP_APPLE_CLANG_VER < 1500
41 #      warning "Libc++ only supports AppleClang 15 and later"
42 #    endif
43 #  elif defined(_LIBCPP_GCC_VER)
44 #    if _LIBCPP_GCC_VER < 1300
45 #      warning "Libc++ only supports GCC 13 and later"
46 #    endif
47 #  endif
48
49 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
50
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
53 // defined to XXYYZZ.
54 #  define _LIBCPP_VERSION 180000
55
56 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
57 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
58
59 #  if __STDC_HOSTED__ == 0
60 #    define _LIBCPP_FREESTANDING
61 #  endif
62
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
75 #    else
76 // Expected release year of the next C++ standard
77 #      define _LIBCPP_STD_VER 26
78 #    endif
79 #  endif // _LIBCPP_STD_VER
80 // NOLINTEND(libcpp-cpp-version-check)
81
82 #  if defined(__ELF__)
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
90 #  elif defined(_AIX)
91 #    define _LIBCPP_OBJECT_FORMAT_XCOFF 1
92 #  else
93 // ... add new file formats here ...
94 #  endif
95
96 // ABI {
97
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.
158 //
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),
180 // so disable it.
181 #      define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
182 #    endif
183 // Feature macros for disabling pre ABI v1 features. All of these options
184 // are deprecated.
185 #    if defined(__FreeBSD__) && __FreeBSD__ < 14
186 #      define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
187 #    endif
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.
191 #    if defined(_AIX)
192 #      define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
193 #    endif
194 #  endif
195
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
201 #  endif
202
203 // We had some bugs where we use [[no_unique_address]] together with construct_at,
204 // which causes UB as the call on construct_at could write to overlapping subobjects
205 //
206 // https://github.com/llvm/llvm-project/issues/70506
207 // https://github.com/llvm/llvm-project/issues/70494
208 //
209 // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions.
210 // The below macro is used for all classes whose ABI have changed as part of fixing these bugs.
211 #  define _LIBCPP_ABI_2023_OVERLAPPING_SUBOBJECT_FIX_TAG __attribute__((__abi_tag__("subobj_fix_2023")))
212
213 // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
214 // within the bounds of the original container and asserts it on every dereference.
215 //
216 // ABI impact: changes the iterator type of the relevant containers.
217 //
218 // Supported containers:
219 // - `span`;
220 // - `string_view`;
221 // - `array`.
222 // #define _LIBCPP_ABI_BOUNDED_ITERATORS
223
224 // } ABI
225
226 // HARDENING {
227
228 // TODO(hardening): deprecate this in LLVM 19.
229 // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
230 // equivalent to setting the extensive mode.
231 #  ifdef _LIBCPP_ENABLE_ASSERTIONS
232 #    if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
233 #      error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
234 #    endif
235 #    if _LIBCPP_ENABLE_ASSERTIONS
236 #      define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_EXTENSIVE
237 #    endif
238 #  endif
239
240 // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
241 //
242 // - `_LIBCPP_HARDENING_MODE_NONE`;
243 // - `_LIBCPP_HARDENING_MODE_FAST`;
244 // - `_LIBCPP_HARDENING_MODE_EXTENSIVE`;
245 // - `_LIBCPP_HARDENING_MODE_DEBUG`.
246 //
247 // These values have the following effects:
248 //
249 // - `_LIBCPP_HARDENING_MODE_NONE` -- sets the hardening mode to "none" which disables all runtime hardening checks;
250 //
251 // - `_LIBCPP_HARDENING_MODE_FAST` -- sets that hardening mode to "fast". The fast mode enables security-critical checks
252 //   that can be done with relatively little runtime overhead in constant time;
253 //
254 // - `_LIBCPP_HARDENING_MODE_EXTENSIVE` -- sets the hardening mode to "extensive". The extensive mode is a superset of
255 //   the fast mode that additionally enables checks that are relatively cheap and prevent common types of logic errors
256 //   but are not necessarily security-critical;
257 //
258 // - `_LIBCPP_HARDENING_MODE_DEBUG` -- sets the hardening mode to "debug". The debug mode is a superset of the extensive
259 //   mode and enables all checks available in the library, including internal assertions. Checks that are part of the
260 //   debug mode can be very expensive and thus the debug mode is intended to be used for testing, not in production.
261
262 // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These
263 // macros are only for internal use -- users should only pick one of the high-level hardening modes described above.
264 //
265 // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and
266 //   a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid:
267 //   - the sentinel is reachable from the begin iterator;
268 //   - TODO(hardening): both iterators refer to the same container.
269 //
270 // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through
271 //   the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access
272 //   a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like
273 //   `optional` and `function` are considered one-element containers for the purposes of this check.
274 //
275 // - `_LIBCPP_ASSERT_NON_NULL` -- checks that the pointer being dereferenced is not null. On most modern platforms zero
276 //   address does not refer to an actual location in memory, so a null pointer dereference would not compromize the
277 //   memory security of a program (however, it is still undefined behavior that can result in strange errors due to
278 //   compiler optimizations).
279 //
280 // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
281 //   given ranges do not overlap.
282 //
283 // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
284 //   the containers have compatible allocators.
285 //
286 // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on
287 //   user input.
288 //
289 // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet.
290
291 // clang-format off
292 #  define _LIBCPP_HARDENING_MODE_NONE      (1 << 1)
293 #  define _LIBCPP_HARDENING_MODE_FAST      (1 << 2)
294 #  define _LIBCPP_HARDENING_MODE_EXTENSIVE (1 << 4) // Deliberately not ordered.
295 #  define _LIBCPP_HARDENING_MODE_DEBUG     (1 << 3)
296 // clang-format on
297
298 #  ifndef _LIBCPP_HARDENING_MODE
299 #    define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
300 #  endif
301
302 #  if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_NONE &&                                                         \
303       _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_FAST &&                                                         \
304       _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_EXTENSIVE &&                                                    \
305       _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG
306 #    error _LIBCPP_HARDENING_MODE must be set to one of the following values: \
307 _LIBCPP_HARDENING_MODE_NONE, \
308 _LIBCPP_HARDENING_MODE_FAST, \
309 _LIBCPP_HARDENING_MODE_EXTENSIVE, \
310 _LIBCPP_HARDENING_MODE_DEBUG
311 #  endif
312
313 // clang-format off
314 // Fast hardening mode checks.
315
316 #  if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
317
318 // Enabled checks.
319 #    define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message)        _LIBCPP_ASSERT(expression, message)
320 #    define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message)     _LIBCPP_ASSERT(expression, message)
321 // Disabled checks.
322 // On most modern platforms, dereferencing a null pointer does not lead to an actual memory access.
323 #    define _LIBCPP_ASSERT_NON_NULL(expression, message)                 _LIBCPP_ASSUME(expression)
324 // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
325 // vulnerability.
326 #    define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message)   _LIBCPP_ASSUME(expression)
327 #    define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message)     _LIBCPP_ASSUME(expression)
328 #    define _LIBCPP_ASSERT_INTERNAL(expression, message)                 _LIBCPP_ASSUME(expression)
329 #    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message)            _LIBCPP_ASSUME(expression)
330
331 // Extensive hardening mode checks.
332
333 #  elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
334
335 // Enabled checks.
336 #    define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message)        _LIBCPP_ASSERT(expression, message)
337 #    define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message)     _LIBCPP_ASSERT(expression, message)
338 #    define _LIBCPP_ASSERT_NON_NULL(expression, message)                 _LIBCPP_ASSERT(expression, message)
339 #    define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message)   _LIBCPP_ASSERT(expression, message)
340 #    define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message)     _LIBCPP_ASSERT(expression, message)
341 #    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message)            _LIBCPP_ASSERT(expression, message)
342 // Disabled checks.
343 #    define _LIBCPP_ASSERT_INTERNAL(expression, message)                 _LIBCPP_ASSUME(expression)
344
345 // Debug hardening mode checks.
346
347 #  elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
348
349 // All checks enabled.
350 #    define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message)         _LIBCPP_ASSERT(expression, message)
351 #    define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message)      _LIBCPP_ASSERT(expression, message)
352 #    define _LIBCPP_ASSERT_NON_NULL(expression, message)                  _LIBCPP_ASSERT(expression, message)
353 #    define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message)    _LIBCPP_ASSERT(expression, message)
354 #    define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message)      _LIBCPP_ASSERT(expression, message)
355 #    define _LIBCPP_ASSERT_INTERNAL(expression, message)                  _LIBCPP_ASSERT(expression, message)
356 #    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message)             _LIBCPP_ASSERT(expression, message)
357
358 // Disable all checks if hardening is not enabled.
359
360 #  else
361
362 // All checks disabled.
363 #    define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message)         _LIBCPP_ASSUME(expression)
364 #    define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message)      _LIBCPP_ASSUME(expression)
365 #    define _LIBCPP_ASSERT_NON_NULL(expression, message)                  _LIBCPP_ASSUME(expression)
366 #    define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message)    _LIBCPP_ASSUME(expression)
367 #    define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message)      _LIBCPP_ASSUME(expression)
368 #    define _LIBCPP_ASSERT_INTERNAL(expression, message)                  _LIBCPP_ASSUME(expression)
369 #    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message)             _LIBCPP_ASSUME(expression)
370
371 #  endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
372 // clang-format on
373
374 // } HARDENING
375
376 #  define _LIBCPP_TOSTRING2(x) #x
377 #  define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
378
379 // NOLINTNEXTLINE(libcpp-cpp-version-check)
380 #  if __cplusplus < 201103L
381 #    define _LIBCPP_CXX03_LANG
382 #  endif
383
384 #  ifndef __has_attribute
385 #    define __has_attribute(__x) 0
386 #  endif
387
388 #  ifndef __has_builtin
389 #    define __has_builtin(__x) 0
390 #  endif
391
392 #  ifndef __has_extension
393 #    define __has_extension(__x) 0
394 #  endif
395
396 #  ifndef __has_feature
397 #    define __has_feature(__x) 0
398 #  endif
399
400 #  ifndef __has_cpp_attribute
401 #    define __has_cpp_attribute(__x) 0
402 #  endif
403
404 #  ifndef __has_constexpr_builtin
405 #    define __has_constexpr_builtin(x) 0
406 #  endif
407
408 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
409 // the compiler and '1' otherwise.
410 #  ifndef __is_identifier
411 #    define __is_identifier(__x) 1
412 #  endif
413
414 #  ifndef __has_declspec_attribute
415 #    define __has_declspec_attribute(__x) 0
416 #  endif
417
418 #  define __has_keyword(__x) !(__is_identifier(__x))
419
420 #  ifndef __has_include
421 #    define __has_include(...) 0
422 #  endif
423
424 #  if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
425 #    error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
426 #  endif
427
428 // FIXME: ABI detection should be done via compiler builtin macros. This
429 // is just a placeholder until Clang implements such macros. For now assume
430 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
431 // and allow the user to explicitly specify the ABI to handle cases where this
432 // heuristic falls short.
433 #  if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
434 #    error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
435 #  elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
436 #    define _LIBCPP_ABI_ITANIUM
437 #  elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
438 #    define _LIBCPP_ABI_MICROSOFT
439 #  else
440 #    if defined(_WIN32) && defined(_MSC_VER)
441 #      define _LIBCPP_ABI_MICROSOFT
442 #    else
443 #      define _LIBCPP_ABI_ITANIUM
444 #    endif
445 #  endif
446
447 #  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
448 #    define _LIBCPP_ABI_VCRUNTIME
449 #  endif
450
451 #  if __has_feature(experimental_library)
452 #    ifndef _LIBCPP_ENABLE_EXPERIMENTAL
453 #      define _LIBCPP_ENABLE_EXPERIMENTAL
454 #    endif
455 #  endif
456
457 // Incomplete features get their own specific disabling flags. This makes it
458 // easier to grep for target specific flags once the feature is complete.
459 #  if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
460 #    define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
461 #    define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
462 #    define _LIBCPP_HAS_NO_INCOMPLETE_TZDB
463 #    define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
464 #  endif
465
466 // Need to detect which libc we're using if we're on Linux.
467 #  if defined(__linux__)
468 #    include <features.h>
469 #    if defined(__GLIBC_PREREQ)
470 #      define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
471 #    else
472 #      define _LIBCPP_GLIBC_PREREQ(a, b) 0
473 #    endif // defined(__GLIBC_PREREQ)
474 #  endif   // defined(__linux__)
475
476 #  if defined(__MVS__)
477 #    include <features.h> // for __NATIVE_ASCII_F
478 #  endif
479
480 #  ifdef __FreeBSD__
481 #    include <osreldate.h> // for __FreeBSD_version
482 #  endif
483
484 #  ifndef __BYTE_ORDER__
485 #    error                                                                                                             \
486         "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
487 #  endif
488
489 #  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
490 #    define _LIBCPP_LITTLE_ENDIAN
491 #  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
492 #    define _LIBCPP_BIG_ENDIAN
493 #  endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
494
495 #  if defined(_WIN32)
496 #    define _LIBCPP_WIN32API
497 #    define _LIBCPP_SHORT_WCHAR 1
498 // Both MinGW and native MSVC provide a "MSVC"-like environment
499 #    define _LIBCPP_MSVCRT_LIKE
500 // If mingw not explicitly detected, assume using MS C runtime only if
501 // a MS compatibility version is specified.
502 #    if defined(_MSC_VER) && !defined(__MINGW32__)
503 #      define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
504 #    endif
505 #    if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
506 #      define _LIBCPP_HAS_BITSCAN64
507 #    endif
508 #    define _LIBCPP_HAS_OPEN_WITH_WCHAR
509 #  endif // defined(_WIN32)
510
511 #  if defined(_AIX) && !defined(__64BIT__)
512 // The size of wchar is 2 byte on 32-bit mode on AIX.
513 #    define _LIBCPP_SHORT_WCHAR 1
514 #  endif
515
516 // Libc++ supports various implementations of std::random_device.
517 //
518 // _LIBCPP_USING_DEV_RANDOM
519 //      Read entropy from the given file, by default `/dev/urandom`.
520 //      If a token is provided, it is assumed to be the path to a file
521 //      to read entropy from. This is the default behavior if nothing
522 //      else is specified. This implementation requires storing state
523 //      inside `std::random_device`.
524 //
525 // _LIBCPP_USING_ARC4_RANDOM
526 //      Use arc4random(). This allows obtaining random data even when
527 //      using sandboxing mechanisms. On some platforms like Apple, this
528 //      is the recommended source of entropy for user-space programs.
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 //
532 // _LIBCPP_USING_GETENTROPY
533 //      Use getentropy().
534 //      When this option is used, the token passed to `std::random_device`'s
535 //      constructor *must* be "/dev/urandom" -- anything else is an error.
536 //
537 // _LIBCPP_USING_FUCHSIA_CPRNG
538 //      Use Fuchsia's zx_cprng_draw() system call, which is specified to
539 //      deliver high-quality entropy and cannot fail.
540 //      When this option is used, the token passed to `std::random_device`'s
541 //      constructor *must* be "/dev/urandom" -- anything else is an error.
542 //
543 // _LIBCPP_USING_NACL_RANDOM
544 //      NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
545 //      including accesses to the special files under `/dev`. This implementation
546 //      uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
547 //      When this option is used, the token passed to `std::random_device`'s
548 //      constructor *must* be "/dev/urandom" -- anything else is an error.
549 //
550 // _LIBCPP_USING_WIN32_RANDOM
551 //      Use rand_s(), for use on Windows.
552 //      When this option is used, the token passed to `std::random_device`'s
553 //      constructor *must* be "/dev/urandom" -- anything else is an error.
554 #  if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ||                     \
555       defined(__DragonFly__)
556 #    define _LIBCPP_USING_ARC4_RANDOM
557 #  elif defined(__wasi__) || defined(__EMSCRIPTEN__)
558 #    define _LIBCPP_USING_GETENTROPY
559 #  elif defined(__Fuchsia__)
560 #    define _LIBCPP_USING_FUCHSIA_CPRNG
561 #  elif defined(__native_client__)
562 #    define _LIBCPP_USING_NACL_RANDOM
563 #  elif defined(_LIBCPP_WIN32API)
564 #    define _LIBCPP_USING_WIN32_RANDOM
565 #  else
566 #    define _LIBCPP_USING_DEV_RANDOM
567 #  endif
568
569 #  ifndef _LIBCPP_CXX03_LANG
570
571 #    define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
572 #    define _ALIGNAS_TYPE(x) alignas(x)
573 #    define _ALIGNAS(x) alignas(x)
574 #    define _LIBCPP_NORETURN [[noreturn]]
575 #    define _NOEXCEPT noexcept
576 #    define _NOEXCEPT_(x) noexcept(x)
577 #    define _LIBCPP_CONSTEXPR constexpr
578
579 #  else
580
581 #    define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
582 #    define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
583 #    define _ALIGNAS(x) __attribute__((__aligned__(x)))
584 #    define _LIBCPP_NORETURN __attribute__((__noreturn__))
585 #    define _LIBCPP_HAS_NO_NOEXCEPT
586 #    define nullptr __nullptr
587 #    define _NOEXCEPT throw()
588 #    define _NOEXCEPT_(x)
589 #    define static_assert(...) _Static_assert(__VA_ARGS__)
590 #    define decltype(...) __decltype(__VA_ARGS__)
591 #    define _LIBCPP_CONSTEXPR
592
593 typedef __char16_t char16_t;
594 typedef __char32_t char32_t;
595
596 #  endif
597
598 #  if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
599 #    define _LIBCPP_HAS_NO_EXCEPTIONS
600 #  endif
601
602 #  define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
603
604 #  if defined(_LIBCPP_COMPILER_CLANG_BASED)
605
606 #    if defined(__APPLE__)
607 #      if defined(__i386__) || defined(__x86_64__)
608 // use old string layout on x86_64 and i386
609 #      elif defined(__arm__)
610 // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs
611 #        if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2
612 #          define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
613 #        endif
614 #      else
615 #        define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
616 #      endif
617 #    endif
618
619 // Objective-C++ features (opt-in)
620 #    if __has_feature(objc_arc)
621 #      define _LIBCPP_HAS_OBJC_ARC
622 #    endif
623
624 #    if __has_feature(objc_arc_weak)
625 #      define _LIBCPP_HAS_OBJC_ARC_WEAK
626 #    endif
627
628 #    if __has_extension(blocks)
629 #      define _LIBCPP_HAS_EXTENSION_BLOCKS
630 #    endif
631
632 #    if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
633 #      define _LIBCPP_HAS_BLOCKS_RUNTIME
634 #    endif
635
636 #    if !__has_feature(address_sanitizer)
637 #      define _LIBCPP_HAS_NO_ASAN
638 #    endif
639
640 #    define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
641
642 #    define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
643
644 #  elif defined(_LIBCPP_COMPILER_GCC)
645
646 #    if !defined(__SANITIZE_ADDRESS__)
647 #      define _LIBCPP_HAS_NO_ASAN
648 #    endif
649
650 #    define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
651
652 #    define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
653
654 #  endif // _LIBCPP_COMPILER_[CLANG|GCC]
655
656 #  if defined(_LIBCPP_OBJECT_FORMAT_COFF)
657
658 #    ifdef _DLL
659 #      define _LIBCPP_CRT_FUNC __declspec(dllimport)
660 #    else
661 #      define _LIBCPP_CRT_FUNC
662 #    endif
663
664 #    if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
665 #      define _LIBCPP_DLL_VIS
666 #      define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
667 #      define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
668 #      define _LIBCPP_OVERRIDABLE_FUNC_VIS
669 #      define _LIBCPP_EXPORTED_FROM_ABI
670 #    elif defined(_LIBCPP_BUILDING_LIBRARY)
671 #      define _LIBCPP_DLL_VIS __declspec(dllexport)
672 #      if defined(__MINGW32__)
673 #        define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
674 #        define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
675 #      else
676 #        define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
677 #        define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
678 #      endif
679 #      define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
680 #      define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
681 #    else
682 #      define _LIBCPP_DLL_VIS __declspec(dllimport)
683 #      define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
684 #      define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
685 #      define _LIBCPP_OVERRIDABLE_FUNC_VIS
686 #      define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
687 #    endif
688
689 #    define _LIBCPP_HIDDEN
690 #    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
691 #    define _LIBCPP_TEMPLATE_VIS
692 #    define _LIBCPP_TEMPLATE_DATA_VIS
693 #    define _LIBCPP_TYPE_VISIBILITY_DEFAULT
694
695 #  else
696
697 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
698 #      define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
699 #    else
700 #      define _LIBCPP_VISIBILITY(vis)
701 #    endif
702
703 #    define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
704 #    define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
705 #    define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
706 #    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
707 #    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
708
709 // TODO: Make this a proper customization point or remove the option to override it.
710 #    ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
711 #      define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
712 #    endif
713
714 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
715 // The inline should be removed once PR32114 is resolved
716 #      define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
717 #    else
718 #      define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
719 #    endif
720
721 // GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates
722 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__)
723 #      define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
724 #    else
725 #      define _LIBCPP_TEMPLATE_VIS
726 #    endif
727
728 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
729 #      define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default")))
730 #    else
731 #      define _LIBCPP_TYPE_VISIBILITY_DEFAULT
732 #    endif
733
734 #  endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
735
736 #  if __has_attribute(exclude_from_explicit_instantiation)
737 #    define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
738 #  else
739 // Try to approximate the effect of exclude_from_explicit_instantiation
740 // (which is that entities are not assumed to be provided by explicit
741 // template instantiations in the dylib) by always inlining those entities.
742 #    define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
743 #  endif
744
745 #  if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
746 #    define _LIBCPP_HARDENING_SIG f
747 #  elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
748 #    define _LIBCPP_HARDENING_SIG s
749 #  elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
750 #    define _LIBCPP_HARDENING_SIG d
751 #  else
752 #    define _LIBCPP_HARDENING_SIG n // "none"
753 #  endif
754
755 #  ifdef _LIBCPP_HAS_NO_EXCEPTIONS
756 #    define _LIBCPP_EXCEPTIONS_SIG n
757 #  else
758 #    define _LIBCPP_EXCEPTIONS_SIG e
759 #  endif
760
761 #  define _LIBCPP_ODR_SIGNATURE                                                                                        \
762     _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
763
764 // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
765 // on two levels:
766 // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
767 //    symbols from their dynamic library by means of using the libc++ headers. This ensures
768 //    that those symbols stay private to the dynamic library in which it is defined.
769 //
770 // 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
771 //    This ensures that no ODR violation can arise from mixing two TUs compiled with different
772 //    versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
773 //    program contains two definitions of a function, the ODR requires them to be token-by-token
774 //    equivalent, and the linker is allowed to pick either definition and discard the other one.
775 //
776 //    For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
777 //    *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
778 //    compiled with different settings), the two definitions are both visible by the linker and they
779 //    have the same name, but they have a meaningfully different implementation (one throws an exception
780 //    and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
781 //    practice what will happen is that the linker will pick one of the definitions at random and will
782 //    discard the other one. This can quite clearly lead to incorrect program behavior.
783 //
784 //    A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
785 //    property that causes the code of a function to differ from the code in another configuration
786 //    can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
787 //    tag, but we encode the ones that we think are most important: library version, exceptions, and
788 //    hardening mode.
789 //
790 //    Note that historically, solving this problem has been achieved in various ways, including
791 //    force-inlining all functions or giving internal linkage to all functions. Both these previous
792 //    solutions suffer from drawbacks that lead notably to code bloat.
793 //
794 // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
795 // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
796 //
797 // Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
798 // instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
799 // name of a virtual function is part of its ABI, since some architectures like arm64e can sign
800 // the virtual function pointer in the vtable based on the mangled name of the function. Since
801 // we use an ABI tag that changes with each released version, the mangled name of the virtual
802 // function would change, which is incorrect. Note that it doesn't make much sense to change
803 // the implementation of a virtual function in an ABI-incompatible way in the first place,
804 // since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
805 //
806 // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
807 //       the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
808 //       use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
809 #  ifndef _LIBCPP_NO_ABI_TAG
810 #    define _LIBCPP_HIDE_FROM_ABI                                                                                      \
811       _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION                                                       \
812           __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
813 #  else
814 #    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
815 #  endif
816 #  define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
817
818 // This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
819 // "C" function, as those lack mangling.
820 #  define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
821
822 #  ifdef _LIBCPP_BUILDING_LIBRARY
823 #    if _LIBCPP_ABI_VERSION > 1
824 #      define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
825 #    else
826 #      define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
827 #    endif
828 #  else
829 #    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
830 #  endif
831
832 // TODO(LLVM-19): Remove _LIBCPP_INLINE_VISIBILITY and _VSTD, which we're keeping around
833 //                only to ease the renaming for downstreams.
834 #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
835 #  define _VSTD std
836
837 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
838 // clang-format off
839 #  define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std {                                  \
840                                inline namespace _LIBCPP_ABI_NAMESPACE {
841 #  define _LIBCPP_END_NAMESPACE_STD }}
842
843 #  define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD                                               \
844                                              inline namespace __fs { namespace filesystem {
845
846 #  define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
847 // clang-format on
848
849 #  if __has_attribute(__enable_if__)
850 #    define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
851 #  endif
852
853 #  if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
854 #    define _LIBCPP_HAS_NO_INT128
855 #  endif
856
857 #  ifdef _LIBCPP_CXX03_LANG
858 #    define _LIBCPP_DECLARE_STRONG_ENUM(x)                                                                             \
859       struct _LIBCPP_EXPORTED_FROM_ABI x {                                                                             \
860         enum __lx
861 // clang-format off
862 #    define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)                                                                      \
863       __lx __v_;                                                                                                       \
864       _LIBCPP_HIDE_FROM_ABI x(__lx __v) : __v_(__v) {}                                                                 \
865       _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : __v_(static_cast<__lx>(__v)) {}                                      \
866       _LIBCPP_HIDE_FROM_ABI operator int() const { return __v_; }                                                      \
867       };
868 // clang-format on
869
870 #  else // _LIBCPP_CXX03_LANG
871 #    define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
872 #    define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
873 #  endif // _LIBCPP_CXX03_LANG
874
875 #  if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
876 #    define _LIBCPP_LOCALE__L_EXTENSIONS 1
877 #  endif
878
879 #  ifdef __FreeBSD__
880 #    define _DECLARE_C99_LDBL_MATH 1
881 #  endif
882
883 // If we are getting operator new from the MSVC CRT, then allocation overloads
884 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
885 #  if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
886 #    define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
887 #  elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
888 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
889 // have it unless the language feature test macro is defined.
890 #    define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
891 #  elif defined(__MVS__)
892 #    define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
893 #  endif
894
895 #  if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
896 #    define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
897 #  endif
898
899 // It is not yet possible to use aligned_alloc() on all Apple platforms since
900 // 10.15 was the first version to ship an implementation of aligned_alloc().
901 #  if defined(__APPLE__)
902 #    if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                                                     \
903          __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
904 #      define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
905 #    endif
906 #  elif defined(__ANDROID__) && __ANDROID_API__ < 28
907 // Android only provides aligned_alloc when targeting API 28 or higher.
908 #    define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
909 #  endif
910
911 #  if defined(__APPLE__) || defined(__FreeBSD__)
912 #    define _LIBCPP_HAS_DEFAULTRUNELOCALE
913 #  endif
914
915 #  if defined(__APPLE__) || defined(__FreeBSD__)
916 #    define _LIBCPP_WCTYPE_IS_MASK
917 #  endif
918
919 #  if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
920 #    define _LIBCPP_HAS_NO_CHAR8_T
921 #  endif
922
923 // Deprecation macros.
924 //
925 // Deprecations warnings are always enabled, except when users explicitly opt-out
926 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
927 #  if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
928 #    if __has_attribute(__deprecated__)
929 #      define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
930 #      define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
931 #    elif _LIBCPP_STD_VER >= 14
932 #      define _LIBCPP_DEPRECATED [[deprecated]]
933 #      define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
934 #    else
935 #      define _LIBCPP_DEPRECATED
936 #      define _LIBCPP_DEPRECATED_(m)
937 #    endif
938 #  else
939 #    define _LIBCPP_DEPRECATED
940 #    define _LIBCPP_DEPRECATED_(m)
941 #  endif
942
943 #  if !defined(_LIBCPP_CXX03_LANG)
944 #    define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
945 #  else
946 #    define _LIBCPP_DEPRECATED_IN_CXX11
947 #  endif
948
949 #  if _LIBCPP_STD_VER >= 14
950 #    define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
951 #  else
952 #    define _LIBCPP_DEPRECATED_IN_CXX14
953 #  endif
954
955 #  if _LIBCPP_STD_VER >= 17
956 #    define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
957 #  else
958 #    define _LIBCPP_DEPRECATED_IN_CXX17
959 #  endif
960
961 #  if _LIBCPP_STD_VER >= 20
962 #    define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
963 #  else
964 #    define _LIBCPP_DEPRECATED_IN_CXX20
965 #  endif
966
967 #  if _LIBCPP_STD_VER >= 23
968 #    define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
969 #  else
970 #    define _LIBCPP_DEPRECATED_IN_CXX23
971 #  endif
972
973 #  if !defined(_LIBCPP_HAS_NO_CHAR8_T)
974 #    define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
975 #  else
976 #    define _LIBCPP_DEPRECATED_WITH_CHAR8_T
977 #  endif
978
979 // Macros to enter and leave a state where deprecation warnings are suppressed.
980 #  if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
981 #    define _LIBCPP_SUPPRESS_DEPRECATED_PUSH                                                                           \
982       _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")                                \
983           _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
984 #    define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
985 #  else
986 #    define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
987 #    define _LIBCPP_SUPPRESS_DEPRECATED_POP
988 #  endif
989
990 #  if _LIBCPP_STD_VER <= 11
991 #    define _LIBCPP_EXPLICIT_SINCE_CXX14
992 #  else
993 #    define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
994 #  endif
995
996 #  if _LIBCPP_STD_VER >= 23
997 #    define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
998 #  else
999 #    define _LIBCPP_EXPLICIT_SINCE_CXX23
1000 #  endif
1001
1002 #  if _LIBCPP_STD_VER >= 14
1003 #    define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
1004 #  else
1005 #    define _LIBCPP_CONSTEXPR_SINCE_CXX14
1006 #  endif
1007
1008 #  if _LIBCPP_STD_VER >= 17
1009 #    define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
1010 #  else
1011 #    define _LIBCPP_CONSTEXPR_SINCE_CXX17
1012 #  endif
1013
1014 #  if _LIBCPP_STD_VER >= 20
1015 #    define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
1016 #  else
1017 #    define _LIBCPP_CONSTEXPR_SINCE_CXX20
1018 #  endif
1019
1020 #  if _LIBCPP_STD_VER >= 23
1021 #    define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
1022 #  else
1023 #    define _LIBCPP_CONSTEXPR_SINCE_CXX23
1024 #  endif
1025
1026 #  ifndef _LIBCPP_HAS_NO_ASAN
1027 extern "C" _LIBCPP_EXPORTED_FROM_ABI void
1028 __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
1029 extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
1030     const void*, const void*, const void*, const void*, const void*, const void*);
1031 extern "C" _LIBCPP_EXPORTED_FROM_ABI int
1032 __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
1033 #  endif
1034
1035 // Try to find out if RTTI is disabled.
1036 #  if !defined(__cpp_rtti) || __cpp_rtti < 199711L
1037 #    define _LIBCPP_HAS_NO_RTTI
1038 #  endif
1039
1040 #  ifndef _LIBCPP_WEAK
1041 #    define _LIBCPP_WEAK __attribute__((__weak__))
1042 #  endif
1043
1044 // Thread API
1045 // clang-format off
1046 #  if !defined(_LIBCPP_HAS_NO_THREADS) &&                                                                              \
1047       !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&                                                                      \
1048       !defined(_LIBCPP_HAS_THREAD_API_WIN32) &&                                                                        \
1049       !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1050
1051 #    if defined(__FreeBSD__) ||                                                                                        \
1052         defined(__wasi__) ||                                                                                           \
1053         defined(__NetBSD__) ||                                                                                         \
1054         defined(__OpenBSD__) ||                                                                                        \
1055         defined(__NuttX__) ||                                                                                          \
1056         defined(__linux__) ||                                                                                          \
1057         defined(__GNU__) ||                                                                                            \
1058         defined(__APPLE__) ||                                                                                          \
1059         defined(__MVS__) ||                                                                                            \
1060         defined(_AIX) ||                                                                                               \
1061         defined(__EMSCRIPTEN__)
1062 // clang-format on
1063 #      define _LIBCPP_HAS_THREAD_API_PTHREAD
1064 #    elif defined(__Fuchsia__)
1065 // TODO(44575): Switch to C11 thread API when possible.
1066 #      define _LIBCPP_HAS_THREAD_API_PTHREAD
1067 #    elif defined(_LIBCPP_WIN32API)
1068 #      define _LIBCPP_HAS_THREAD_API_WIN32
1069 #    else
1070 #      error "No thread API"
1071 #    endif // _LIBCPP_HAS_THREAD_API
1072 #  endif   // _LIBCPP_HAS_NO_THREADS
1073
1074 #  if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1075 #    if defined(__ANDROID__) && __ANDROID_API__ >= 30
1076 #      define _LIBCPP_HAS_COND_CLOCKWAIT
1077 #    elif defined(_LIBCPP_GLIBC_PREREQ)
1078 #      if _LIBCPP_GLIBC_PREREQ(2, 30)
1079 #        define _LIBCPP_HAS_COND_CLOCKWAIT
1080 #      endif
1081 #    endif
1082 #  endif
1083
1084 #  if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1085 #    error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1086        _LIBCPP_HAS_NO_THREADS is not defined.
1087 #  endif
1088
1089 #  if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1090 #    error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1091        _LIBCPP_HAS_NO_THREADS is defined.
1092 #  endif
1093
1094 #  if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1095 #    error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1096        _LIBCPP_HAS_NO_THREADS is defined.
1097 #  endif
1098
1099 #  if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1100 #    define __STDCPP_THREADS__ 1
1101 #  endif
1102
1103 // The glibc and Bionic implementation of pthreads implements
1104 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1105 // mutexes have no destroy mechanism.
1106 //
1107 // This optimization can't be performed on Apple platforms, where
1108 // pthread_mutex_destroy can allow the kernel to release resources.
1109 // See https://llvm.org/D64298 for details.
1110 //
1111 // TODO(EricWF): Enable this optimization on Bionic after speaking to their
1112 //               respective stakeholders.
1113 // clang-format off
1114 #  if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) ||                                               \
1115       (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) ||                                                 \
1116        defined(_LIBCPP_HAS_THREAD_API_WIN32)
1117 // clang-format on
1118 #    define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1119 #  endif
1120
1121 // Destroying a condvar is a nop on Windows.
1122 //
1123 // This optimization can't be performed on Apple platforms, where
1124 // pthread_cond_destroy can allow the kernel to release resources.
1125 // See https://llvm.org/D64298 for details.
1126 //
1127 // TODO(EricWF): This is potentially true for some pthread implementations
1128 // as well.
1129 #  if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1130 #    define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1131 #  endif
1132
1133 // Some systems do not provide gets() in their C library, for security reasons.
1134 #  if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
1135 #    define _LIBCPP_C_HAS_NO_GETS
1136 #  endif
1137
1138 #  if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) ||                        \
1139       defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
1140 #    define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1141 #  endif
1142
1143 #  if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1144 #    define _LIBCPP_HAS_C_ATOMIC_IMP
1145 #  elif defined(_LIBCPP_COMPILER_GCC)
1146 #    define _LIBCPP_HAS_GCC_ATOMIC_IMP
1147 #  endif
1148
1149 #  if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) &&                                    \
1150       !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
1151 #    define _LIBCPP_HAS_NO_ATOMIC_HEADER
1152 #  else
1153 #    ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1154 #      define _LIBCPP_ATOMIC_FLAG_TYPE bool
1155 #    endif
1156 #    ifdef _LIBCPP_FREESTANDING
1157 #      define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1158 #    endif
1159 #  endif
1160
1161 #  if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
1162 #    define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__))
1163 #  else
1164 #    define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
1165 #  endif
1166
1167 #  if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1168 #    if defined(__clang__) && __has_attribute(acquire_capability)
1169 // Work around the attribute handling in clang.  When both __declspec and
1170 // __attribute__ are present, the processing goes awry preventing the definition
1171 // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
1172 // combining the two does work.
1173 #      if !defined(_MSC_VER)
1174 #        define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1175 #      endif
1176 #    endif
1177 #  endif
1178
1179 #  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1180 #    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1181 #  else
1182 #    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1183 #  endif
1184
1185 #  if _LIBCPP_STD_VER >= 20
1186 #    define _LIBCPP_CONSTINIT constinit
1187 #  elif __has_attribute(__require_constant_initialization__)
1188 #    define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1189 #  else
1190 #    define _LIBCPP_CONSTINIT
1191 #  endif
1192
1193 #  if __has_attribute(__noinline__)
1194 #    define _LIBCPP_NOINLINE __attribute__((__noinline__))
1195 #  else
1196 #    define _LIBCPP_NOINLINE
1197 #  endif
1198
1199 // We often repeat things just for handling wide characters in the library.
1200 // When wide characters are disabled, it can be useful to have a quick way of
1201 // disabling it without having to resort to #if-#endif, which has a larger
1202 // impact on readability.
1203 #  if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1204 #    define _LIBCPP_IF_WIDE_CHARACTERS(...)
1205 #  else
1206 #    define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1207 #  endif
1208
1209 #  if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1210 #    define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1211 #    define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1212 #    define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1213 #    define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1214 #    define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1215 #  endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1216
1217 #  if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1218 #    define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1219 #    define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1220 #    define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1221 #    define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1222 #    define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1223 #    define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1224 #  endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1225
1226 // clang-format off
1227 #  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()\")")
1228 #  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()\")")
1229 // clang-format on
1230
1231 #  ifndef _LIBCPP_NO_AUTO_LINK
1232 #    if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1233 #      if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
1234 #        pragma comment(lib, "c++.lib")
1235 #      else
1236 #        pragma comment(lib, "libc++.lib")
1237 #      endif
1238 #    endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1239 #  endif   // _LIBCPP_NO_AUTO_LINK
1240
1241 // Configures the fopen close-on-exec mode character, if any. This string will
1242 // be appended to any mode string used by fstream for fopen/fdopen.
1243 //
1244 // Not all platforms support this, but it helps avoid fd-leaks on platforms that
1245 // do.
1246 #  if defined(__BIONIC__)
1247 #    define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1248 #  else
1249 #    define _LIBCPP_FOPEN_CLOEXEC_MODE
1250 #  endif
1251
1252 #  if __has_cpp_attribute(msvc::no_unique_address)
1253 // MSVC implements [[no_unique_address]] as a silent no-op currently.
1254 // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1255 // However, MSVC implements [[msvc::no_unique_address]] which does what
1256 // [[no_unique_address]] is supposed to do, in general.
1257
1258 // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1259 // [[msvc::no_unique_address]] though. If/when it does implement
1260 // [[msvc::no_unique_address]], this should be preferred though.
1261 #    define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1262 #  elif __has_cpp_attribute(no_unique_address)
1263 #    define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1264 #  else
1265 #    define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
1266 // Note that this can be replaced by #error as soon as clang-cl
1267 // implements msvc::no_unique_address, since there should be no C++20
1268 // compiler that doesn't support one of the two attributes at that point.
1269 // We generally don't want to use this macro outside of C++20-only code,
1270 // because using it conditionally in one language version only would make
1271 // the ABI inconsistent.
1272 #  endif
1273
1274 #  ifdef _LIBCPP_COMPILER_CLANG_BASED
1275 #    define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1276 #    define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1277 #    define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1278 #    define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1279 #  elif defined(_LIBCPP_COMPILER_GCC)
1280 #    define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1281 #    define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1282 #    define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1283 #    define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1284 #  else
1285 #    define _LIBCPP_DIAGNOSTIC_PUSH
1286 #    define _LIBCPP_DIAGNOSTIC_POP
1287 #    define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1288 #    define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1289 #  endif
1290
1291 // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1292 // functions is gradually being added to existing C libraries. The conditions
1293 // below check for known C library versions and conditions under which these
1294 // functions are declared by the C library.
1295 #  define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1296 // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1297 // __cpp_char8_t is defined or if C2X extensions are enabled. Determining
1298 // the latter depends on internal GNU libc details that are not appropriate
1299 // to depend on here, so any declarations present when __cpp_char8_t is not
1300 // defined are ignored.
1301 #  if defined(_LIBCPP_GLIBC_PREREQ)
1302 #    if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
1303 #      undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1304 #    endif
1305 #  endif
1306
1307 // There are a handful of public standard library types that are intended to
1308 // support CTAD but don't need any explicit deduction guides to do so. This
1309 // macro is used to mark them as such, which suppresses the
1310 // '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
1311 // with these classes.
1312 #  if _LIBCPP_STD_VER >= 17
1313 #    ifdef _LIBCPP_COMPILER_CLANG_BASED
1314 #      define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName)                                                              \
1315         template <class... _Tag>                                                                                       \
1316         [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
1317 #    else
1318 #      define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName)                                                               \
1319         template <class... _Tag>                                                                                       \
1320         ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
1321 #    endif
1322 #  else
1323 #    define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1324 #  endif
1325
1326 // TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
1327 // compiler intrinsics in the Objective-C++ mode.
1328 #  ifdef __OBJC__
1329 #    define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1330 #  endif
1331
1332 #  define _PSTL_PRAGMA(x) _Pragma(#x)
1333
1334 // Enable SIMD for compilers that support OpenMP 4.0
1335 #  if (defined(_OPENMP) && _OPENMP >= 201307)
1336
1337 #    define _PSTL_UDR_PRESENT
1338 #    define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
1339 #    define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
1340 #    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
1341 #    define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
1342 #    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
1343 #    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
1344
1345 // Declaration of reduction functor, where
1346 // NAME - the name of the functor
1347 // OP - type of the callable object with the reduction operation
1348 // omp_in - refers to the local partial result
1349 // omp_out - refers to the final value of the combiner operator
1350 // omp_priv - refers to the private copy of the initial value
1351 // omp_orig - refers to the original variable to be reduced
1352 #    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)                                                                   \
1353       _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
1354
1355 #  elif defined(_LIBCPP_COMPILER_CLANG_BASED)
1356
1357 #    define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
1358 #    define _PSTL_PRAGMA_DECLARE_SIMD
1359 #    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1360 #    define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
1361 #    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1362 #    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1363 #    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1364
1365 #  else // (defined(_OPENMP) && _OPENMP >= 201307)
1366
1367 #    define _PSTL_PRAGMA_SIMD
1368 #    define _PSTL_PRAGMA_DECLARE_SIMD
1369 #    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
1370 #    define _PSTL_PRAGMA_SIMD_SCAN(PRM)
1371 #    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
1372 #    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
1373 #    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
1374
1375 #  endif // (defined(_OPENMP) && _OPENMP >= 201307)
1376
1377 #  define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
1378
1379 // Optional attributes - these are useful for a better QoI, but not required to be available
1380
1381 #  if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
1382 #    define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
1383 #  else
1384 #    define _LIBCPP_NO_CFI
1385 #  endif
1386
1387 #  if __has_attribute(__malloc__)
1388 #    define _LIBCPP_NOALIAS __attribute__((__malloc__))
1389 #  else
1390 #    define _LIBCPP_NOALIAS
1391 #  endif
1392
1393 #  if __has_attribute(__using_if_exists__)
1394 #    define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
1395 #  else
1396 #    define _LIBCPP_USING_IF_EXISTS
1397 #  endif
1398
1399 #  if __has_cpp_attribute(nodiscard)
1400 #    define _LIBCPP_NODISCARD [[__nodiscard__]]
1401 #  else
1402 // We can't use GCC's [[gnu::warn_unused_result]] and
1403 // __attribute__((warn_unused_result)), because GCC does not silence them via
1404 // (void) cast.
1405 #    define _LIBCPP_NODISCARD
1406 #  endif
1407
1408 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1409 // specified as such as an extension.
1410 #  if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1411 #    define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1412 #  else
1413 #    define _LIBCPP_NODISCARD_EXT
1414 #  endif
1415
1416 #  if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1417 #    define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1418 #  else
1419 #    define _LIBCPP_NODISCARD_AFTER_CXX17
1420 #  endif
1421
1422 #  if __has_attribute(__no_destroy__)
1423 #    define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1424 #  else
1425 #    define _LIBCPP_NO_DESTROY
1426 #  endif
1427
1428 #  if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1429 #    define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
1430 #  else
1431 #    define _LIBCPP_DIAGNOSE_WARNING(...)
1432 #  endif
1433
1434 // Use a function like macro to imply that it must be followed by a semicolon
1435 #  if __has_cpp_attribute(fallthrough)
1436 #    define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1437 #  elif __has_attribute(__fallthrough__)
1438 #    define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1439 #  else
1440 #    define _LIBCPP_FALLTHROUGH() ((void)0)
1441 #  endif
1442
1443 #  if __has_cpp_attribute(_Clang::__lifetimebound__)
1444 #    define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1445 #  else
1446 #    define _LIBCPP_LIFETIMEBOUND
1447 #  endif
1448
1449 #  if __has_attribute(__nodebug__)
1450 #    define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1451 #  else
1452 #    define _LIBCPP_NODEBUG
1453 #  endif
1454
1455 #  if __has_attribute(__standalone_debug__)
1456 #    define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
1457 #  else
1458 #    define _LIBCPP_STANDALONE_DEBUG
1459 #  endif
1460
1461 #  if __has_attribute(__preferred_name__)
1462 #    define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
1463 #  else
1464 #    define _LIBCPP_PREFERRED_NAME(x)
1465 #  endif
1466
1467 #  if __has_attribute(__no_sanitize__)
1468 #    define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1469 #  else
1470 #    define _LIBCPP_NO_SANITIZE(...)
1471 #  endif
1472
1473 #  if __has_attribute(__init_priority__)
1474 #    define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1475 #  else
1476 #    define _LIBCPP_INIT_PRIORITY_MAX
1477 #  endif
1478
1479 #  if __has_attribute(__format__)
1480 // The attribute uses 1-based indices for ordinary and static member functions.
1481 // The attribute uses 2-based indices for non-static member functions.
1482 #    define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index)                           \
1483       __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1484 #  else
1485 #    define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1486 #  endif
1487
1488 #  if __has_attribute(__packed__)
1489 #    define _LIBCPP_PACKED __attribute__((__packed__))
1490 #  else
1491 #    define _LIBCPP_PACKED
1492 #  endif
1493
1494 #  if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1495 #    define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1496 #  else
1497 #    define _LIBCPP_DECLSPEC_EMPTY_BASES
1498 #  endif
1499
1500 // Allow for build-time disabling of unsigned integer sanitization
1501 #  if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
1502 #    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
1503 #  else
1504 #    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1505 #  endif
1506
1507 #endif // __cplusplus
1508
1509 #endif // _LIBCPP___CONFIG