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