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/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14#include <__configuration/abi.h>
15#include <__configuration/availability.h>
16#include <__configuration/compiler.h>
17#include <__configuration/experimental.h>
18#include <__configuration/hardening.h>
19#include <__configuration/language.h>
20#include <__configuration/platform.h>
21
22#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
23# pragma GCC system_header
24#endif
25
26#ifdef __cplusplus
27
28// The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
29
30// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
31// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
32// defined to XXYYZZ.
33# define _LIBCPP_VERSION 220108
34
35# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
36# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
37# define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z))
38
39# if __STDC_HOSTED__ == 0
40# define _LIBCPP_FREESTANDING
41# endif
42
43# define _LIBCPP_TOSTRING2(x) #x
44# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
45
46# ifndef __has_constexpr_builtin
47# define __has_constexpr_builtin(x) 0
48# endif
49
50// This checks wheter a Clang module is built
51# ifndef __building_module
52# define __building_module(...) 0
53# endif
54
55// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
56// the compiler and '1' otherwise.
57# ifndef __is_identifier
58# define __is_identifier(__x) 1
59# endif
60
61# ifndef __has_declspec_attribute
62# define __has_declspec_attribute(__x) 0
63# endif
64
65# define __has_keyword(__x) !(__is_identifier(__x))
66
67# ifndef __has_warning
68# define __has_warning(...) 0
69# endif
70
71# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
72# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
73# endif
74
75# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
76# define _LIBCPP_ABI_VCRUNTIME
77# endif
78
79# if defined(__MVS__)
80# include <features.h> // for __NATIVE_ASCII_F
81# endif
82
83# if defined(_WIN32)
84# define _LIBCPP_WIN32API
85# define _LIBCPP_SHORT_WCHAR 1
86// Both MinGW and native MSVC provide a "MSVC"-like environment
87# define _LIBCPP_MSVCRT_LIKE
88// If mingw not explicitly detected, assume using MS C runtime only if
89// a MS compatibility version is specified.
90# if defined(_MSC_VER) && !defined(__MINGW32__)
91# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
92# endif
93# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
94# define _LIBCPP_HAS_BITSCAN64 1
95# else
96# define _LIBCPP_HAS_BITSCAN64 0
97# endif
98# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1
99# else
100# define _LIBCPP_HAS_OPEN_WITH_WCHAR 0
101# define _LIBCPP_HAS_BITSCAN64 0
102# endif // defined(_WIN32)
103
104# if defined(_AIX) && !defined(__64BIT__)
105// The size of wchar is 2 byte on 32-bit mode on AIX.
106# define _LIBCPP_SHORT_WCHAR 1
107# endif
108
109// Libc++ supports various implementations of std::random_device.
110//
111// _LIBCPP_USING_DEV_RANDOM
112// Read entropy from the given file, by default `/dev/urandom`.
113// If a token is provided, it is assumed to be the path to a file
114// to read entropy from. This is the default behavior if nothing
115// else is specified. This implementation requires storing state
116// inside `std::random_device`.
117//
118// _LIBCPP_USING_ARC4_RANDOM
119// Use arc4random(). This allows obtaining random data even when
120// using sandboxing mechanisms. On some platforms like Apple, this
121// is the recommended source of entropy for user-space programs.
122// When this option is used, the token passed to `std::random_device`'s
123// constructor *must* be "/dev/urandom" -- anything else is an error.
124//
125// _LIBCPP_USING_GETENTROPY
126// Use getentropy().
127// When this option is used, the token passed to `std::random_device`'s
128// constructor *must* be "/dev/urandom" -- anything else is an error.
129//
130// _LIBCPP_USING_FUCHSIA_CPRNG
131// Use Fuchsia's zx_cprng_draw() system call, which is specified to
132// deliver high-quality entropy and cannot fail.
133// When this option is used, the token passed to `std::random_device`'s
134// constructor *must* be "/dev/urandom" -- anything else is an error.
135//
136// _LIBCPP_USING_WIN32_RANDOM
137// Use rand_s(), for use on Windows.
138// When this option is used, the token passed to `std::random_device`'s
139// constructor *must* be "/dev/urandom" -- anything else is an error.
140# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
141 defined(__DragonFly__)
142# define _LIBCPP_USING_ARC4_RANDOM
143# elif defined(__wasi__) || defined(__EMSCRIPTEN__)
144# define _LIBCPP_USING_GETENTROPY
145# elif defined(__Fuchsia__)
146# define _LIBCPP_USING_FUCHSIA_CPRNG
147# elif defined(_LIBCPP_WIN32API)
148# define _LIBCPP_USING_WIN32_RANDOM
149# else
150# define _LIBCPP_USING_DEV_RANDOM
151# endif
152
153# ifndef _LIBCPP_CXX03_LANG
154
155# define _LIBCPP_ALIGNOF(...) alignof(__VA_ARGS__)
156# define _ALIGNAS_TYPE(x) alignas(x)
157# define _ALIGNAS(x) alignas(x)
158# define _NOEXCEPT noexcept
159# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
160# define _LIBCPP_CONSTEXPR constexpr
161
162# else
163
164# define _LIBCPP_ALIGNOF(...) _Alignof(__VA_ARGS__)
165# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
166# define _ALIGNAS(x) __attribute__((__aligned__(x)))
167# define nullptr __nullptr
168# define _NOEXCEPT throw()
169# define _NOEXCEPT_(...)
170# define static_assert(...) _Static_assert(__VA_ARGS__)
171# define decltype(...) __decltype(__VA_ARGS__)
172# define _LIBCPP_CONSTEXPR
173
174typedef __char16_t char16_t;
175typedef __char32_t char32_t;
176
177# endif
178
179# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
180
181# if __has_extension(blocks) && defined(__APPLE__)
182# define _LIBCPP_HAS_BLOCKS_RUNTIME 1
183# else
184# define _LIBCPP_HAS_BLOCKS_RUNTIME 0
185# endif
186
187# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
188
189# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
190
191# ifdef _DLL
192# define _LIBCPP_CRT_FUNC __declspec(dllimport)
193# else
194# define _LIBCPP_CRT_FUNC
195# endif
196
197# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
198# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
199# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
200# define _LIBCPP_OVERRIDABLE_FUNC_VIS
201# define _LIBCPP_EXPORTED_FROM_ABI
202# elif defined(_LIBCPP_BUILDING_LIBRARY)
203# if defined(__MINGW32__)
204# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
205# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
206# else
207# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
208# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
209# endif
210# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
211# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
212# else
213# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
214# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
215# define _LIBCPP_OVERRIDABLE_FUNC_VIS
216# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
217# endif
218
219# define _LIBCPP_HIDDEN
220# define _LIBCPP_TEMPLATE_DATA_VIS
221# define _LIBCPP_NAMESPACE_VISIBILITY
222
223# else
224
225# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
226# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
227# else
228# define _LIBCPP_VISIBILITY(vis)
229# endif
230
231# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
232# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
233# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
234# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
235# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
236
237// TODO: Make this a proper customization point or remove the option to override it.
238# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
239# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
240# endif
241
242# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
243# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
244# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
245# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
246# else
247# define _LIBCPP_NAMESPACE_VISIBILITY
248# endif
249
250# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
251
252# if __has_attribute(exclude_from_explicit_instantiation)
253# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
254# else
255// Try to approximate the effect of exclude_from_explicit_instantiation
256// (which is that entities are not assumed to be provided by explicit
257// template instantiations in the dylib) by always inlining those entities.
258# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
259# endif
260
261# ifdef _LIBCPP_COMPILER_CLANG_BASED
262# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
263# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
264# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
265# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
266# elif defined(_LIBCPP_COMPILER_GCC)
267# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
268# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
269# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
270# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
271# else
272# define _LIBCPP_DIAGNOSTIC_PUSH
273# define _LIBCPP_DIAGNOSTIC_POP
274# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
275# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
276# endif
277
278// Macros to enter and leave a state where deprecation warnings are suppressed.
279# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
280 _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") \
281 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
282# define _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_DIAGNOSTIC_POP
283
284# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
285# define _LIBCPP_HARDENING_SIG f
286# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
287# define _LIBCPP_HARDENING_SIG s
288# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
289# define _LIBCPP_HARDENING_SIG d
290# else
291# define _LIBCPP_HARDENING_SIG n // "none"
292# endif
293
294# if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE
295# define _LIBCPP_ASSERTION_SEMANTIC_SIG o
296# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
297# define _LIBCPP_ASSERTION_SEMANTIC_SIG q
298# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
299# define _LIBCPP_ASSERTION_SEMANTIC_SIG e
300# else
301# define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore`
302# endif
303
304# if !_LIBCPP_HAS_EXCEPTIONS
305# define _LIBCPP_EXCEPTIONS_SIG n
306# else
307# define _LIBCPP_EXCEPTIONS_SIG e
308# endif
309
310# define _LIBCPP_ODR_SIGNATURE \
311 _LIBCPP_CONCAT( \
312 _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \
313 _LIBCPP_VERSION)
314
315// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
316// on two levels:
317// 1. The symbol is given hidden visibility, which ensures that users won't start exporting
318// symbols from their dynamic library by means of using the libc++ headers. This ensures
319// that those symbols stay private to the dynamic library in which it is defined.
320//
321// 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
322// This ensures that no ODR violation can arise from mixing two TUs compiled with different
323// versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
324// program contains two definitions of a function, the ODR requires them to be token-by-token
325// equivalent, and the linker is allowed to pick either definition and discard the other one.
326//
327// For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
328// *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
329// compiled with different settings), the two definitions are both visible by the linker and they
330// have the same name, but they have a meaningfully different implementation (one throws an exception
331// and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
332// practice what will happen is that the linker will pick one of the definitions at random and will
333// discard the other one. This can quite clearly lead to incorrect program behavior.
334//
335// A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
336// property that causes the code of a function to differ from the code in another configuration
337// can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
338// tag, but we encode the ones that we think are most important: library version, exceptions, and
339// hardening mode.
340//
341// Note that historically, solving this problem has been achieved in various ways, including
342// force-inlining all functions or giving internal linkage to all functions. Both these previous
343// solutions suffer from drawbacks that lead notably to code bloat.
344//
345// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
346// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
347//
348// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
349// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
350// name of a virtual function is part of its ABI, since some architectures like arm64e can sign
351// the virtual function pointer in the vtable based on the mangled name of the function. Since
352// we use an ABI tag that changes with each released version, the mangled name of the virtual
353// function would change, which is incorrect. Note that it doesn't make much sense to change
354// the implementation of a virtual function in an ABI-incompatible way in the first place,
355// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
356//
357// The macro can be applied to record and enum types. When the tagged type is nested in
358// a record this "parent" record needs to have the macro too. Another use case for applying
359// this macro to records and unions is to apply an ABI tag to inline constexpr variables.
360// This can be useful for inline variables that are implementation details which are expected
361// to change in the future.
362//
363// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
364// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
365// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
366# ifndef _LIBCPP_NO_ABI_TAG
367# define _LIBCPP_HIDE_FROM_ABI \
368 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
369 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
370# else
371# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
372# endif
373# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
374
375// Clang modules take a significant compile time hit when pushing and popping diagnostics.
376// Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can
377// simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined.
378# ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
379# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
380 _LIBCPP_DIAGNOSTIC_PUSH \
381 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
382 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
383 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
384 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
385 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
386 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
387 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
388 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
389 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
390# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
391# else
392# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
393# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
394# endif
395
396// clang-format off
397
398// The unversioned namespace is used when we want to be ABI compatible with other standard libraries in some way. There
399// are two main categories where that's the case:
400// - Historically, we have made exception types ABI compatible with libstdc++ to allow throwing them between libstdc++
401// and libc++. This is not used anymore for new exception types, since there is no use-case for it anymore.
402// - Types and functions which are used by the compiler are in the unversioned namespace, since the compiler has to know
403// their mangling without the appropriate declaration in some cases.
404// If it's not clear whether using the unversioned namespace is the correct thing to do, it's not. The versioned
405// namespace (_LIBCPP_BEGIN_NAMESPACE_STD) should almost always be used.
406# define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \
407 _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_NAMESPACE_VISIBILITY std {
408
409# define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_POP_EXTENSION_DIAGNOSTICS
410
411# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD inline namespace _LIBCPP_ABI_NAMESPACE {
412# define _LIBCPP_END_NAMESPACE_STD } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
413
414// TODO: This should really be in the versioned namespace
415#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD namespace experimental {
416#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
417
418#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
419#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
420
421#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
422#define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
423
424#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
425# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
426# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
427#else
428# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
429 inline namespace __fs { namespace filesystem {
430
431# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
432#endif
433
434// clang-format on
435
436# if __has_attribute(__enable_if__)
437# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
438# endif
439
440# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
441# define _LIBCPP_HAS_INT128 0
442# else
443# define _LIBCPP_HAS_INT128 1
444# endif
445
446# ifdef _LIBCPP_CXX03_LANG
447# define _LIBCPP_DECLARE_STRONG_ENUM(x) \
448 struct _LIBCPP_EXPORTED_FROM_ABI x { \
449 enum __lx
450// clang-format off
451# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
452 __lx __v_; \
453 _LIBCPP_HIDE_FROM_ABI x(__lx __v) : __v_(__v) {} \
454 _LIBCPP_HIDE_FROM_ABI explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
455 _LIBCPP_HIDE_FROM_ABI operator int() const { return __v_; } \
456 };
457// clang-format on
458
459# else // _LIBCPP_CXX03_LANG
460# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
461# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
462# endif // _LIBCPP_CXX03_LANG
463
464# ifdef __FreeBSD__
465# define _DECLARE_C99_LDBL_MATH 1
466# endif
467
468/* zig patch: compiler defines _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION in some cases */
469# if !defined(_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION)
470// If we are getting operator new from the MSVC CRT, then allocation overloads
471// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
472# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
473# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
474# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
475// We're deferring to Microsoft's STL to provide aligned new et al. We don't
476// have it unless the language feature test macro is defined.
477# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
478# elif defined(__MVS__)
479# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
480# else
481# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 1
482# endif
483
484# if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
485# define _LIBCPP_HAS_ALIGNED_ALLOCATION 0
486# else
487# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
488# endif
489# endif
490
491# if defined(__APPLE__) || defined(__FreeBSD__)
492# define _LIBCPP_WCTYPE_IS_MASK
493# endif
494
495# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
496# define _LIBCPP_HAS_CHAR8_T 0
497# else
498# define _LIBCPP_HAS_CHAR8_T 1
499# endif
500
501// Deprecation macros.
502//
503// Deprecations warnings are always enabled, except when users explicitly opt-out
504// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
505# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
506# if __has_attribute(__deprecated__)
507# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
508# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
509# elif _LIBCPP_STD_VER >= 14
510# define _LIBCPP_DEPRECATED [[deprecated]]
511# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
512# else
513# define _LIBCPP_DEPRECATED
514# define _LIBCPP_DEPRECATED_(m)
515# endif
516# else
517# define _LIBCPP_DEPRECATED
518# define _LIBCPP_DEPRECATED_(m)
519# endif
520
521// FIXME: using `#warning` causes diagnostics from system headers which include deprecated headers. This can only be
522// enabled again once https://github.com/llvm/llvm-project/pull/168041 (or a similar feature) has landed, since that
523// allows suppression in system headers.
524# if defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && 0
525# define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 1
526# else
527# define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 0
528# endif
529
530# if !defined(_LIBCPP_CXX03_LANG)
531# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
532# else
533# define _LIBCPP_DEPRECATED_IN_CXX11
534# endif
535
536# if _LIBCPP_STD_VER >= 14
537# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
538# else
539# define _LIBCPP_DEPRECATED_IN_CXX14
540# endif
541
542# if _LIBCPP_STD_VER >= 17
543# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
544# else
545# define _LIBCPP_DEPRECATED_IN_CXX17
546# endif
547
548# if _LIBCPP_STD_VER >= 20
549# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
550# else
551# define _LIBCPP_DEPRECATED_IN_CXX20
552# endif
553
554# if _LIBCPP_STD_VER >= 23
555# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
556# else
557# define _LIBCPP_DEPRECATED_IN_CXX23
558# endif
559
560# if _LIBCPP_STD_VER >= 26
561# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
562# define _LIBCPP_DEPRECATED_IN_CXX26_(m) _LIBCPP_DEPRECATED_(m)
563# else
564# define _LIBCPP_DEPRECATED_IN_CXX26
565# define _LIBCPP_DEPRECATED_IN_CXX26_(m)
566# endif
567
568# if _LIBCPP_HAS_CHAR8_T
569# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
570# else
571# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
572# endif
573
574# if _LIBCPP_STD_VER <= 11
575# define _LIBCPP_EXPLICIT_SINCE_CXX14
576# else
577# define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
578# endif
579
580# if _LIBCPP_STD_VER >= 23
581# define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
582# else
583# define _LIBCPP_EXPLICIT_SINCE_CXX23
584# endif
585
586# if _LIBCPP_STD_VER >= 14
587# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
588# else
589# define _LIBCPP_CONSTEXPR_SINCE_CXX14
590# endif
591
592# if _LIBCPP_STD_VER >= 17
593# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
594# else
595# define _LIBCPP_CONSTEXPR_SINCE_CXX17
596# endif
597
598# if _LIBCPP_STD_VER >= 20
599# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
600# else
601# define _LIBCPP_CONSTEXPR_SINCE_CXX20
602# endif
603
604# if _LIBCPP_STD_VER >= 23
605# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
606# else
607# define _LIBCPP_CONSTEXPR_SINCE_CXX23
608# endif
609
610# if _LIBCPP_STD_VER >= 26
611# define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr
612# else
613# define _LIBCPP_CONSTEXPR_SINCE_CXX26
614# endif
615
616# ifndef _LIBCPP_WEAK
617# define _LIBCPP_WEAK __attribute__((__weak__))
618# endif
619
620// Thread API
621// clang-format off
622# if _LIBCPP_HAS_THREADS && \
623 !_LIBCPP_HAS_THREAD_API_PTHREAD && \
624 !_LIBCPP_HAS_THREAD_API_WIN32 && \
625 !_LIBCPP_HAS_THREAD_API_EXTERNAL
626
627# if defined(__FreeBSD__) || \
628 defined(__wasi__) || \
629 defined(__NetBSD__) || \
630 defined(__OpenBSD__) || \
631 defined(__NuttX__) || \
632 defined(__linux__) || \
633 defined(__GNU__) || \
634 defined(__APPLE__) || \
635 defined(__MVS__) || \
636 defined(_AIX) || \
637 defined(__EMSCRIPTEN__)
638// clang-format on
639# undef _LIBCPP_HAS_THREAD_API_PTHREAD
640# define _LIBCPP_HAS_THREAD_API_PTHREAD 1
641# elif defined(__Fuchsia__)
642// TODO(44575): Switch to C11 thread API when possible.
643# undef _LIBCPP_HAS_THREAD_API_PTHREAD
644# define _LIBCPP_HAS_THREAD_API_PTHREAD 1
645# elif defined(_LIBCPP_WIN32API)
646# undef _LIBCPP_HAS_THREAD_API_WIN32
647# define _LIBCPP_HAS_THREAD_API_WIN32 1
648# else
649# error "No thread API"
650# endif // _LIBCPP_HAS_THREAD_API
651# endif // _LIBCPP_HAS_THREADS
652
653# if !_LIBCPP_HAS_THREAD_API_PTHREAD
654# define _LIBCPP_HAS_COND_CLOCKWAIT 0
655# elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
656# define _LIBCPP_HAS_COND_CLOCKWAIT 1
657# else
658# define _LIBCPP_HAS_COND_CLOCKWAIT 0
659# endif
660
661# if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_PTHREAD
662# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be true when _LIBCPP_HAS_THREADS is true.
663# endif
664
665# if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_EXTERNAL
666# error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true.
667# endif
668
669# if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS
670# error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false.
671# endif
672
673# if _LIBCPP_HAS_THREADS && !defined(__STDCPP_THREADS__)
674# define __STDCPP_THREADS__ 1
675# endif
676
677// The glibc and Bionic implementation of pthreads implements
678// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
679// mutexes have no destroy mechanism.
680//
681// This optimization can't be performed on Apple platforms, where
682// pthread_mutex_destroy can allow the kernel to release resources.
683// See https://llvm.org/D64298 for details.
684//
685// TODO(EricWF): Enable this optimization on Bionic after speaking to their
686// respective stakeholders.
687// clang-format off
688# if (_LIBCPP_HAS_THREAD_API_PTHREAD && defined(__GLIBC__)) || \
689 (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || \
690 _LIBCPP_HAS_THREAD_API_WIN32
691// clang-format on
692# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1
693# else
694# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0
695# endif
696
697// Destroying a condvar is a nop on Windows.
698//
699// This optimization can't be performed on Apple platforms, where
700// pthread_cond_destroy can allow the kernel to release resources.
701// See https://llvm.org/D64298 for details.
702//
703// TODO(EricWF): This is potentially true for some pthread implementations
704// as well.
705# if (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || _LIBCPP_HAS_THREAD_API_WIN32
706# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1
707# else
708# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0
709# endif
710
711# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
712 _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__)
713# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
714# endif
715
716# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
717# define _LIBCPP_HAS_C_ATOMIC_IMP 1
718# define _LIBCPP_HAS_GCC_ATOMIC_IMP 0
719# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
720# elif defined(_LIBCPP_COMPILER_GCC)
721# define _LIBCPP_HAS_C_ATOMIC_IMP 0
722# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1
723# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
724# endif
725
726# if !_LIBCPP_HAS_C_ATOMIC_IMP && !_LIBCPP_HAS_GCC_ATOMIC_IMP && !_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP
727# define _LIBCPP_HAS_ATOMIC_HEADER 0
728# else
729# define _LIBCPP_HAS_ATOMIC_HEADER 1
730# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
731# define _LIBCPP_ATOMIC_FLAG_TYPE bool
732# endif
733# endif
734
735# if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__)
736# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]]
737# else
738# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
739# endif
740
741# if _LIBCPP_STD_VER >= 20
742# define _LIBCPP_CONSTINIT constinit
743# elif __has_attribute(__require_constant_initialization__)
744# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
745# else
746# define _LIBCPP_CONSTINIT
747# endif
748
749# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
750// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
751// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
752// when compiling for CUDA we use the non-underscored version of the noinline
753// attribute.
754//
755// This is a temporary workaround and we still expect the CUDA SDK team to solve
756// this issue properly in the SDK headers.
757//
758// See https://github.com/llvm/llvm-project/pull/73838 for more details.
759# define _LIBCPP_NOINLINE __attribute__((noinline))
760# elif __has_attribute(__noinline__)
761# define _LIBCPP_NOINLINE __attribute__((__noinline__))
762# else
763# define _LIBCPP_NOINLINE
764# endif
765
766// We often repeat things just for handling wide characters in the library.
767// When wide characters are disabled, it can be useful to have a quick way of
768// disabling it without having to resort to #if-#endif, which has a larger
769// impact on readability.
770# if !_LIBCPP_HAS_WIDE_CHARACTERS
771# define _LIBCPP_IF_WIDE_CHARACTERS(...)
772# else
773# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
774# endif
775
776// clang-format off
777# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh\")") _Pragma("push_macro(\"move\")") _Pragma("push_macro(\"erase\")")
778# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh\")") _Pragma("pop_macro(\"move\")") _Pragma("pop_macro(\"erase\")")
779// clang-format on
780
781# ifndef _LIBCPP_NO_AUTO_LINK
782# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
783# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
784# pragma comment(lib, "c++.lib")
785# else
786# pragma comment(lib, "libc++.lib")
787# endif
788# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
789# endif // _LIBCPP_NO_AUTO_LINK
790
791// Configures the fopen close-on-exec mode character, if any. This string will
792// be appended to any mode string used by fstream for fopen/fdopen.
793//
794// Not all platforms support this, but it helps avoid fd-leaks on platforms that
795// do.
796# if defined(__BIONIC__)
797# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
798# else
799# define _LIBCPP_FOPEN_CLOEXEC_MODE
800# endif
801
802# if __has_cpp_attribute(msvc::no_unique_address)
803// MSVC implements [[no_unique_address]] as a silent no-op currently.
804// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
805// However, MSVC implements [[msvc::no_unique_address]] which does what
806// [[no_unique_address]] is supposed to do, in general.
807# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
808# else
809# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
810# endif
811
812// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
813// functions is gradually being added to existing C libraries. The conditions
814// below check for known C library versions and conditions under which these
815// functions are declared by the C library.
816//
817// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
818// __cpp_char8_t is defined or if C2X extensions are enabled. Determining
819// the latter depends on internal GNU libc details that are not appropriate
820// to depend on here, so any declarations present when __cpp_char8_t is not
821// defined are ignored.
822# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
823# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
824# else
825# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
826# endif
827
828// There are a handful of public standard library types that are intended to
829// support CTAD but don't need any explicit deduction guides to do so. This
830// macro is used to mark them as such, which suppresses the
831// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
832// with these classes.
833# if _LIBCPP_STD_VER >= 17
834# ifdef _LIBCPP_COMPILER_CLANG_BASED
835# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
836 template <class... _Tag> \
837 [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
838# else
839# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
840 template <class... _Tag> \
841 ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
842# endif
843# else
844# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
845# endif
846
847# if defined(__OBJC__) && defined(_LIBCPP_APPLE_CLANG_VER)
848# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
849# endif
850
851# define _PSTL_PRAGMA(x) _Pragma(#x)
852
853// Enable SIMD for compilers that support OpenMP 4.0
854# if (defined(_OPENMP) && _OPENMP >= 201307)
855
856# define _PSTL_UDR_PRESENT
857# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
858# define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
859# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
860# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
861# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
862# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
863
864// Declaration of reduction functor, where
865// NAME - the name of the functor
866// OP - type of the callable object with the reduction operation
867// omp_in - refers to the local partial result
868// omp_out - refers to the final value of the combiner operator
869// omp_priv - refers to the private copy of the initial value
870// omp_orig - refers to the original variable to be reduced
871# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
872 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
873
874# elif defined(_LIBCPP_COMPILER_CLANG_BASED)
875
876# define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
877# define _PSTL_PRAGMA_DECLARE_SIMD
878# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
879# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
880# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
881# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
882# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
883
884# else // (defined(_OPENMP) && _OPENMP >= 201307)
885
886# define _PSTL_PRAGMA_SIMD
887# define _PSTL_PRAGMA_DECLARE_SIMD
888# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
889# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
890# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
891# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
892# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
893
894# endif // (defined(_OPENMP) && _OPENMP >= 201307)
895
896# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
897
898// Optional attributes - these are useful for a better QoI, but not required to be available
899
900# define _LIBCPP_NOALIAS __attribute__((__malloc__))
901# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
902# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
903# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
904# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
905 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
906# define _LIBCPP_PACKED __attribute__((__packed__))
907
908# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
909# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
910# else
911# define _LIBCPP_NO_CFI
912# endif
913
914# if __has_attribute(__using_if_exists__)
915# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
916# else
917# define _LIBCPP_USING_IF_EXISTS
918# endif
919
920# if __has_cpp_attribute(_Clang::__no_destroy__)
921# define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]]
922# else
923# define _LIBCPP_NO_DESTROY
924# endif
925
926# if __has_attribute(__diagnose_if__)
927# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
928# else
929# define _LIBCPP_DIAGNOSE_WARNING(...)
930# endif
931
932# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_APPLE_CLANG_VER) && \
933 (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2001)
934# define _LIBCPP_DIAGNOSE_IF(...) __attribute__((__diagnose_if__(__VA_ARGS__)))
935# else
936# define _LIBCPP_DIAGNOSE_IF(...)
937# endif
938
939# define _LIBCPP_DIAGNOSE_NULLPTR_IF(condition, condition_description) \
940 _LIBCPP_DIAGNOSE_IF( \
941 condition, \
942 "null passed to callee that requires a non-null argument" condition_description, \
943 "warning", \
944 "nonnull")
945
946# if __has_cpp_attribute(_Clang::__lifetimebound__)
947# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
948# else
949# define _LIBCPP_LIFETIMEBOUND
950# endif
951
952// This is to work around https://llvm.org/PR156809
953# ifndef _LIBCPP_CXX03_LANG
954# define _LIBCPP_CTOR_LIFETIMEBOUND _LIBCPP_LIFETIMEBOUND
955# else
956# define _LIBCPP_CTOR_LIFETIMEBOUND
957# endif
958
959# if __has_cpp_attribute(_Clang::__noescape__)
960# define _LIBCPP_NOESCAPE [[_Clang::__noescape__]]
961# else
962# define _LIBCPP_NOESCAPE
963# endif
964
965# if __has_cpp_attribute(_Clang::__no_specializations__)
966# define _LIBCPP_NO_SPECIALIZATIONS \
967 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
968# else
969# define _LIBCPP_NO_SPECIALIZATIONS
970# endif
971
972# if __has_cpp_attribute(_Clang::__preferred_name__)
973# define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]]
974# else
975# define _LIBCPP_PREFERRED_NAME(x)
976# endif
977
978# if __has_cpp_attribute(_Clang::__scoped_lockable__)
979# define _LIBCPP_SCOPED_LOCKABLE [[_Clang::__scoped_lockable__]]
980# else
981# define _LIBCPP_SCOPED_LOCKABLE
982# endif
983
984# if __has_cpp_attribute(_Clang::__capability__)
985# define _LIBCPP_CAPABILITY(...) [[_Clang::__capability__(__VA_ARGS__)]]
986# else
987# define _LIBCPP_CAPABILITY(...)
988# endif
989
990# if __has_attribute(__acquire_capability__)
991# define _LIBCPP_ACQUIRE_CAPABILITY(...) __attribute__((__acquire_capability__(__VA_ARGS__)))
992# else
993# define _LIBCPP_ACQUIRE_CAPABILITY(...)
994# endif
995
996# if __has_cpp_attribute(_Clang::__try_acquire_capability__)
997# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) [[_Clang::__try_acquire_capability__(__VA_ARGS__)]]
998# else
999# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...)
1000# endif
1001
1002# if __has_cpp_attribute(_Clang::__acquire_shared_capability__)
1003# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY [[_Clang::__acquire_shared_capability__]]
1004# else
1005# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY
1006# endif
1007
1008# if __has_cpp_attribute(_Clang::__try_acquire_shared_capability__)
1009# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) [[_Clang::__try_acquire_shared_capability__(__VA_ARGS__)]]
1010# else
1011# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...)
1012# endif
1013
1014# if __has_cpp_attribute(_Clang::__release_capability__)
1015# define _LIBCPP_RELEASE_CAPABILITY [[_Clang::__release_capability__]]
1016# else
1017# define _LIBCPP_RELEASE_CAPABILITY
1018# endif
1019
1020# if __has_cpp_attribute(_Clang::__release_shared_capability__)
1021# define _LIBCPP_RELEASE_SHARED_CAPABILITY [[_Clang::__release_shared_capability__]]
1022# else
1023# define _LIBCPP_RELEASE_SHARED_CAPABILITY
1024# endif
1025
1026# if __has_attribute(__requires_capability__)
1027# define _LIBCPP_REQUIRES_CAPABILITY(...) __attribute__((__requires_capability__(__VA_ARGS__)))
1028# else
1029# define _LIBCPP_REQUIRES_CAPABILITY(...)
1030# endif
1031
1032# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1033# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1034# else
1035# define _LIBCPP_DECLSPEC_EMPTY_BASES
1036# endif
1037
1038// Allow for build-time disabling of unsigned integer sanitization
1039# if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
1040# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
1041# else
1042# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1043# endif
1044
1045# if __has_feature(nullability)
1046# define _LIBCPP_DIAGNOSE_NULLPTR _Nonnull
1047# else
1048# define _LIBCPP_DIAGNOSE_NULLPTR
1049# endif
1050
1051#endif // __cplusplus
1052
1053#endif // _LIBCPP___CONFIG