1// -*- C++ -*-
2//===--------------------------- __config ---------------------------------===//
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#if defined(_MSC_VER) && !defined(__clang__)
14#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15#    define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16#  endif
17#endif
18
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20#pragma GCC system_header
21#endif
22
23#ifdef __cplusplus
24
25#ifdef __GNUC__
26#  define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
27// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
28// introduced in GCC 5.0.
29#  define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
30#else
31#  define _GNUC_VER 0
32#  define _GNUC_VER_NEW 0
33#endif
34
35#define _LIBCPP_VERSION 12000
36
37#ifndef _LIBCPP_ABI_VERSION
38#  define _LIBCPP_ABI_VERSION 1
39#endif
40
41#if __STDC_HOSTED__ == 0
42#  define _LIBCPP_FREESTANDING
43#endif
44
45#ifndef _LIBCPP_STD_VER
46#  if  __cplusplus <= 201103L
47#    define _LIBCPP_STD_VER 11
48#  elif __cplusplus <= 201402L
49#    define _LIBCPP_STD_VER 14
50#  elif __cplusplus <= 201703L
51#    define _LIBCPP_STD_VER 17
52#  else
53#    define _LIBCPP_STD_VER 18  // current year, or date of c++2a ratification
54#  endif
55#endif  // _LIBCPP_STD_VER
56
57#if defined(__ELF__)
58#  define _LIBCPP_OBJECT_FORMAT_ELF   1
59#elif defined(__MACH__)
60#  define _LIBCPP_OBJECT_FORMAT_MACHO 1
61#elif defined(_WIN32)
62#  define _LIBCPP_OBJECT_FORMAT_COFF  1
63#elif defined(__wasm__)
64#  define _LIBCPP_OBJECT_FORMAT_WASM  1
65#else
66   // ... add new file formats here ...
67#endif
68
69#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
70// Change short string representation so that string data starts at offset 0,
71// improving its alignment in some cases.
72#  define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
73// Fix deque iterator type in order to support incomplete types.
74#  define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
75// Fix undefined behavior in how std::list stores its linked nodes.
76#  define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
77// Fix undefined behavior in  how __tree stores its end and parent nodes.
78#  define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
79// Fix undefined behavior in how __hash_table stores its pointer types.
80#  define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
81#  define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
82#  define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
83// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
84// provided under the alternate keyword __nullptr, which changes the mangling
85// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
86#  define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
87// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
88// instead of as a class simulating an enum. If this option is enabled
89// `pointer_safety` and `get_pointer_safety()` will no longer be available
90// in C++03.
91#  define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
92// Define a key function for `bad_function_call` in the library, to centralize
93// its vtable and typeinfo to libc++ rather than having all other libraries
94// using that class define their own copies.
95#  define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
96// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
97#  define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
98// Use the smallest possible integer type to represent the index of the variant.
99// Previously libc++ used "unsigned int" exclusively.
100#  define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
101// Unstable attempt to provide a more optimized std::function
102#  define _LIBCPP_ABI_OPTIMIZED_FUNCTION
103// All the regex constants must be distinct and nonzero.
104#  define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
105// Re-worked external template instantiations for std::string with a focus on
106// performance and fast-path inlining.
107#  define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
108// Enable clang::trivial_abi on std::unique_ptr.
109#  define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
110// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
111#  define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
112#elif _LIBCPP_ABI_VERSION == 1
113#  if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
114// Enable compiling copies of now inline methods into the dylib to support
115// applications compiled against older libraries. This is unnecessary with
116// COFF dllexport semantics, since dllexport forces a non-inline definition
117// of inline functions to be emitted anyway. Our own non-inline copy would
118// conflict with the dllexport-emitted copy, so we disable it.
119#    define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
120#  endif
121// Feature macros for disabling pre ABI v1 features. All of these options
122// are deprecated.
123#  if defined(__FreeBSD__)
124#    define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
125#  endif
126#endif
127
128#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
129// Enable additional explicit instantiations of iostreams components. This
130// reduces the number of weak definitions generated in programs that use
131// iostreams by providing a single strong definition in the shared library.
132# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
133#endif
134
135#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
136#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
137
138#ifndef _LIBCPP_ABI_NAMESPACE
139# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
140#endif
141
142#if __cplusplus < 201103L
143#define _LIBCPP_CXX03_LANG
144#endif
145
146#ifndef __has_attribute
147#define __has_attribute(__x) 0
148#endif
149
150#ifndef __has_builtin
151#define __has_builtin(__x) 0
152#endif
153
154#ifndef __has_extension
155#define __has_extension(__x) 0
156#endif
157
158#ifndef __has_feature
159#define __has_feature(__x) 0
160#endif
161
162#ifndef __has_cpp_attribute
163#define __has_cpp_attribute(__x) 0
164#endif
165
166// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
167// the compiler and '1' otherwise.
168#ifndef __is_identifier
169#define __is_identifier(__x) 1
170#endif
171
172#ifndef __has_declspec_attribute
173#define __has_declspec_attribute(__x) 0
174#endif
175
176#define __has_keyword(__x) !(__is_identifier(__x))
177
178#ifndef __has_include
179#define __has_include(...) 0
180#endif
181
182#if defined(__clang__)
183#  define _LIBCPP_COMPILER_CLANG
184#  ifndef __apple_build_version__
185#    define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
186#  endif
187#elif defined(__GNUC__)
188#  define _LIBCPP_COMPILER_GCC
189#elif defined(_MSC_VER)
190#  define _LIBCPP_COMPILER_MSVC
191#elif defined(__IBMCPP__)
192#  define _LIBCPP_COMPILER_IBM
193#endif
194
195#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
196#error "libc++ does not support using GCC with C++03. Please enable C++11"
197#endif
198
199// FIXME: ABI detection should be done via compiler builtin macros. This
200// is just a placeholder until Clang implements such macros. For now assume
201// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
202// and allow the user to explicitly specify the ABI to handle cases where this
203// heuristic falls short.
204#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
205#  error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
206#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
207#  define _LIBCPP_ABI_ITANIUM
208#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
209#  define _LIBCPP_ABI_MICROSOFT
210#else
211#  if defined(_WIN32) && defined(_MSC_VER)
212#    define _LIBCPP_ABI_MICROSOFT
213#  else
214#    define _LIBCPP_ABI_ITANIUM
215#  endif
216#endif
217
218#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
219# define _LIBCPP_ABI_VCRUNTIME
220#endif
221
222// Need to detect which libc we're using if we're on Linux.
223#if defined(__linux__)
224#  include <features.h>
225#  if defined(__GLIBC_PREREQ)
226#    define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
227#  else
228#    define _LIBCPP_GLIBC_PREREQ(a, b) 0
229#  endif // defined(__GLIBC_PREREQ)
230#endif // defined(__linux__)
231
232#ifdef __LITTLE_ENDIAN__
233#  if __LITTLE_ENDIAN__
234#    define _LIBCPP_LITTLE_ENDIAN
235#  endif  // __LITTLE_ENDIAN__
236#endif  // __LITTLE_ENDIAN__
237
238#ifdef __BIG_ENDIAN__
239#  if __BIG_ENDIAN__
240#    define _LIBCPP_BIG_ENDIAN
241#  endif  // __BIG_ENDIAN__
242#endif  // __BIG_ENDIAN__
243
244#ifdef __BYTE_ORDER__
245#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
246#    define _LIBCPP_LITTLE_ENDIAN
247#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
248#    define _LIBCPP_BIG_ENDIAN
249#  endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
250#endif // __BYTE_ORDER__
251
252#ifdef __FreeBSD__
253#  include <sys/endian.h>
254#  include <osreldate.h>
255#  if _BYTE_ORDER == _LITTLE_ENDIAN
256#    define _LIBCPP_LITTLE_ENDIAN
257#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
258#    define _LIBCPP_BIG_ENDIAN
259#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
260#  ifndef __LONG_LONG_SUPPORTED
261#    define _LIBCPP_HAS_NO_LONG_LONG
262#  endif  // __LONG_LONG_SUPPORTED
263#endif  // __FreeBSD__
264
265#ifdef __NetBSD__
266#  include <sys/endian.h>
267#  if _BYTE_ORDER == _LITTLE_ENDIAN
268#    define _LIBCPP_LITTLE_ENDIAN
269#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
270#    define _LIBCPP_BIG_ENDIAN
271#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
272#endif  // __NetBSD__
273
274#if defined(_WIN32)
275#  define _LIBCPP_WIN32API
276#  define _LIBCPP_LITTLE_ENDIAN
277#  define _LIBCPP_SHORT_WCHAR   1
278// Both MinGW and native MSVC provide a "MSVC"-like environment
279#  define _LIBCPP_MSVCRT_LIKE
280// If mingw not explicitly detected, assume using MS C runtime only if
281// a MS compatibility version is specified.
282#  if defined(_MSC_VER) && !defined(__MINGW32__)
283#    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
284#  endif
285#  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
286#    define _LIBCPP_HAS_BITSCAN64
287#  endif
288#  define _LIBCPP_HAS_OPEN_WITH_WCHAR
289#  if defined(_LIBCPP_MSVCRT)
290#    define _LIBCPP_HAS_QUICK_EXIT
291#  endif
292
293// Some CRT APIs are unavailable to store apps
294#  if defined(WINAPI_FAMILY)
295#    include <winapifamily.h>
296#    if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                  \
297        (!defined(WINAPI_PARTITION_SYSTEM) ||                                  \
298         !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
299#      define _LIBCPP_WINDOWS_STORE_APP
300#    endif
301#  endif
302#endif // defined(_WIN32)
303
304#ifdef __sun__
305#  include <sys/isa_defs.h>
306#  ifdef _LITTLE_ENDIAN
307#    define _LIBCPP_LITTLE_ENDIAN
308#  else
309#    define _LIBCPP_BIG_ENDIAN
310#  endif
311#endif // __sun__
312
313#if defined(__CloudABI__)
314   // Certain architectures provide arc4random(). Prefer using
315   // arc4random() over /dev/{u,}random to make it possible to obtain
316   // random data even when using sandboxing mechanisms such as chroots,
317   // Capsicum, etc.
318#  define _LIBCPP_USING_ARC4_RANDOM
319#elif defined(__Fuchsia__) || defined(__wasi__)
320#  define _LIBCPP_USING_GETENTROPY
321#elif defined(__native_client__)
322   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
323   // including accesses to the special files under /dev. C++11's
324   // std::random_device is instead exposed through a NaCl syscall.
325#  define _LIBCPP_USING_NACL_RANDOM
326#elif defined(_LIBCPP_WIN32API)
327#  define _LIBCPP_USING_WIN32_RANDOM
328#else
329#  define _LIBCPP_USING_DEV_RANDOM
330#endif
331
332#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
333#  include <endian.h>
334#  if __BYTE_ORDER == __LITTLE_ENDIAN
335#    define _LIBCPP_LITTLE_ENDIAN
336#  elif __BYTE_ORDER == __BIG_ENDIAN
337#    define _LIBCPP_BIG_ENDIAN
338#  else  // __BYTE_ORDER == __BIG_ENDIAN
339#    error unable to determine endian
340#  endif
341#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
342
343#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
344#  define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
345#else
346#  define _LIBCPP_NO_CFI
347#endif
348
349#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
350#  if defined(__FreeBSD__)
351#    define _LIBCPP_HAS_ALIGNED_ALLOC
352#    define _LIBCPP_HAS_QUICK_EXIT
353#    if __FreeBSD_version >= 1300064 || \
354       (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
355#      define _LIBCPP_HAS_TIMESPEC_GET
356#    endif
357#  elif defined(__BIONIC__)
358#    if __ANDROID_API__ >= 21
359#      define _LIBCPP_HAS_QUICK_EXIT
360#    endif
361#    if __ANDROID_API__ >= 28
362#      define _LIBCPP_HAS_ALIGNED_ALLOC
363#    endif
364#    if __ANDROID_API__ >= 29
365#      define _LIBCPP_HAS_TIMESPEC_GET
366#    endif
367#  elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
368#    define _LIBCPP_HAS_ALIGNED_ALLOC
369#    define _LIBCPP_HAS_QUICK_EXIT
370#    define _LIBCPP_HAS_TIMESPEC_GET
371#  elif defined(__linux__)
372#    if !defined(_LIBCPP_HAS_MUSL_LIBC)
373#      if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
374#        define _LIBCPP_HAS_QUICK_EXIT
375#      endif
376#      if _LIBCPP_GLIBC_PREREQ(2, 17)
377#        define _LIBCPP_HAS_ALIGNED_ALLOC
378#        define _LIBCPP_HAS_TIMESPEC_GET
379#      endif
380#    else // defined(_LIBCPP_HAS_MUSL_LIBC)
381#      define _LIBCPP_HAS_ALIGNED_ALLOC
382#      define _LIBCPP_HAS_QUICK_EXIT
383#      define _LIBCPP_HAS_TIMESPEC_GET
384#    endif
385#  elif defined(__APPLE__)
386     // timespec_get and aligned_alloc were introduced in macOS 10.15 and
387     // aligned releases
388#    if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 || \
389         __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
390         __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
391         __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)
392#      define _LIBCPP_HAS_ALIGNED_ALLOC
393#      define _LIBCPP_HAS_TIMESPEC_GET
394#    endif
395#  endif // __APPLE__
396#endif
397
398#ifndef _LIBCPP_CXX03_LANG
399# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
400#elif defined(_LIBCPP_COMPILER_CLANG)
401# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
402#else
403# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
404#endif
405
406#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
407
408#if defined(_LIBCPP_COMPILER_CLANG)
409
410#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
411#  error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
412#endif
413#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
414    (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
415#  define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
416#endif
417
418#if __has_feature(cxx_alignas)
419#  define _ALIGNAS_TYPE(x) alignas(x)
420#  define _ALIGNAS(x) alignas(x)
421#else
422#  define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
423#  define _ALIGNAS(x) __attribute__((__aligned__(x)))
424#endif
425
426#if __cplusplus < 201103L
427typedef __char16_t char16_t;
428typedef __char32_t char32_t;
429#endif
430
431#if !__has_feature(cxx_exceptions)
432#  define _LIBCPP_NO_EXCEPTIONS
433#endif
434
435#if !(__has_feature(cxx_strong_enums))
436#define _LIBCPP_HAS_NO_STRONG_ENUMS
437#endif
438
439#if __has_feature(cxx_attributes)
440#  define _LIBCPP_NORETURN [[noreturn]]
441#else
442#  define _LIBCPP_NORETURN __attribute__ ((noreturn))
443#endif
444
445#if !(__has_feature(cxx_nullptr))
446#  if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
447#    define nullptr __nullptr
448#  else
449#    define _LIBCPP_HAS_NO_NULLPTR
450#  endif
451#endif
452
453// Objective-C++ features (opt-in)
454#if __has_feature(objc_arc)
455#define _LIBCPP_HAS_OBJC_ARC
456#endif
457
458#if __has_feature(objc_arc_weak)
459#define _LIBCPP_HAS_OBJC_ARC_WEAK
460#endif
461
462#if __has_extension(blocks)
463#  define _LIBCPP_HAS_EXTENSION_BLOCKS
464#endif
465
466#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
467#  define _LIBCPP_HAS_BLOCKS_RUNTIME
468#endif
469
470#if !(__has_feature(cxx_relaxed_constexpr))
471#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
472#endif
473
474#if !(__has_feature(cxx_variable_templates))
475#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
476#endif
477
478#if !(__has_feature(cxx_noexcept))
479#define _LIBCPP_HAS_NO_NOEXCEPT
480#endif
481
482#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
483#define _LIBCPP_HAS_NO_ASAN
484#endif
485
486// Allow for build-time disabling of unsigned integer sanitization
487#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
488#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
489#endif
490
491#if __has_builtin(__builtin_launder)
492#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
493#endif
494
495#if __has_builtin(__builtin_constant_p)
496#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
497#endif
498
499#if !__is_identifier(__has_unique_object_representations)
500#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
501#endif
502
503#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
504
505// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
506#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
507    (defined(__apple_build_version__) && __apple_build_version__ < 10010000)
508#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
509#endif
510
511#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
512
513#elif defined(_LIBCPP_COMPILER_GCC)
514
515#define _ALIGNAS(x) __attribute__((__aligned__(x)))
516#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
517
518#define _LIBCPP_NORETURN __attribute__((noreturn))
519
520#if !__EXCEPTIONS
521#  define _LIBCPP_NO_EXCEPTIONS
522#endif
523
524// Determine if GCC supports relaxed constexpr
525#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
526#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
527#endif
528
529// GCC 5 supports variable templates
530#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
531#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
532#endif
533
534#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
535#define _LIBCPP_HAS_NO_ASAN
536#endif
537
538#if _GNUC_VER >= 700
539#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
540#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
541#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
542#endif
543
544#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
545
546#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
547
548#elif defined(_LIBCPP_COMPILER_MSVC)
549
550#define _LIBCPP_TOSTRING2(x) #x
551#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
552#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
553
554#if _MSC_VER < 1900
555#error "MSVC versions prior to Visual Studio 2015 are not supported"
556#endif
557
558#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
559#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
560#define __alignof__ __alignof
561#define _LIBCPP_NORETURN __declspec(noreturn)
562#define _ALIGNAS(x) __declspec(align(x))
563#define _ALIGNAS_TYPE(x) alignas(x)
564
565#define _LIBCPP_WEAK
566
567#define _LIBCPP_HAS_NO_ASAN
568
569#define _LIBCPP_ALWAYS_INLINE __forceinline
570
571#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
572
573#define _LIBCPP_DISABLE_EXTENSION_WARNING
574
575#elif defined(_LIBCPP_COMPILER_IBM)
576
577#define _ALIGNAS(x) __attribute__((__aligned__(x)))
578#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
579#define _ATTRIBUTE(x) __attribute__((x))
580#define _LIBCPP_NORETURN __attribute__((noreturn))
581
582#define _LIBCPP_HAS_NO_UNICODE_CHARS
583#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
584
585#if defined(_AIX)
586#define __MULTILOCALE_API
587#endif
588
589#define _LIBCPP_HAS_NO_ASAN
590
591#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
592
593#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
594
595#define _LIBCPP_DISABLE_EXTENSION_WARNING
596
597#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
598
599#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
600
601#ifdef _DLL
602#  define _LIBCPP_CRT_FUNC __declspec(dllimport)
603#else
604#  define _LIBCPP_CRT_FUNC
605#endif
606
607#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
608#  define _LIBCPP_DLL_VIS
609#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
610#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
611#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
612#  define _LIBCPP_EXPORTED_FROM_ABI
613#elif defined(_LIBCPP_BUILDING_LIBRARY)
614#  define _LIBCPP_DLL_VIS __declspec(dllexport)
615#  if defined(__MINGW32__)
616#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
617#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
618#  else
619#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
620#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
621#  endif
622#  define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
623#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
624#else
625#  define _LIBCPP_DLL_VIS __declspec(dllimport)
626#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
627#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
628#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
629#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
630#endif
631
632#define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
633#define _LIBCPP_FUNC_VIS            _LIBCPP_DLL_VIS
634#define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
635#define _LIBCPP_HIDDEN
636#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
637#define _LIBCPP_TEMPLATE_VIS
638#define _LIBCPP_ENUM_VIS
639
640#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
641
642#ifndef _LIBCPP_HIDDEN
643#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
644#    define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
645#  else
646#    define _LIBCPP_HIDDEN
647#  endif
648#endif
649
650#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
651#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
652// The inline should be removed once PR32114 is resolved
653#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
654#  else
655#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
656#  endif
657#endif
658
659#ifndef _LIBCPP_FUNC_VIS
660#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
661#    define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
662#  else
663#    define _LIBCPP_FUNC_VIS
664#  endif
665#endif
666
667#ifndef _LIBCPP_TYPE_VIS
668#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
669#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
670#  else
671#    define _LIBCPP_TYPE_VIS
672#  endif
673#endif
674
675#ifndef _LIBCPP_TEMPLATE_VIS
676#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
677#    if __has_attribute(__type_visibility__)
678#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
679#    else
680#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
681#    endif
682#  else
683#    define _LIBCPP_TEMPLATE_VIS
684#  endif
685#endif
686
687#ifndef _LIBCPP_EXPORTED_FROM_ABI
688#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
689#    define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
690#  else
691#    define _LIBCPP_EXPORTED_FROM_ABI
692#  endif
693#endif
694
695#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
696#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
697#endif
698
699#ifndef _LIBCPP_EXCEPTION_ABI
700#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
701#    define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
702#  else
703#    define _LIBCPP_EXCEPTION_ABI
704#  endif
705#endif
706
707#ifndef _LIBCPP_ENUM_VIS
708#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
709#    define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
710#  else
711#    define _LIBCPP_ENUM_VIS
712#  endif
713#endif
714
715#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
716#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
717#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
718#  else
719#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
720#  endif
721#endif
722
723#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
724#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
725#endif
726
727#if __has_attribute(internal_linkage)
728#  define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
729#else
730#  define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
731#endif
732
733#if __has_attribute(exclude_from_explicit_instantiation)
734#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
735#else
736   // Try to approximate the effect of exclude_from_explicit_instantiation
737   // (which is that entities are not assumed to be provided by explicit
738   // template instantiations in the dylib) by always inlining those entities.
739#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
740#endif
741
742#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
743#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
744#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
745#  else
746#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
747#  endif
748#endif
749
750#ifndef _LIBCPP_HIDE_FROM_ABI
751#  if _LIBCPP_HIDE_FROM_ABI_PER_TU
752#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
753#  else
754#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
755#  endif
756#endif
757
758#ifdef _LIBCPP_BUILDING_LIBRARY
759#  if _LIBCPP_ABI_VERSION > 1
760#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
761#  else
762#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
763#  endif
764#else
765#  define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
766#endif
767
768// Just so we can migrate to the new macros gradually.
769#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
770
771// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
772#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
773#define _LIBCPP_END_NAMESPACE_STD  } }
774#define _VSTD std::_LIBCPP_ABI_NAMESPACE
775_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
776
777#if _LIBCPP_STD_VER >= 17
778#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
779  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
780#else
781#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
782  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
783#endif
784
785#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
786  _LIBCPP_END_NAMESPACE_STD } }
787
788#define _VSTD_FS _VSTD::__fs::filesystem
789
790#ifndef _LIBCPP_PREFERRED_OVERLOAD
791#  if __has_attribute(__enable_if__)
792#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
793#  endif
794#endif
795
796#ifndef _LIBCPP_HAS_NO_NOEXCEPT
797#  define _NOEXCEPT noexcept
798#  define _NOEXCEPT_(x) noexcept(x)
799#else
800#  define _NOEXCEPT throw()
801#  define _NOEXCEPT_(x)
802#endif
803
804#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
805typedef unsigned short char16_t;
806typedef unsigned int   char32_t;
807#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
808
809#ifndef __SIZEOF_INT128__
810#define _LIBCPP_HAS_NO_INT128
811#endif
812
813#ifdef _LIBCPP_CXX03_LANG
814# define static_assert(...) _Static_assert(__VA_ARGS__)
815# define decltype(...) __decltype(__VA_ARGS__)
816#endif  // _LIBCPP_CXX03_LANG
817
818#ifdef _LIBCPP_CXX03_LANG
819#  define _LIBCPP_CONSTEXPR
820#else
821#  define _LIBCPP_CONSTEXPR constexpr
822#endif
823
824#ifndef __cpp_consteval
825#  define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
826#else
827#  define _LIBCPP_CONSTEVAL consteval
828#endif
829
830#ifdef _LIBCPP_CXX03_LANG
831#  define _LIBCPP_DEFAULT {}
832#else
833#  define _LIBCPP_DEFAULT = default;
834#endif
835
836#ifdef _LIBCPP_CXX03_LANG
837#  define _LIBCPP_EQUAL_DELETE
838#else
839#  define _LIBCPP_EQUAL_DELETE = delete
840#endif
841
842#ifdef __GNUC__
843#  define _LIBCPP_NOALIAS __attribute__((__malloc__))
844#else
845#  define _LIBCPP_NOALIAS
846#endif
847
848#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
849    (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
850#  define _LIBCPP_EXPLICIT explicit
851#else
852#  define _LIBCPP_EXPLICIT
853#endif
854
855#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
856#  define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
857#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
858     __lx __v_; \
859     _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
860     _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
861     _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
862     };
863#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
864#  define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
865#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
866#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
867
868// _LIBCPP_DEBUG potential values:
869//  - undefined: No assertions. This is the default.
870//  - 0:         Basic assertions
871//  - 1:         Basic assertions + iterator validity checks.
872#if !defined(_LIBCPP_DEBUG)
873# define _LIBCPP_DEBUG_LEVEL 0
874#elif _LIBCPP_DEBUG == 0
875# define _LIBCPP_DEBUG_LEVEL 1
876#elif _LIBCPP_DEBUG == 1
877# define _LIBCPP_DEBUG_LEVEL 2
878#else
879# error Supported values for _LIBCPP_DEBUG are 0 and 1
880#endif
881
882// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
883#if _LIBCPP_DEBUG_LEVEL >= 1
884# define _LIBCPP_DISABLE_EXTERN_TEMPLATE
885#endif
886
887#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
888#define _LIBCPP_EXTERN_TEMPLATE(...)
889#endif
890
891#ifndef _LIBCPP_EXTERN_TEMPLATE
892#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
893#endif
894
895#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
896#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
897#endif
898
899#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
900    defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
901#define _LIBCPP_LOCALE__L_EXTENSIONS 1
902#endif
903
904#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
905// Most unix variants have catopen.  These are the specific ones that don't.
906#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
907#    define _LIBCPP_HAS_CATOPEN 1
908#  endif
909#endif
910
911#ifdef __FreeBSD__
912#define _DECLARE_C99_LDBL_MATH 1
913#endif
914
915// If we are getting operator new from the MSVC CRT, then allocation overloads
916// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
917#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
918#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
919#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
920   // We're deferring to Microsoft's STL to provide aligned new et al. We don't
921   // have it unless the language feature test macro is defined.
922#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
923#elif defined(__MVS__)
924#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
925#endif
926
927#if defined(__APPLE__)
928#  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
929      defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
930#    define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
931#  endif
932#endif // defined(__APPLE__)
933
934#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
935    (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
936    (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
937#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
938#endif
939
940#if defined(__APPLE__) || defined(__FreeBSD__)
941#define _LIBCPP_HAS_DEFAULTRUNELOCALE
942#endif
943
944#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
945#define _LIBCPP_WCTYPE_IS_MASK
946#endif
947
948#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
949#define _LIBCPP_NO_HAS_CHAR8_T
950#endif
951
952// Deprecation macros.
953//
954// Deprecations warnings are always enabled, except when users explicitly opt-out
955// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
956#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
957#  if __has_attribute(deprecated)
958#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
959#  elif _LIBCPP_STD_VER > 11
960#    define _LIBCPP_DEPRECATED [[deprecated]]
961#  else
962#    define _LIBCPP_DEPRECATED
963#  endif
964#else
965#  define _LIBCPP_DEPRECATED
966#endif
967
968#if !defined(_LIBCPP_CXX03_LANG)
969#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
970#else
971#  define _LIBCPP_DEPRECATED_IN_CXX11
972#endif
973
974#if _LIBCPP_STD_VER >= 14
975#  define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
976#else
977#  define _LIBCPP_DEPRECATED_IN_CXX14
978#endif
979
980#if _LIBCPP_STD_VER >= 17
981#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
982#else
983#  define _LIBCPP_DEPRECATED_IN_CXX17
984#endif
985
986#if _LIBCPP_STD_VER > 17
987#  define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
988#else
989#  define _LIBCPP_DEPRECATED_IN_CXX20
990#endif
991
992#if !defined(_LIBCPP_NO_HAS_CHAR8_T)
993#  define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
994#else
995#  define _LIBCPP_DEPRECATED_WITH_CHAR8_T
996#endif
997
998// Macros to enter and leave a state where deprecation warnings are suppressed.
999#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
1000    (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
1001#  define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
1002    _Pragma("GCC diagnostic push") \
1003    _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
1004#  define _LIBCPP_SUPPRESS_DEPRECATED_POP \
1005    _Pragma("GCC diagnostic pop")
1006#endif
1007#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
1008#  define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1009#  define _LIBCPP_SUPPRESS_DEPRECATED_POP
1010#endif
1011
1012#if _LIBCPP_STD_VER <= 11
1013#  define _LIBCPP_EXPLICIT_AFTER_CXX11
1014#else
1015#  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
1016#endif
1017
1018#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1019#  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
1020#else
1021#  define _LIBCPP_CONSTEXPR_AFTER_CXX11
1022#endif
1023
1024#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1025#  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
1026#else
1027#  define _LIBCPP_CONSTEXPR_AFTER_CXX14
1028#endif
1029
1030#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1031#  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
1032#else
1033#  define _LIBCPP_CONSTEXPR_AFTER_CXX17
1034#endif
1035
1036// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
1037// NODISCARD macros to the correct attribute.
1038#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1039#  define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
1040#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
1041#  define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
1042#else
1043// We can't use GCC's [[gnu::warn_unused_result]] and
1044// __attribute__((warn_unused_result)), because GCC does not silence them via
1045// (void) cast.
1046#  define _LIBCPP_NODISCARD_ATTRIBUTE
1047#endif
1048
1049// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1050// specified as such as an extension.
1051#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1052#  define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1053#else
1054#  define _LIBCPP_NODISCARD_EXT
1055#endif
1056
1057#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1058    (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1059#  define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
1060#else
1061#  define _LIBCPP_NODISCARD_AFTER_CXX17
1062#endif
1063
1064#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
1065#  define _LIBCPP_INLINE_VAR inline
1066#else
1067#  define _LIBCPP_INLINE_VAR
1068#endif
1069
1070#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
1071#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1072#define _LIBCPP_CONSTEXPR_IF_NODEBUG
1073#else
1074#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
1075#endif
1076#endif
1077
1078#if __has_attribute(no_destroy)
1079#  define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1080#else
1081#  define _LIBCPP_NO_DESTROY
1082#endif
1083
1084#ifndef _LIBCPP_HAS_NO_ASAN
1085_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1086  const void *, const void *, const void *, const void *);
1087#endif
1088
1089// Try to find out if RTTI is disabled.
1090#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti)
1091#  define _LIBCPP_NO_RTTI
1092#elif defined(__GNUC__) && !defined(__GXX_RTTI)
1093#  define _LIBCPP_NO_RTTI
1094#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
1095#  define _LIBCPP_NO_RTTI
1096#endif
1097
1098#ifndef _LIBCPP_WEAK
1099#define _LIBCPP_WEAK __attribute__((__weak__))
1100#endif
1101
1102// Thread API
1103#if !defined(_LIBCPP_HAS_NO_THREADS) && \
1104    !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1105    !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1106    !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1107#  if defined(__FreeBSD__) || \
1108      defined(__wasi__) || \
1109      defined(__NetBSD__) || \
1110      defined(__NuttX__) || \
1111      defined(__linux__) || \
1112      defined(__GNU__) || \
1113      defined(__APPLE__) || \
1114      defined(__CloudABI__) || \
1115      defined(__sun__) || \
1116      defined(__MVS__) || \
1117      (defined(__MINGW32__) && __has_include(<pthread.h>))
1118#    define _LIBCPP_HAS_THREAD_API_PTHREAD
1119#  elif defined(__Fuchsia__)
1120     // TODO(44575): Switch to C11 thread API when possible.
1121#    define _LIBCPP_HAS_THREAD_API_PTHREAD
1122#  elif defined(_LIBCPP_WIN32API)
1123#    define _LIBCPP_HAS_THREAD_API_WIN32
1124#  else
1125#    error "No thread API"
1126#  endif // _LIBCPP_HAS_THREAD_API
1127#endif // _LIBCPP_HAS_NO_THREADS
1128
1129#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1130#if defined(__ANDROID__) && __ANDROID_API__ >= 30
1131#define _LIBCPP_HAS_COND_CLOCKWAIT
1132#elif defined(_LIBCPP_GLIBC_PREREQ)
1133#if _LIBCPP_GLIBC_PREREQ(2, 30)
1134#define _LIBCPP_HAS_COND_CLOCKWAIT
1135#endif
1136#endif
1137#endif
1138
1139#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1140#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1141       _LIBCPP_HAS_NO_THREADS is not defined.
1142#endif
1143
1144#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1145#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1146       _LIBCPP_HAS_NO_THREADS is defined.
1147#endif
1148
1149#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1150#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1151       _LIBCPP_HAS_NO_THREADS is defined.
1152#endif
1153
1154#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1155#define __STDCPP_THREADS__ 1
1156#endif
1157
1158// The glibc and Bionic implementation of pthreads implements
1159// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1160// mutexes have no destroy mechanism.
1161//
1162// This optimization can't be performed on Apple platforms, where
1163// pthread_mutex_destroy can allow the kernel to release resources.
1164// See https://llvm.org/D64298 for details.
1165//
1166// TODO(EricWF): Enable this optimization on Bionic after speaking to their
1167//               respective stakeholders.
1168#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1169  || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
1170  || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1171# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1172#endif
1173
1174// Destroying a condvar is a nop on Windows.
1175//
1176// This optimization can't be performed on Apple platforms, where
1177// pthread_cond_destroy can allow the kernel to release resources.
1178// See https://llvm.org/D64298 for details.
1179//
1180// TODO(EricWF): This is potentially true for some pthread implementations
1181// as well.
1182#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1183     defined(_LIBCPP_HAS_THREAD_API_WIN32)
1184# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1185#endif
1186
1187// Systems that use capability-based security (FreeBSD with Capsicum,
1188// Nuxi CloudABI) may only provide local filesystem access (using *at()).
1189// Functions like open(), rename(), unlink() and stat() should not be
1190// used, as they attempt to access the global filesystem namespace.
1191#ifdef __CloudABI__
1192#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1193#endif
1194
1195// CloudABI is intended for running networked services. Processes do not
1196// have standard input and output channels.
1197#ifdef __CloudABI__
1198#define _LIBCPP_HAS_NO_STDIN
1199#define _LIBCPP_HAS_NO_STDOUT
1200#endif
1201
1202// Some systems do not provide gets() in their C library, for security reasons.
1203#ifndef _LIBCPP_C_HAS_NO_GETS
1204#  if defined(_LIBCPP_MSVCRT) || \
1205      (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043)
1206#    define _LIBCPP_C_HAS_NO_GETS
1207#  endif
1208#endif
1209
1210#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) ||      \
1211    defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \
1212    defined(__MVS__)
1213#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1214#endif
1215
1216// Thread-unsafe functions such as strtok() and localtime()
1217// are not available.
1218#ifdef __CloudABI__
1219#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1220#endif
1221
1222#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1223#  define _LIBCPP_HAS_C_ATOMIC_IMP
1224#elif defined(_LIBCPP_COMPILER_GCC)
1225#  define _LIBCPP_HAS_GCC_ATOMIC_IMP
1226#endif
1227
1228#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1229     !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1230     !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
1231     || defined(_LIBCPP_HAS_NO_THREADS)
1232#  define _LIBCPP_HAS_NO_ATOMIC_HEADER
1233#else
1234#  ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1235#    define _LIBCPP_ATOMIC_FLAG_TYPE bool
1236#  endif
1237#  ifdef _LIBCPP_FREESTANDING
1238#    define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1239#  endif
1240#endif
1241
1242#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1243#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1244#endif
1245
1246#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1247#  if defined(__clang__) && __has_attribute(acquire_capability)
1248// Work around the attribute handling in clang.  When both __declspec and
1249// __attribute__ are present, the processing goes awry preventing the definition
1250// of the types.
1251#    if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1252#      define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1253#    endif
1254#  endif
1255#endif
1256
1257#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
1258#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1259#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1260#  else
1261#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1262#  endif
1263#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
1264
1265#if __has_attribute(require_constant_initialization)
1266#  define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1267#else
1268#  define _LIBCPP_SAFE_STATIC
1269#endif
1270
1271#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1272#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1273#endif
1274
1275#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
1276#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
1277#endif
1278
1279#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1280#  if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1281#    define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1282#  endif
1283#endif
1284
1285#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1286#  define _LIBCPP_DIAGNOSE_WARNING(...) \
1287     __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1288#  define _LIBCPP_DIAGNOSE_ERROR(...) \
1289     __attribute__((diagnose_if(__VA_ARGS__, "error")))
1290#else
1291#  define _LIBCPP_DIAGNOSE_WARNING(...)
1292#  define _LIBCPP_DIAGNOSE_ERROR(...)
1293#endif
1294
1295// Use a function like macro to imply that it must be followed by a semicolon
1296#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1297#  define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1298#elif __has_cpp_attribute(clang::fallthrough)
1299#  define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1300#elif __has_attribute(fallthrough) || _GNUC_VER >= 700
1301#  define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1302#else
1303#  define _LIBCPP_FALLTHROUGH() ((void)0)
1304#endif
1305
1306#if __has_attribute(__nodebug__)
1307#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1308#else
1309#define _LIBCPP_NODEBUG
1310#endif
1311
1312#ifndef _LIBCPP_NODEBUG_TYPE
1313#if __has_attribute(__nodebug__) && \
1314    (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
1315#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1316#else
1317#define _LIBCPP_NODEBUG_TYPE
1318#endif
1319#endif // !defined(_LIBCPP_NODEBUG_TYPE)
1320
1321#if defined(_LIBCPP_ABI_MICROSOFT) && \
1322    (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1323#  define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1324#else
1325#  define _LIBCPP_DECLSPEC_EMPTY_BASES
1326#endif
1327
1328#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1329#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1330#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1331#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1332#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1333#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1334
1335#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
1336#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1337#endif
1338
1339#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
1340#define _LIBCPP_HAS_NO_IS_AGGREGATE
1341#endif
1342
1343#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
1344#define _LIBCPP_HAS_NO_COROUTINES
1345#endif
1346
1347#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
1348#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1349#endif
1350
1351#if defined(_LIBCPP_COMPILER_IBM)
1352#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1353#endif
1354
1355#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1356#  define _LIBCPP_PUSH_MACROS
1357#  define _LIBCPP_POP_MACROS
1358#else
1359  // Don't warn about macro conflicts when we can restore them at the
1360  // end of the header.
1361#  ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1362#    define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1363#  endif
1364#  if defined(_LIBCPP_COMPILER_MSVC)
1365#    define _LIBCPP_PUSH_MACROS    \
1366       __pragma(push_macro("min")) \
1367       __pragma(push_macro("max"))
1368#    define _LIBCPP_POP_MACROS     \
1369       __pragma(pop_macro("min"))  \
1370       __pragma(pop_macro("max"))
1371#  else
1372#    define _LIBCPP_PUSH_MACROS        \
1373       _Pragma("push_macro(\"min\")")  \
1374       _Pragma("push_macro(\"max\")")
1375#    define _LIBCPP_POP_MACROS         \
1376       _Pragma("pop_macro(\"min\")")   \
1377       _Pragma("pop_macro(\"max\")")
1378#  endif
1379#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1380
1381#ifndef _LIBCPP_NO_AUTO_LINK
1382#  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1383#    if defined(_DLL)
1384#      pragma comment(lib, "c++.lib")
1385#    else
1386#      pragma comment(lib, "libc++.lib")
1387#    endif
1388#  endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1389#endif // _LIBCPP_NO_AUTO_LINK
1390
1391#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1392
1393// Configures the fopen close-on-exec mode character, if any. This string will
1394// be appended to any mode string used by fstream for fopen/fdopen.
1395//
1396// Not all platforms support this, but it helps avoid fd-leaks on platforms that
1397// do.
1398#if defined(__BIONIC__)
1399#  define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1400#else
1401#  define _LIBCPP_FOPEN_CLOEXEC_MODE
1402#endif
1403
1404#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
1405#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x)
1406#else
1407#define _LIBCPP_BUILTIN_CONSTANT_P(x) false
1408#endif
1409
1410// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1411// of functions used in cstdio may not be available for low API levels when
1412// using 64-bit file offsets on LP32.
1413#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1414#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1415#endif
1416
1417#if __has_attribute(init_priority)
1418# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1419#else
1420# define _LIBCPP_INIT_PRIORITY_MAX
1421#endif
1422
1423#endif // __cplusplus
1424
1425#endif // _LIBCPP_CONFIG
1426