2 //===--------------------------- __config ---------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_CONFIG
11 #define _LIBCPP_CONFIG
13 #if defined(_MSC_VER) && !defined(__clang__)
14 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15 # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
19 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20 #pragma GCC system_header
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__)
32 # define _GNUC_VER_NEW 0
35 #define _LIBCPP_VERSION 9000
37 #ifndef _LIBCPP_ABI_VERSION
38 # define _LIBCPP_ABI_VERSION 1
41 #ifndef __STDC_HOSTED__
42 # define _LIBCPP_FREESTANDING
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
53 # define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
55 #endif // _LIBCPP_STD_VER
58 # define _LIBCPP_OBJECT_FORMAT_ELF 1
59 #elif defined(__MACH__)
60 # define _LIBCPP_OBJECT_FORMAT_MACHO 1
62 # define _LIBCPP_OBJECT_FORMAT_COFF 1
63 #elif defined(__wasm__)
64 # define _LIBCPP_OBJECT_FORMAT_WASM 1
66 # error Unknown object file format
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
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
114 // Feature macros for disabling pre ABI v1 features. All of these options
116 # if defined(__FreeBSD__)
117 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
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
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)
129 #ifndef _LIBCPP_ABI_NAMESPACE
130 # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
133 #if __cplusplus < 201103L
134 #define _LIBCPP_CXX03_LANG
137 #ifndef __has_attribute
138 #define __has_attribute(__x) 0
141 #ifndef __has_builtin
142 #define __has_builtin(__x) 0
145 #ifndef __has_extension
146 #define __has_extension(__x) 0
149 #ifndef __has_feature
150 #define __has_feature(__x) 0
153 #ifndef __has_cpp_attribute
154 #define __has_cpp_attribute(__x) 0
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
163 #ifndef __has_declspec_attribute
164 #define __has_declspec_attribute(__x) 0
167 #define __has_keyword(__x) !(__is_identifier(__x))
169 #ifndef __has_include
170 #define __has_include(...) 0
173 #if defined(__clang__)
174 # define _LIBCPP_COMPILER_CLANG
175 # ifndef __apple_build_version__
176 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
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
186 #ifndef _LIBCPP_CLANG_VER
187 #define _LIBCPP_CLANG_VER 0
190 #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
191 #error "libc++ does not support using GCC with C++03. Please enable C++11"
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
206 # if defined(_WIN32) && defined(_MSC_VER)
207 # define _LIBCPP_ABI_MICROSOFT
209 # define _LIBCPP_ABI_ITANIUM
213 #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
214 # define _LIBCPP_ABI_VCRUNTIME
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)
223 # define _LIBCPP_GLIBC_PREREQ(a, b) 0
224 # endif // defined(__GLIBC_PREREQ)
225 #endif // defined(__linux__)
227 #ifdef __LITTLE_ENDIAN__
228 # if __LITTLE_ENDIAN__
229 # define _LIBCPP_LITTLE_ENDIAN
230 # endif // __LITTLE_ENDIAN__
231 #endif // __LITTLE_ENDIAN__
233 #ifdef __BIG_ENDIAN__
235 # define _LIBCPP_BIG_ENDIAN
236 # endif // __BIG_ENDIAN__
237 #endif // __BIG_ENDIAN__
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__
248 # include <sys/endian.h>
249 # include <osreldate.h>
250 # if _BYTE_ORDER == _LITTLE_ENDIAN
251 # define _LIBCPP_LITTLE_ENDIAN
252 # else // _BYTE_ORDER == _LITTLE_ENDIAN
253 # define _LIBCPP_BIG_ENDIAN
254 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
255 # ifndef __LONG_LONG_SUPPORTED
256 # define _LIBCPP_HAS_NO_LONG_LONG
257 # endif // __LONG_LONG_SUPPORTED
258 #endif // __FreeBSD__
261 # include <sys/endian.h>
262 # if _BYTE_ORDER == _LITTLE_ENDIAN
263 # define _LIBCPP_LITTLE_ENDIAN
264 # else // _BYTE_ORDER == _LITTLE_ENDIAN
265 # define _LIBCPP_BIG_ENDIAN
266 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
267 # define _LIBCPP_HAS_QUICK_EXIT
271 # define _LIBCPP_WIN32API
272 # define _LIBCPP_LITTLE_ENDIAN
273 # define _LIBCPP_SHORT_WCHAR 1
274 // Both MinGW and native MSVC provide a "MSVC"-like environment
275 # define _LIBCPP_MSVCRT_LIKE
276 // If mingw not explicitly detected, assume using MS C runtime only if
277 // a MS compatibility version is specified.
278 # if defined(_MSC_VER) && !defined(__MINGW32__)
279 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
281 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
282 # define _LIBCPP_HAS_BITSCAN64
284 # define _LIBCPP_HAS_OPEN_WITH_WCHAR
285 # if defined(_LIBCPP_MSVCRT)
286 # define _LIBCPP_HAS_QUICK_EXIT
289 // Some CRT APIs are unavailable to store apps
290 # if defined(WINAPI_FAMILY)
291 # include <winapifamily.h>
292 # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
293 (!defined(WINAPI_PARTITION_SYSTEM) || \
294 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
295 # define _LIBCPP_WINDOWS_STORE_APP
298 #endif // defined(_WIN32)
301 # include <sys/isa_defs.h>
302 # ifdef _LITTLE_ENDIAN
303 # define _LIBCPP_LITTLE_ENDIAN
305 # define _LIBCPP_BIG_ENDIAN
309 #if defined(__CloudABI__)
310 // Certain architectures provide arc4random(). Prefer using
311 // arc4random() over /dev/{u,}random to make it possible to obtain
312 // random data even when using sandboxing mechanisms such as chroots,
314 # define _LIBCPP_USING_ARC4_RANDOM
315 #elif defined(__Fuchsia__) || defined(__wasi__)
316 # define _LIBCPP_USING_GETENTROPY
317 #elif defined(__native_client__)
318 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
319 // including accesses to the special files under /dev. C++11's
320 // std::random_device is instead exposed through a NaCl syscall.
321 # define _LIBCPP_USING_NACL_RANDOM
322 #elif defined(_LIBCPP_WIN32API)
323 # define _LIBCPP_USING_WIN32_RANDOM
325 # define _LIBCPP_USING_DEV_RANDOM
328 #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
330 # if __BYTE_ORDER == __LITTLE_ENDIAN
331 # define _LIBCPP_LITTLE_ENDIAN
332 # elif __BYTE_ORDER == __BIG_ENDIAN
333 # define _LIBCPP_BIG_ENDIAN
334 # else // __BYTE_ORDER == __BIG_ENDIAN
335 # error unable to determine endian
337 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
339 #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
340 # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
342 # define _LIBCPP_NO_CFI
345 #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
346 # if defined(__FreeBSD__)
347 # define _LIBCPP_HAS_QUICK_EXIT
348 # define _LIBCPP_HAS_C11_FEATURES
349 # elif defined(__Fuchsia__) || defined(__wasi__)
350 # define _LIBCPP_HAS_QUICK_EXIT
351 # define _LIBCPP_HAS_TIMESPEC_GET
352 # define _LIBCPP_HAS_C11_FEATURES
353 # elif defined(__linux__)
354 # if !defined(_LIBCPP_HAS_MUSL_LIBC)
355 # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
356 # define _LIBCPP_HAS_QUICK_EXIT
358 # if _LIBCPP_GLIBC_PREREQ(2, 17)
359 # define _LIBCPP_HAS_C11_FEATURES
360 # define _LIBCPP_HAS_TIMESPEC_GET
362 # else // defined(_LIBCPP_HAS_MUSL_LIBC)
363 # define _LIBCPP_HAS_QUICK_EXIT
364 # define _LIBCPP_HAS_TIMESPEC_GET
365 # define _LIBCPP_HAS_C11_FEATURES
370 #ifndef _LIBCPP_CXX03_LANG
371 # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
372 #elif defined(_LIBCPP_COMPILER_CLANG)
373 # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
375 // This definition is potentially buggy, but it's only taken with GCC in C++03,
376 // which we barely support anyway. See llvm.org/PR39713
377 # define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
380 #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
382 #if defined(_LIBCPP_COMPILER_CLANG)
384 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
385 // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
386 #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
387 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \
388 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
389 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
392 #if __has_feature(cxx_alignas)
393 # define _ALIGNAS_TYPE(x) alignas(x)
394 # define _ALIGNAS(x) alignas(x)
396 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
397 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
400 #if __cplusplus < 201103L
401 typedef __char16_t char16_t;
402 typedef __char32_t char32_t;
405 #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
406 #define _LIBCPP_NO_EXCEPTIONS
409 #if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
410 #define _LIBCPP_NO_RTTI
413 #if !(__has_feature(cxx_strong_enums))
414 #define _LIBCPP_HAS_NO_STRONG_ENUMS
417 #if __has_feature(cxx_attributes)
418 # define _LIBCPP_NORETURN [[noreturn]]
420 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
423 #if !(__has_feature(cxx_lambdas))
424 #define _LIBCPP_HAS_NO_LAMBDAS
427 #if !(__has_feature(cxx_nullptr))
428 # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
429 # define nullptr __nullptr
431 # define _LIBCPP_HAS_NO_NULLPTR
435 #if !(__has_feature(cxx_rvalue_references))
436 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
439 #if !(__has_feature(cxx_auto_type))
440 #define _LIBCPP_HAS_NO_AUTO_TYPE
443 #if !(__has_feature(cxx_variadic_templates))
444 #define _LIBCPP_HAS_NO_VARIADICS
447 // Objective-C++ features (opt-in)
448 #if __has_feature(objc_arc)
449 #define _LIBCPP_HAS_OBJC_ARC
452 #if __has_feature(objc_arc_weak)
453 #define _LIBCPP_HAS_OBJC_ARC_WEAK
456 #if !(__has_feature(cxx_relaxed_constexpr))
457 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
460 #if !(__has_feature(cxx_variable_templates))
461 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
464 #if !(__has_feature(cxx_noexcept))
465 #define _LIBCPP_HAS_NO_NOEXCEPT
468 #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
469 #define _LIBCPP_HAS_NO_ASAN
472 // Allow for build-time disabling of unsigned integer sanitization
473 #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
474 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
477 #if __has_builtin(__builtin_launder)
478 #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
481 #if !__is_identifier(__has_unique_object_representations)
482 #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
485 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
487 // No apple compilers support ""d and ""y at this time.
488 #if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
489 #define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
492 #elif defined(_LIBCPP_COMPILER_GCC)
494 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
495 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
497 #define _LIBCPP_NORETURN __attribute__((noreturn))
499 #if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
500 #define _LIBCPP_NO_EXCEPTIONS
503 // Determine if GCC supports relaxed constexpr
504 #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
505 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
508 // GCC 5 supports variable templates
509 #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
510 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
513 #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
514 #define _LIBCPP_HAS_NO_ASAN
518 #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
522 #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
525 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
527 #elif defined(_LIBCPP_COMPILER_MSVC)
529 #define _LIBCPP_TOSTRING2(x) #x
530 #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
531 #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
534 #error "MSVC versions prior to Visual Studio 2015 are not supported"
537 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
538 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
539 #define __alignof__ __alignof
540 #define _LIBCPP_NORETURN __declspec(noreturn)
541 #define _ALIGNAS(x) __declspec(align(x))
542 #define _ALIGNAS_TYPE(x) alignas(x)
546 #define _LIBCPP_HAS_NO_ASAN
548 #define _LIBCPP_ALWAYS_INLINE __forceinline
550 #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
552 #elif defined(_LIBCPP_COMPILER_IBM)
554 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
555 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
556 #define _ATTRIBUTE(x) __attribute__((x))
557 #define _LIBCPP_NORETURN __attribute__((noreturn))
559 #define _LIBCPP_HAS_NO_UNICODE_CHARS
560 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
563 #define __MULTILOCALE_API
566 #define _LIBCPP_HAS_NO_ASAN
568 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
570 #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
572 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
574 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
577 # define _LIBCPP_CRT_FUNC __declspec(dllimport)
579 # define _LIBCPP_CRT_FUNC
582 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
583 # define _LIBCPP_DLL_VIS
584 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
585 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
586 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
587 # define _LIBCPP_EXPORTED_FROM_ABI
588 #elif defined(_LIBCPP_BUILDING_LIBRARY)
589 # define _LIBCPP_DLL_VIS __declspec(dllexport)
590 # if defined(__MINGW32__)
591 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
592 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
594 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
595 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
597 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
598 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
600 # define _LIBCPP_DLL_VIS __declspec(dllimport)
601 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
602 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
603 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
604 # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
607 #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
608 #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
609 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
610 #define _LIBCPP_HIDDEN
611 #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
612 #define _LIBCPP_TEMPLATE_VIS
613 #define _LIBCPP_ENUM_VIS
615 #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
617 #ifndef _LIBCPP_HIDDEN
618 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
619 # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
621 # define _LIBCPP_HIDDEN
625 #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
626 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
627 // The inline should be removed once PR32114 is resolved
628 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
630 # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
634 #ifndef _LIBCPP_FUNC_VIS
635 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
636 # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
638 # define _LIBCPP_FUNC_VIS
642 #ifndef _LIBCPP_TYPE_VIS
643 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
644 # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
646 # define _LIBCPP_TYPE_VIS
650 #ifndef _LIBCPP_TEMPLATE_VIS
651 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
652 # if __has_attribute(__type_visibility__)
653 # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
655 # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
658 # define _LIBCPP_TEMPLATE_VIS
662 #ifndef _LIBCPP_EXPORTED_FROM_ABI
663 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
664 # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
666 # define _LIBCPP_EXPORTED_FROM_ABI
670 #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
671 #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
674 #ifndef _LIBCPP_EXCEPTION_ABI
675 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
676 # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
678 # define _LIBCPP_EXCEPTION_ABI
682 #ifndef _LIBCPP_ENUM_VIS
683 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
684 # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
686 # define _LIBCPP_ENUM_VIS
690 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
691 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
692 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
694 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
698 #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
699 #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
702 #if __has_attribute(internal_linkage)
703 # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
705 # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
708 #if __has_attribute(exclude_from_explicit_instantiation)
709 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
711 // Try to approximate the effect of exclude_from_explicit_instantiation
712 // (which is that entities are not assumed to be provided by explicit
713 // template instantiations in the dylib) by always inlining those entities.
714 # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
717 #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
718 # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
719 # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
721 # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
725 #ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
726 # ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
727 # define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 0
729 // TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
730 // And we should consider defaulting to OFF.
731 # define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 1
735 #ifndef _LIBCPP_HIDE_FROM_ABI
736 # if _LIBCPP_HIDE_FROM_ABI_PER_TU
737 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
739 # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
743 #ifdef _LIBCPP_BUILDING_LIBRARY
744 # if _LIBCPP_ABI_VERSION > 1
745 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
747 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
750 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
753 // Just so we can migrate to the new macros gradually.
754 #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
756 // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
757 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
758 #define _LIBCPP_END_NAMESPACE_STD } }
759 #define _VSTD std::_LIBCPP_ABI_NAMESPACE
760 _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
762 #if _LIBCPP_STD_VER >= 17
763 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
764 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
766 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
767 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
770 #define _LIBCPP_END_NAMESPACE_FILESYSTEM \
771 _LIBCPP_END_NAMESPACE_STD } }
773 #define _VSTD_FS _VSTD::__fs::filesystem
775 #ifndef _LIBCPP_PREFERRED_OVERLOAD
776 # if __has_attribute(__enable_if__)
777 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
781 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
782 # define _NOEXCEPT noexcept
783 # define _NOEXCEPT_(x) noexcept(x)
785 # define _NOEXCEPT throw()
786 # define _NOEXCEPT_(x)
789 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
790 typedef unsigned short char16_t;
791 typedef unsigned int char32_t;
792 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
794 #ifndef __SIZEOF_INT128__
795 #define _LIBCPP_HAS_NO_INT128
798 #ifdef _LIBCPP_CXX03_LANG
799 # define static_assert(...) _Static_assert(__VA_ARGS__)
800 # define decltype(...) __decltype(__VA_ARGS__)
801 #endif // _LIBCPP_CXX03_LANG
803 #ifdef _LIBCPP_CXX03_LANG
804 # define _LIBCPP_CONSTEXPR
806 # define _LIBCPP_CONSTEXPR constexpr
809 #ifdef _LIBCPP_CXX03_LANG
810 # define _LIBCPP_DEFAULT {}
812 # define _LIBCPP_DEFAULT = default;
815 #ifdef _LIBCPP_CXX03_LANG
816 # define _LIBCPP_EQUAL_DELETE
818 # define _LIBCPP_EQUAL_DELETE = delete
822 # define _LIBCPP_NOALIAS __attribute__((__malloc__))
824 # define _LIBCPP_NOALIAS
827 #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
828 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
829 # define _LIBCPP_EXPLICIT explicit
831 # define _LIBCPP_EXPLICIT
834 #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
835 #define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
838 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
839 # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
840 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
842 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
843 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
844 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
846 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
847 # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
848 # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
849 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
852 # if _LIBCPP_DEBUG == 0
853 # define _LIBCPP_DEBUG_LEVEL 1
854 # elif _LIBCPP_DEBUG == 1
855 # define _LIBCPP_DEBUG_LEVEL 2
857 # error Supported values for _LIBCPP_DEBUG are 0 and 1
859 # if !defined(_LIBCPP_BUILDING_LIBRARY)
860 # define _LIBCPP_EXTERN_TEMPLATE(...)
864 #ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
865 #define _LIBCPP_EXTERN_TEMPLATE(...)
866 #define _LIBCPP_EXTERN_TEMPLATE2(...)
869 #ifndef _LIBCPP_EXTERN_TEMPLATE
870 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
873 #ifndef _LIBCPP_EXTERN_TEMPLATE2
874 #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
877 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
878 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
879 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
882 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
883 // Most unix variants have catopen. These are the specific ones that don't.
884 # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
885 # define _LIBCPP_HAS_CATOPEN 1
890 #define _DECLARE_C99_LDBL_MATH 1
893 // If we are getting operator new from the MSVC CRT, then allocation overloads
894 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
895 #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
896 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
897 #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
898 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
899 // have it unless the language feature test macro is defined.
900 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
903 #if defined(__APPLE__)
904 # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
905 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
906 # define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
908 #endif // defined(__APPLE__)
910 #if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
911 (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
912 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
913 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
916 #if defined(__APPLE__) || defined(__FreeBSD__)
917 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
920 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
921 #define _LIBCPP_WCTYPE_IS_MASK
924 #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
925 #define _LIBCPP_NO_HAS_CHAR8_T
928 // Deprecation macros.
930 // Deprecations warnings are always enabled, except when users explicitly opt-out
931 // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
932 #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
933 # if __has_attribute(deprecated)
934 # define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
935 # elif _LIBCPP_STD_VER > 11
936 # define _LIBCPP_DEPRECATED [[deprecated]]
938 # define _LIBCPP_DEPRECATED
941 # define _LIBCPP_DEPRECATED
944 #if !defined(_LIBCPP_CXX03_LANG)
945 # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
947 # define _LIBCPP_DEPRECATED_IN_CXX11
950 #if _LIBCPP_STD_VER >= 14
951 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
953 # define _LIBCPP_DEPRECATED_IN_CXX14
956 #if _LIBCPP_STD_VER >= 17
957 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
959 # define _LIBCPP_DEPRECATED_IN_CXX17
962 #if _LIBCPP_STD_VER <= 11
963 # define _LIBCPP_EXPLICIT_AFTER_CXX11
965 # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
968 #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
969 # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
971 # define _LIBCPP_CONSTEXPR_AFTER_CXX11
974 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
975 # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
977 # define _LIBCPP_CONSTEXPR_AFTER_CXX14
980 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
981 # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
983 # define _LIBCPP_CONSTEXPR_AFTER_CXX17
986 // The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
987 // NODISCARD macros to the correct attribute.
988 #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
989 # define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
990 #elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
991 # define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
993 // We can't use GCC's [[gnu::warn_unused_result]] and
994 // __attribute__((warn_unused_result)), because GCC does not silence them via
996 # define _LIBCPP_NODISCARD_ATTRIBUTE
999 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1000 // specified as such as an extension.
1001 #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1002 # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1004 # define _LIBCPP_NODISCARD_EXT
1007 #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1008 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1009 # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
1011 # define _LIBCPP_NODISCARD_AFTER_CXX17
1014 #if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
1015 # define _LIBCPP_INLINE_VAR inline
1017 # define _LIBCPP_INLINE_VAR
1020 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1021 # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
1023 # define _LIBCPP_EXPLICIT_MOVE(x) (x)
1026 #ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
1027 #if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1028 #define _LIBCPP_CONSTEXPR_IF_NODEBUG
1030 #define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
1034 #if __has_attribute(no_destroy)
1035 # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1037 # define _LIBCPP_NO_DESTROY
1040 #ifndef _LIBCPP_HAS_NO_ASAN
1041 _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1042 const void *, const void *, const void *, const void *);
1045 // Try to find out if RTTI is disabled.
1046 // g++ and cl.exe have RTTI on by default and define a macro when it is.
1047 // g++ only defines the macro in 4.3.2 and onwards.
1048 #if !defined(_LIBCPP_NO_RTTI)
1049 # if defined(__GNUC__) && \
1050 ((__GNUC__ >= 5) || \
1051 (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \
1052 !defined(__GXX_RTTI)
1053 # define _LIBCPP_NO_RTTI
1054 # elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
1055 # define _LIBCPP_NO_RTTI
1059 #ifndef _LIBCPP_WEAK
1060 #define _LIBCPP_WEAK __attribute__((__weak__))
1064 #if !defined(_LIBCPP_HAS_NO_THREADS) && \
1065 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
1066 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1067 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1068 # if defined(__FreeBSD__) || \
1069 defined(__Fuchsia__) || \
1070 defined(__wasi__) || \
1071 defined(__NetBSD__) || \
1072 defined(__linux__) || \
1073 defined(__GNU__) || \
1074 defined(__APPLE__) || \
1075 defined(__CloudABI__) || \
1076 defined(__sun__) || \
1077 (defined(__MINGW32__) && __has_include(<pthread.h>))
1078 # define _LIBCPP_HAS_THREAD_API_PTHREAD
1079 # elif defined(_LIBCPP_WIN32API)
1080 # define _LIBCPP_HAS_THREAD_API_WIN32
1082 # error "No thread API"
1083 # endif // _LIBCPP_HAS_THREAD_API
1084 #endif // _LIBCPP_HAS_NO_THREADS
1086 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1087 #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1088 _LIBCPP_HAS_NO_THREADS is not defined.
1091 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1092 #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1093 _LIBCPP_HAS_NO_THREADS is defined.
1096 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1097 #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1098 _LIBCPP_HAS_NO_THREADS is defined.
1101 // The Apple, glibc, and Bionic implementation of pthreads implements
1102 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1103 // mutexes have no destroy mechanism.
1104 // TODO(EricWF): Enable this optimization on Apple and Bionic platforms after
1105 // speaking to their respective stakeholders.
1106 #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1107 || defined(_LIBCPP_HAS_THREAD_API_WIN32)
1108 # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1111 // Destroying a condvar is a nop on Windows.
1112 // TODO(EricWF): This is potentially true for some pthread implementations
1114 #if defined(_LIBCPP_HAS_THREAD_API_WIN32)
1115 # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1118 // Systems that use capability-based security (FreeBSD with Capsicum,
1119 // Nuxi CloudABI) may only provide local filesystem access (using *at()).
1120 // Functions like open(), rename(), unlink() and stat() should not be
1121 // used, as they attempt to access the global filesystem namespace.
1123 #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1126 // CloudABI is intended for running networked services. Processes do not
1127 // have standard input and output channels.
1129 #define _LIBCPP_HAS_NO_STDIN
1130 #define _LIBCPP_HAS_NO_STDOUT
1133 // Some systems do not provide gets() in their C library, for security reasons.
1134 #ifndef _LIBCPP_C_HAS_NO_GETS
1135 # if defined(_LIBCPP_MSVCRT) || \
1136 (defined(__FreeBSD__) && __FreeBSD_version >= 1300043)
1137 # define _LIBCPP_C_HAS_NO_GETS
1141 #if defined(__BIONIC__) || defined(__CloudABI__) || \
1142 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
1143 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1146 // Thread-unsafe functions such as strtok() and localtime()
1147 // are not available.
1149 #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1152 #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
1153 # define _LIBCPP_HAS_C_ATOMIC_IMP
1154 #elif defined(_LIBCPP_COMPILER_GCC)
1155 # define _LIBCPP_HAS_GCC_ATOMIC_IMP
1158 #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1159 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1160 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
1161 || defined(_LIBCPP_HAS_NO_THREADS)
1162 # define _LIBCPP_HAS_NO_ATOMIC_HEADER
1164 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1165 # define _LIBCPP_ATOMIC_FLAG_TYPE bool
1167 # ifdef _LIBCPP_FREESTANDING
1168 # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1172 #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1173 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1176 #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1177 # if defined(__clang__) && __has_attribute(acquire_capability)
1178 // Work around the attribute handling in clang. When both __declspec and
1179 // __attribute__ are present, the processing goes awry preventing the definition
1181 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1182 # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1187 #if __has_attribute(require_constant_initialization)
1188 # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1190 # define _LIBCPP_SAFE_STATIC
1193 #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1194 #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1197 #if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
1198 #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
1201 #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1202 # if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1203 # define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1207 #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1208 # define _LIBCPP_DIAGNOSE_WARNING(...) \
1209 __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1210 # define _LIBCPP_DIAGNOSE_ERROR(...) \
1211 __attribute__((diagnose_if(__VA_ARGS__, "error")))
1213 # define _LIBCPP_DIAGNOSE_WARNING(...)
1214 # define _LIBCPP_DIAGNOSE_ERROR(...)
1217 // Use a function like macro to imply that it must be followed by a semicolon
1218 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1219 # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1220 #elif __has_cpp_attribute(clang::fallthrough)
1221 # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1222 #elif __has_attribute(fallthough) || _GNUC_VER >= 700
1223 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1225 # define _LIBCPP_FALLTHROUGH() ((void)0)
1228 #if __has_attribute(__nodebug__)
1229 #define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1231 #define _LIBCPP_NODEBUG
1234 #ifndef _LIBCPP_NODEBUG_TYPE
1235 #if __has_attribute(__nodebug__) && \
1236 (defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 900)
1237 #define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1239 #define _LIBCPP_NODEBUG_TYPE
1241 #endif // !defined(_LIBCPP_NODEBUG_TYPE)
1243 #if defined(_LIBCPP_ABI_MICROSOFT) && \
1244 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1245 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1247 # define _LIBCPP_DECLSPEC_EMPTY_BASES
1250 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1251 #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1252 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1253 #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1254 #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1255 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1257 #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
1258 #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1261 #if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
1262 #define _LIBCPP_HAS_NO_IS_AGGREGATE
1265 #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
1266 #define _LIBCPP_HAS_NO_COROUTINES
1269 // FIXME: Correct this macro when either (A) a feature test macro for the
1270 // spaceship operator is provided, or (B) a compiler provides a complete
1272 #define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1274 // Decide whether to use availability macros.
1275 #if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1276 !defined(_LIBCPP_DISABLE_AVAILABILITY) && \
1277 __has_feature(attribute_availability_with_strict) && \
1278 __has_feature(attribute_availability_in_templates) && \
1279 __has_extension(pragma_clang_attribute_external_declaration)
1281 # define _LIBCPP_USE_AVAILABILITY_APPLE
1285 // Define availability macros.
1286 #if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
1287 # define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
1288 __attribute__((availability(macosx,strict,introduced=10.12))) \
1289 __attribute__((availability(ios,strict,introduced=10.0))) \
1290 __attribute__((availability(tvos,strict,introduced=10.0))) \
1291 __attribute__((availability(watchos,strict,introduced=3.0)))
1292 # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
1293 __attribute__((availability(macosx,strict,introduced=10.14))) \
1294 __attribute__((availability(ios,strict,introduced=12.0))) \
1295 __attribute__((availability(tvos,strict,introduced=12.0))) \
1296 __attribute__((availability(watchos,strict,introduced=5.0)))
1297 # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
1298 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1299 # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
1300 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1301 # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
1302 __attribute__((availability(macosx,strict,introduced=10.12))) \
1303 __attribute__((availability(ios,strict,introduced=10.0))) \
1304 __attribute__((availability(tvos,strict,introduced=10.0))) \
1305 __attribute__((availability(watchos,strict,introduced=3.0)))
1306 # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
1307 __attribute__((availability(macosx,strict,introduced=10.12))) \
1308 __attribute__((availability(ios,strict,introduced=10.0))) \
1309 __attribute__((availability(tvos,strict,introduced=10.0))) \
1310 __attribute__((availability(watchos,strict,introduced=3.0)))
1311 # define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
1312 __attribute__((availability(ios,strict,introduced=6.0)))
1313 # define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
1314 __attribute__((availability(macosx,strict,introduced=10.9))) \
1315 __attribute__((availability(ios,strict,introduced=7.0)))
1316 # define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
1317 __attribute__((availability(macosx,strict,introduced=10.9))) \
1318 __attribute__((availability(ios,strict,introduced=7.0)))
1319 # define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
1320 __attribute__((availability(macosx,strict,introduced=10.9))) \
1321 __attribute__((availability(ios,strict,introduced=7.0)))
1322 # define _LIBCPP_AVAILABILITY_FILESYSTEM \
1323 __attribute__((availability(macosx,strict,introduced=10.15))) \
1324 __attribute__((availability(ios,strict,introduced=13.0))) \
1325 __attribute__((availability(tvos,strict,introduced=13.0))) \
1326 __attribute__((availability(watchos,strict,introduced=6.0)))
1327 # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
1328 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
1329 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
1330 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
1331 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
1332 # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
1333 _Pragma("clang attribute pop") \
1334 _Pragma("clang attribute pop") \
1335 _Pragma("clang attribute pop") \
1336 _Pragma("clang attribute pop")
1338 # define _LIBCPP_AVAILABILITY_SHARED_MUTEX
1339 # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
1340 # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1341 # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1342 # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
1343 # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
1344 # define _LIBCPP_AVAILABILITY_FUTURE_ERROR
1345 # define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
1346 # define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
1347 # define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1348 # define _LIBCPP_AVAILABILITY_FILESYSTEM
1349 # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
1350 # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
1353 // Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
1354 #ifdef _LIBCPP_NO_EXCEPTIONS
1355 # define _LIBCPP_AVAILABILITY_FUTURE
1356 # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
1357 # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1358 # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1360 # define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
1361 # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1362 # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1363 # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
1366 // The stream API was dropped and re-added in the dylib shipped on macOS
1367 // and iOS. We can only assume the dylib to provide these definitions for
1368 // macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
1369 // from the headers, but not from the dylib. Explicit instantiation
1370 // declarations for streams exist conditionally to this; if we provide
1371 // an explicit instantiation declaration and we try to deploy to a dylib
1372 // that does not provide those symbols, we'll get a load-time error.
1373 #if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1374 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
1375 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
1376 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
1377 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
1378 # define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
1381 #if defined(_LIBCPP_COMPILER_IBM)
1382 #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1385 #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1386 # define _LIBCPP_PUSH_MACROS
1387 # define _LIBCPP_POP_MACROS
1389 // Don't warn about macro conflicts when we can restore them at the
1390 // end of the header.
1391 # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1392 # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1394 # if defined(_LIBCPP_COMPILER_MSVC)
1395 # define _LIBCPP_PUSH_MACROS \
1396 __pragma(push_macro("min")) \
1397 __pragma(push_macro("max"))
1398 # define _LIBCPP_POP_MACROS \
1399 __pragma(pop_macro("min")) \
1400 __pragma(pop_macro("max"))
1402 # define _LIBCPP_PUSH_MACROS \
1403 _Pragma("push_macro(\"min\")") \
1404 _Pragma("push_macro(\"max\")")
1405 # define _LIBCPP_POP_MACROS \
1406 _Pragma("pop_macro(\"min\")") \
1407 _Pragma("pop_macro(\"max\")")
1409 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1411 #ifndef _LIBCPP_NO_AUTO_LINK
1412 # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1414 # pragma comment(lib, "c++.lib")
1416 # pragma comment(lib, "libc++.lib")
1418 # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1419 #endif // _LIBCPP_NO_AUTO_LINK
1421 #define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1423 #endif // __cplusplus
1425 #endif // _LIBCPP_CONFIG