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