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