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