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