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_lambdas))
446#define _LIBCPP_HAS_NO_LAMBDAS
447#endif
448
449#if !(__has_feature(cxx_nullptr))
450#  if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
451#    define nullptr __nullptr
452#  else
453#    define _LIBCPP_HAS_NO_NULLPTR
454#  endif
455#endif
456
457#if !(__has_feature(cxx_auto_type))
458#define _LIBCPP_HAS_NO_AUTO_TYPE
459#endif
460
461// Objective-C++ features (opt-in)
462#if __has_feature(objc_arc)
463#define _LIBCPP_HAS_OBJC_ARC
464#endif
465
466#if __has_feature(objc_arc_weak)
467#define _LIBCPP_HAS_OBJC_ARC_WEAK
468#endif
469
470#if __has_extension(blocks)
471#  define _LIBCPP_HAS_EXTENSION_BLOCKS
472#endif
473
474#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
475#  define _LIBCPP_HAS_BLOCKS_RUNTIME
476#endif
477
478#if !(__has_feature(cxx_relaxed_constexpr))
479#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
480#endif
481
482#if !(__has_feature(cxx_variable_templates))
483#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
484#endif
485
486#if !(__has_feature(cxx_noexcept))
487#define _LIBCPP_HAS_NO_NOEXCEPT
488#endif
489
490#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
491#define _LIBCPP_HAS_NO_ASAN
492#endif
493
494// Allow for build-time disabling of unsigned integer sanitization
495#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
496#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
497#endif
498
499#if __has_builtin(__builtin_launder)
500#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
501#endif
502
503#if __has_builtin(__builtin_constant_p)
504#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
505#endif
506
507#if !__is_identifier(__has_unique_object_representations)
508#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
509#endif
510
511#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
512
513// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
514#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
515    (defined(__apple_build_version__) && __apple_build_version__ < 10010000)
516#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
517#endif
518
519#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
520
521#elif defined(_LIBCPP_COMPILER_GCC)
522
523#define _ALIGNAS(x) __attribute__((__aligned__(x)))
524#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
525
526#define _LIBCPP_NORETURN __attribute__((noreturn))
527
528#if !__EXCEPTIONS
529#  define _LIBCPP_NO_EXCEPTIONS
530#endif
531
532// Determine if GCC supports relaxed constexpr
533#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
534#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
535#endif
536
537// GCC 5 supports variable templates
538#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
539#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
540#endif
541
542#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
543#define _LIBCPP_HAS_NO_ASAN
544#endif
545
546#if _GNUC_VER >= 700
547#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
548#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
549#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
550#endif
551
552#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
553
554#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
555
556#elif defined(_LIBCPP_COMPILER_MSVC)
557
558#define _LIBCPP_TOSTRING2(x) #x
559#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
560#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
561
562#if _MSC_VER < 1900
563#error "MSVC versions prior to Visual Studio 2015 are not supported"
564#endif
565
566#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
567#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
568#define __alignof__ __alignof
569#define _LIBCPP_NORETURN __declspec(noreturn)
570#define _ALIGNAS(x) __declspec(align(x))
571#define _ALIGNAS_TYPE(x) alignas(x)
572
573#define _LIBCPP_WEAK
574
575#define _LIBCPP_HAS_NO_ASAN
576
577#define _LIBCPP_ALWAYS_INLINE __forceinline
578
579#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
580
581#define _LIBCPP_DISABLE_EXTENSION_WARNING
582
583#elif defined(_LIBCPP_COMPILER_IBM)
584
585#define _ALIGNAS(x) __attribute__((__aligned__(x)))
586#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
587#define _ATTRIBUTE(x) __attribute__((x))
588#define _LIBCPP_NORETURN __attribute__((noreturn))
589
590#define _LIBCPP_HAS_NO_UNICODE_CHARS
591#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
592
593#if defined(_AIX)
594#define __MULTILOCALE_API
595#endif
596
597#define _LIBCPP_HAS_NO_ASAN
598
599#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
600
601#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
602
603#define _LIBCPP_DISABLE_EXTENSION_WARNING
604
605#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
606
607#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
608
609#ifdef _DLL
610#  define _LIBCPP_CRT_FUNC __declspec(dllimport)
611#else
612#  define _LIBCPP_CRT_FUNC
613#endif
614
615#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
616#  define _LIBCPP_DLL_VIS
617#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
618#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
619#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
620#  define _LIBCPP_EXPORTED_FROM_ABI
621#elif defined(_LIBCPP_BUILDING_LIBRARY)
622#  define _LIBCPP_DLL_VIS __declspec(dllexport)
623#  if defined(__MINGW32__)
624#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
625#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
626#  else
627#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
628#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
629#  endif
630#  define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
631#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
632#else
633#  define _LIBCPP_DLL_VIS __declspec(dllimport)
634#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
635#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
636#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
637#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
638#endif
639
640#define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
641#define _LIBCPP_FUNC_VIS            _LIBCPP_DLL_VIS
642#define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
643#define _LIBCPP_HIDDEN
644#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
645#define _LIBCPP_TEMPLATE_VIS
646#define _LIBCPP_ENUM_VIS
647
648#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
649
650#ifndef _LIBCPP_HIDDEN
651#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
652#    define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
653#  else
654#    define _LIBCPP_HIDDEN
655#  endif
656#endif
657
658#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
659#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
660// The inline should be removed once PR32114 is resolved
661#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
662#  else
663#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
664#  endif
665#endif
666
667#ifndef _LIBCPP_FUNC_VIS
668#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
669#    define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
670#  else
671#    define _LIBCPP_FUNC_VIS
672#  endif
673#endif
674
675#ifndef _LIBCPP_TYPE_VIS
676#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
677#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
678#  else
679#    define _LIBCPP_TYPE_VIS
680#  endif
681#endif
682
683#ifndef _LIBCPP_TEMPLATE_VIS
684#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
685#    if __has_attribute(__type_visibility__)
686#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
687#    else
688#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
689#    endif
690#  else
691#    define _LIBCPP_TEMPLATE_VIS
692#  endif
693#endif
694
695#ifndef _LIBCPP_EXPORTED_FROM_ABI
696#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
697#    define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
698#  else
699#    define _LIBCPP_EXPORTED_FROM_ABI
700#  endif
701#endif
702
703#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
704#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
705#endif
706
707#ifndef _LIBCPP_EXCEPTION_ABI
708#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
709#    define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
710#  else
711#    define _LIBCPP_EXCEPTION_ABI
712#  endif
713#endif
714
715#ifndef _LIBCPP_ENUM_VIS
716#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
717#    define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
718#  else
719#    define _LIBCPP_ENUM_VIS
720#  endif
721#endif
722
723#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
724#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
725#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
726#  else
727#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
728#  endif
729#endif
730
731#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
732#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
733#endif
734
735#if __has_attribute(internal_linkage)
736#  define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
737#else
738#  define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
739#endif
740
741#if __has_attribute(exclude_from_explicit_instantiation)
742#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
743#else
744   // Try to approximate the effect of exclude_from_explicit_instantiation
745   // (which is that entities are not assumed to be provided by explicit
746   // template instantiations in the dylib) by always inlining those entities.
747#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
748#endif
749
750#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
751#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
752#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
753#  else
754#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
755#  endif
756#endif
757
758#ifndef _LIBCPP_HIDE_FROM_ABI
759#  if _LIBCPP_HIDE_FROM_ABI_PER_TU
760#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
761#  else
762#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
763#  endif
764#endif
765
766#ifdef _LIBCPP_BUILDING_LIBRARY
767#  if _LIBCPP_ABI_VERSION > 1
768#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
769#  else
770#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
771#  endif
772#else
773#  define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
774#endif
775
776// Just so we can migrate to the new macros gradually.
777#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
778
779// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
780#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
781#define _LIBCPP_END_NAMESPACE_STD  } }
782#define _VSTD std::_LIBCPP_ABI_NAMESPACE
783_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
784
785#if _LIBCPP_STD_VER >= 17
786#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
787  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
788#else
789#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
790  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
791#endif
792
793#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
794  _LIBCPP_END_NAMESPACE_STD } }
795
796#define _VSTD_FS _VSTD::__fs::filesystem
797
798#ifndef _LIBCPP_PREFERRED_OVERLOAD
799#  if __has_attribute(__enable_if__)
800#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
801#  endif
802#endif
803
804#ifndef _LIBCPP_HAS_NO_NOEXCEPT
805#  define _NOEXCEPT noexcept
806#  define _NOEXCEPT_(x) noexcept(x)
807#else
808#  define _NOEXCEPT throw()
809#  define _NOEXCEPT_(x)
810#endif
811
812#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
813typedef unsigned short char16_t;
814typedef unsigned int   char32_t;
815#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
816
817#ifndef __SIZEOF_INT128__
818#define _LIBCPP_HAS_NO_INT128
819#endif
820
821#ifdef _LIBCPP_CXX03_LANG
822# define static_assert(...) _Static_assert(__VA_ARGS__)
823# define decltype(...) __decltype(__VA_ARGS__)
824#endif  // _LIBCPP_CXX03_LANG
825
826#ifdef _LIBCPP_CXX03_LANG
827#  define _LIBCPP_CONSTEXPR
828#else
829#  define _LIBCPP_CONSTEXPR constexpr
830#endif
831
832#ifndef __cpp_consteval
833#  define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
834#else
835#  define _LIBCPP_CONSTEVAL consteval
836#endif
837
838#ifdef _LIBCPP_CXX03_LANG
839#  define _LIBCPP_DEFAULT {}
840#else
841#  define _LIBCPP_DEFAULT = default;
842#endif
843
844#ifdef _LIBCPP_CXX03_LANG
845#  define _LIBCPP_EQUAL_DELETE
846#else
847#  define _LIBCPP_EQUAL_DELETE = delete
848#endif
849
850#ifdef __GNUC__
851#  define _LIBCPP_NOALIAS __attribute__((__malloc__))
852#else
853#  define _LIBCPP_NOALIAS
854#endif
855
856#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
857    (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
858#  define _LIBCPP_EXPLICIT explicit
859#else
860#  define _LIBCPP_EXPLICIT
861#endif
862
863#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
864#  define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
865#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
866     __lx __v_; \
867     _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
868     _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
869     _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
870     };
871#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
872#  define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
873#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
874#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
875
876// _LIBCPP_DEBUG potential values:
877//  - undefined: No assertions. This is the default.
878//  - 0:         Basic assertions
879//  - 1:         Basic assertions + iterator validity checks.
880#if !defined(_LIBCPP_DEBUG)
881# define _LIBCPP_DEBUG_LEVEL 0
882#elif _LIBCPP_DEBUG == 0
883# define _LIBCPP_DEBUG_LEVEL 1
884#elif _LIBCPP_DEBUG == 1
885# define _LIBCPP_DEBUG_LEVEL 2
886#else
887# error Supported values for _LIBCPP_DEBUG are 0 and 1
888#endif
889
890// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
891#if _LIBCPP_DEBUG_LEVEL >= 1
892# define _LIBCPP_DISABLE_EXTERN_TEMPLATE
893#endif
894
895#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
896#define _LIBCPP_EXTERN_TEMPLATE(...)
897#endif
898
899#ifndef _LIBCPP_EXTERN_TEMPLATE
900#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
901#endif
902
903#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
904#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
905#endif
906
907#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
908    defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
909#define _LIBCPP_LOCALE__L_EXTENSIONS 1
910#endif
911
912#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
913// Most unix variants have catopen.  These are the specific ones that don't.
914#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
915#    define _LIBCPP_HAS_CATOPEN 1
916#  endif
917#endif
918
919#ifdef __FreeBSD__
920#define _DECLARE_C99_LDBL_MATH 1
921#endif
922
923// If we are getting operator new from the MSVC CRT, then allocation overloads
924// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
925#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
926#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
927#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
928   // We're deferring to Microsoft's STL to provide aligned new et al. We don't
929   // have it unless the language feature test macro is defined.
930#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
931#elif defined(__MVS__)
932#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
933#endif
934
935#if defined(__APPLE__)
936#  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
937      defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
938#    define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
939#  endif
940#endif // defined(__APPLE__)
941
942#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
943    (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
944    (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
945#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
946#endif
947
948#if defined(__APPLE__) || defined(__FreeBSD__)
949#define _LIBCPP_HAS_DEFAULTRUNELOCALE
950#endif
951
952#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
953#define _LIBCPP_WCTYPE_IS_MASK
954#endif
955
956#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
957#define _LIBCPP_NO_HAS_CHAR8_T
958#endif
959
960// Deprecation macros.
961//
962// Deprecations warnings are always enabled, except when users explicitly opt-out
963// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
964#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
965#  if __has_attribute(deprecated)
966#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
967#  elif _LIBCPP_STD_VER > 11
968#    define _LIBCPP_DEPRECATED [[deprecated]]
969#  else
970#    define _LIBCPP_DEPRECATED
971#  endif
972#else
973#  define _LIBCPP_DEPRECATED
974#endif
975
976#if !defined(_LIBCPP_CXX03_LANG)
977#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
978#else
979#  define _LIBCPP_DEPRECATED_IN_CXX11
980#endif
981
982#if _LIBCPP_STD_VER >= 14
983#  define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
984#else
985#  define _LIBCPP_DEPRECATED_IN_CXX14
986#endif
987
988#if _LIBCPP_STD_VER >= 17
989#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
990#else
991#  define _LIBCPP_DEPRECATED_IN_CXX17
992#endif
993
994#if _LIBCPP_STD_VER > 17
995#  define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
996#else
997#  define _LIBCPP_DEPRECATED_IN_CXX20
998#endif
999
1000// Macros to enter and leave a state where deprecation warnings are suppressed.
1001#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
1002    (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
1003#  define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
1004    _Pragma("GCC diagnostic push") \
1005    _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
1006#  define _LIBCPP_SUPPRESS_DEPRECATED_POP \
1007    _Pragma("GCC diagnostic pop")
1008#endif
1009#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
1010#  define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1011#  define _LIBCPP_SUPPRESS_DEPRECATED_POP
1012#endif
1013
1014#if _LIBCPP_STD_VER <= 11
1015#  define _LIBCPP_EXPLICIT_AFTER_CXX11
1016#else
1017#  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
1018#endif
1019
1020#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1021#  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
1022#else
1023#  define _LIBCPP_CONSTEXPR_AFTER_CXX11
1024#endif
1025
1026#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1027#  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
1028#else
1029#  define _LIBCPP_CONSTEXPR_AFTER_CXX14
1030#endif
1031
1032#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1033#  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
1034#else
1035#  define _LIBCPP_CONSTEXPR_AFTER_CXX17
1036#endif
1037
1038// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
1039// NODISCARD macros to the correct attribute.
1040#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1041#  define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
1042#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
1043#  define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
1044#else
1045// We can't use GCC's [[gnu::warn_unused_result]] and
1046// __attribute__((warn_unused_result)), because GCC does not silence them via
1047// (void) cast.
1048#  define _LIBCPP_NODISCARD_ATTRIBUTE
1049#endif
1050
1051// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1052// specified as such as an extension.
1053#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1054#  define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1055#else
1056#  define _LIBCPP_NODISCARD_EXT
1057#endif
1058
1059#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1060    (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1061#  define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
1062#else
1063#  define _LIBCPP_NODISCARD_AFTER_CXX17
1064#endif
1065
1066#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
1067#  define _LIBCPP_INLINE_VAR inline
1068#else
1069#  define _LIBCPP_INLINE_VAR
1070#endif
1071
1072#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
1073#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1074#define _LIBCPP_CONSTEXPR_IF_NODEBUG
1075#else
1076#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
1077#endif
1078#endif
1079
1080#if __has_attribute(no_destroy)
1081#  define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1082#else
1083#  define _LIBCPP_NO_DESTROY
1084#endif
1085
1086#ifndef _LIBCPP_HAS_NO_ASAN
1087_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1088  const void *, const void *, const void *, const void *);
1089#endif
1090
1091// Try to find out if RTTI is disabled.
1092#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti)
1093#  define _LIBCPP_NO_RTTI
1094#elif defined(__GNUC__) && !defined(__GXX_RTTI)
1095#  define _LIBCPP_NO_RTTI
1096#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
1097#  define _LIBCPP_NO_RTTI
1098#endif
1099
1100#ifndef _LIBCPP_WEAK
1101#define _LIBCPP_WEAK __attribute__((__weak__))
1102#endif
1103
1104// Thread API
1105#if !defined(_LIBCPP_HAS_NO_THREADS) && \
1106    !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1107    !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1108    !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1109#  if defined(__FreeBSD__) || \
1110      defined(__wasi__) || \
1111      defined(__NetBSD__) || \
1112      defined(__NuttX__) || \
1113      defined(__linux__) || \
1114      defined(__GNU__) || \
1115      defined(__APPLE__) || \
1116      defined(__CloudABI__) || \
1117      defined(__sun__) || \
1118      (defined(__MINGW32__) && __has_include(<pthread.h>))
1119#    define _LIBCPP_HAS_THREAD_API_PTHREAD
1120#  elif defined(__Fuchsia__)
1121     // TODO(44575): Switch to C11 thread API when possible.
1122#    define _LIBCPP_HAS_THREAD_API_PTHREAD
1123#  elif defined(_LIBCPP_WIN32API)
1124#    define _LIBCPP_HAS_THREAD_API_WIN32
1125#  else
1126#    error "No thread API"
1127#  endif // _LIBCPP_HAS_THREAD_API
1128#endif // _LIBCPP_HAS_NO_THREADS
1129
1130#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1131#if defined(__ANDROID__) && __ANDROID_API__ >= 30
1132#define _LIBCPP_HAS_COND_CLOCKWAIT
1133#elif defined(_LIBCPP_GLIBC_PREREQ)
1134#if _LIBCPP_GLIBC_PREREQ(2, 30)
1135#define _LIBCPP_HAS_COND_CLOCKWAIT
1136#endif
1137#endif
1138#endif
1139
1140#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1141#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1142       _LIBCPP_HAS_NO_THREADS is not defined.
1143#endif
1144
1145#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1146#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1147       _LIBCPP_HAS_NO_THREADS is defined.
1148#endif
1149
1150#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1151#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1152       _LIBCPP_HAS_NO_THREADS is defined.
1153#endif
1154
1155#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS)
1156#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
1157#endif
1158
1159#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1160#define __STDCPP_THREADS__ 1
1161#endif
1162
1163// The glibc and Bionic implementation of pthreads implements
1164// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1165// mutexes have no destroy mechanism.
1166//
1167// This optimization can't be performed on Apple platforms, where
1168// pthread_mutex_destroy can allow the kernel to release resources.
1169// See https://llvm.org/D64298 for details.
1170//
1171// TODO(EricWF): Enable this optimization on Bionic after speaking to their
1172//               respective stakeholders.
1173#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1174  || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
1175  || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1176# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1177#endif
1178
1179// Destroying a condvar is a nop on Windows.
1180//
1181// This optimization can't be performed on Apple platforms, where
1182// pthread_cond_destroy can allow the kernel to release resources.
1183// See https://llvm.org/D64298 for details.
1184//
1185// TODO(EricWF): This is potentially true for some pthread implementations
1186// as well.
1187#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
1188     defined(_LIBCPP_HAS_THREAD_API_WIN32)
1189# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1190#endif
1191
1192// Systems that use capability-based security (FreeBSD with Capsicum,
1193// Nuxi CloudABI) may only provide local filesystem access (using *at()).
1194// Functions like open(), rename(), unlink() and stat() should not be
1195// used, as they attempt to access the global filesystem namespace.
1196#ifdef __CloudABI__
1197#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1198#endif
1199
1200// CloudABI is intended for running networked services. Processes do not
1201// have standard input and output channels.
1202#ifdef __CloudABI__
1203#define _LIBCPP_HAS_NO_STDIN
1204#define _LIBCPP_HAS_NO_STDOUT
1205#endif
1206
1207// Some systems do not provide gets() in their C library, for security reasons.
1208#ifndef _LIBCPP_C_HAS_NO_GETS
1209#  if defined(_LIBCPP_MSVCRT) || \
1210      (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043)
1211#    define _LIBCPP_C_HAS_NO_GETS
1212#  endif
1213#endif
1214
1215#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) ||      \
1216    defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \
1217    defined(__MVS__)
1218#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1219#endif
1220
1221// Thread-unsafe functions such as strtok() and localtime()
1222// are not available.
1223#ifdef __CloudABI__
1224#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1225#endif
1226
1227#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1228#  define _LIBCPP_HAS_C_ATOMIC_IMP
1229#elif defined(_LIBCPP_COMPILER_GCC)
1230#  define _LIBCPP_HAS_GCC_ATOMIC_IMP
1231#endif
1232
1233#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1234     !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1235     !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
1236     || defined(_LIBCPP_HAS_NO_THREADS)
1237#  define _LIBCPP_HAS_NO_ATOMIC_HEADER
1238#else
1239#  ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1240#    define _LIBCPP_ATOMIC_FLAG_TYPE bool
1241#  endif
1242#  ifdef _LIBCPP_FREESTANDING
1243#    define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1244#  endif
1245#endif
1246
1247#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1248#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1249#endif
1250
1251#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1252#  if defined(__clang__) && __has_attribute(acquire_capability)
1253// Work around the attribute handling in clang.  When both __declspec and
1254// __attribute__ are present, the processing goes awry preventing the definition
1255// of the types.
1256#    if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1257#      define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1258#    endif
1259#  endif
1260#endif
1261
1262#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
1263#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1264#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
1265#  else
1266#    define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
1267#  endif
1268#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
1269
1270#if __has_attribute(require_constant_initialization)
1271#  define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1272#else
1273#  define _LIBCPP_SAFE_STATIC
1274#endif
1275
1276#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1277#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1278#endif
1279
1280#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
1281#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
1282#endif
1283
1284#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1285#  if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1286#    define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1287#  endif
1288#endif
1289
1290#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1291#  define _LIBCPP_DIAGNOSE_WARNING(...) \
1292     __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1293#  define _LIBCPP_DIAGNOSE_ERROR(...) \
1294     __attribute__((diagnose_if(__VA_ARGS__, "error")))
1295#else
1296#  define _LIBCPP_DIAGNOSE_WARNING(...)
1297#  define _LIBCPP_DIAGNOSE_ERROR(...)
1298#endif
1299
1300// Use a function like macro to imply that it must be followed by a semicolon
1301#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1302#  define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1303#elif __has_cpp_attribute(clang::fallthrough)
1304#  define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1305#elif __has_attribute(fallthrough) || _GNUC_VER >= 700
1306#  define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1307#else
1308#  define _LIBCPP_FALLTHROUGH() ((void)0)
1309#endif
1310
1311#if __has_attribute(__nodebug__)
1312#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1313#else
1314#define _LIBCPP_NODEBUG
1315#endif
1316
1317#ifndef _LIBCPP_NODEBUG_TYPE
1318#if __has_attribute(__nodebug__) && \
1319    (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
1320#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1321#else
1322#define _LIBCPP_NODEBUG_TYPE
1323#endif
1324#endif // !defined(_LIBCPP_NODEBUG_TYPE)
1325
1326#if defined(_LIBCPP_ABI_MICROSOFT) && \
1327    (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1328#  define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1329#else
1330#  define _LIBCPP_DECLSPEC_EMPTY_BASES
1331#endif
1332
1333#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1334#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1335#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1336#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1337#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1338#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1339
1340#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
1341#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1342#endif
1343
1344#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
1345#define _LIBCPP_HAS_NO_IS_AGGREGATE
1346#endif
1347
1348#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
1349#define _LIBCPP_HAS_NO_COROUTINES
1350#endif
1351
1352#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
1353#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1354#endif
1355
1356#if defined(_LIBCPP_COMPILER_IBM)
1357#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1358#endif
1359
1360#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1361#  define _LIBCPP_PUSH_MACROS
1362#  define _LIBCPP_POP_MACROS
1363#else
1364  // Don't warn about macro conflicts when we can restore them at the
1365  // end of the header.
1366#  ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1367#    define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1368#  endif
1369#  if defined(_LIBCPP_COMPILER_MSVC)
1370#    define _LIBCPP_PUSH_MACROS    \
1371       __pragma(push_macro("min")) \
1372       __pragma(push_macro("max"))
1373#    define _LIBCPP_POP_MACROS     \
1374       __pragma(pop_macro("min"))  \
1375       __pragma(pop_macro("max"))
1376#  else
1377#    define _LIBCPP_PUSH_MACROS        \
1378       _Pragma("push_macro(\"min\")")  \
1379       _Pragma("push_macro(\"max\")")
1380#    define _LIBCPP_POP_MACROS         \
1381       _Pragma("pop_macro(\"min\")")   \
1382       _Pragma("pop_macro(\"max\")")
1383#  endif
1384#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1385
1386#ifndef _LIBCPP_NO_AUTO_LINK
1387#  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1388#    if defined(_DLL)
1389#      pragma comment(lib, "c++.lib")
1390#    else
1391#      pragma comment(lib, "libc++.lib")
1392#    endif
1393#  endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1394#endif // _LIBCPP_NO_AUTO_LINK
1395
1396#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1397
1398// Configures the fopen close-on-exec mode character, if any. This string will
1399// be appended to any mode string used by fstream for fopen/fdopen.
1400//
1401// Not all platforms support this, but it helps avoid fd-leaks on platforms that
1402// do.
1403#if defined(__BIONIC__)
1404#  define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1405#else
1406#  define _LIBCPP_FOPEN_CLOEXEC_MODE
1407#endif
1408
1409#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P
1410#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x)
1411#else
1412#define _LIBCPP_BUILTIN_CONSTANT_P(x) false
1413#endif
1414
1415// Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
1416// of functions used in cstdio may not be available for low API levels when
1417// using 64-bit file offsets on LP32.
1418#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
1419#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1420#endif
1421
1422#if __has_attribute(init_priority)
1423# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1424#else
1425# define _LIBCPP_INIT_PRIORITY_MAX
1426#endif
1427
1428#endif // __cplusplus
1429
1430#endif // _LIBCPP_CONFIG
1431