2 //===--------------------------- __config ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_CONFIG
12 #define _LIBCPP_CONFIG
14 #if defined(_MSC_VER) && !defined(__clang__)
15 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
18 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
19 #pragma GCC system_header
25 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
30 #define _LIBCPP_VERSION 4000
32 #ifndef _LIBCPP_ABI_VERSION
33 #define _LIBCPP_ABI_VERSION 1
36 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
37 // Change short string representation so that string data starts at offset 0,
38 // improving its alignment in some cases.
39 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
40 // Fix deque iterator type in order to support incomplete types.
41 #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
42 // Fix undefined behavior in how std::list stores it's linked nodes.
43 #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
44 // Fix undefined behavior in how __tree stores its end and parent nodes.
45 #define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
46 // Fix undefined behavior in how __hash_table stores it's pointer types
47 #define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
48 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
49 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
50 #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
51 // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
52 // provided under the alternate keyword __nullptr, which changes the mangling
53 // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
54 #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
55 // Define the `pointer_safety` enum as a C++11 strongly typed enumeration
56 // instead of as a class simulating an enum. If this option is enabled
57 // `pointer_safety` and `get_pointer_safety()` will no longer be available
59 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
60 #elif _LIBCPP_ABI_VERSION == 1
62 // Enable compiling a definition of error_category() into the libc++ dylib.
63 #define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
65 // Feature macros for disabling pre ABI v1 features. All of these options
67 #if defined(__FreeBSD__)
68 #define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
72 #ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
73 #error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
74 use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
77 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
78 #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
80 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
82 #if __cplusplus < 201103L
83 #define _LIBCPP_CXX03_LANG
86 #ifndef __has_attribute
87 #define __has_attribute(__x) 0
90 #define __has_builtin(__x) 0
92 #ifndef __has_extension
93 #define __has_extension(__x) 0
96 #define __has_feature(__x) 0
98 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
99 // the compiler and '1' otherwise.
100 #ifndef __is_identifier
101 #define __is_identifier(__x) 1
104 #if defined(__clang__)
105 #define _LIBCPP_COMPILER_CLANG
106 # ifndef __apple_build_version__
107 # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
109 #elif defined(__GNUC__)
110 #define _LIBCPP_COMPILER_GCC
111 #elif defined(_MSC_VER)
112 #define _LIBCPP_COMPILER_MSVC
113 #elif defined(__IBMCPP__)
114 #define _LIBCPP_COMPILER_IBM
117 #ifndef _LIBCPP_CLANG_VER
118 # define _LIBCPP_CLANG_VER 0
121 // FIXME: ABI detection should be done via compiler builtin macros. This
122 // is just a placeholder until Clang implements such macros. For now assume
123 // that Windows compilers pretending to be MSVC++ target the microsoft ABI.
124 #if defined(_WIN32) && defined(_MSC_VER)
125 # define _LIBCPP_ABI_MICROSOFT
127 # define _LIBCPP_ABI_ITANIUM
130 // Need to detect which libc we're using if we're on Linux.
131 #if defined(__linux__)
132 #include <features.h>
133 #if !defined(__GLIBC_PREREQ)
134 #define __GLIBC_PREREQ(a, b) 0
135 #endif // !defined(__GLIBC_PREREQ)
136 #endif // defined(__linux__)
138 #ifdef __LITTLE_ENDIAN__
139 #if __LITTLE_ENDIAN__
140 #define _LIBCPP_LITTLE_ENDIAN 1
141 #define _LIBCPP_BIG_ENDIAN 0
142 #endif // __LITTLE_ENDIAN__
143 #endif // __LITTLE_ENDIAN__
145 #ifdef __BIG_ENDIAN__
147 #define _LIBCPP_LITTLE_ENDIAN 0
148 #define _LIBCPP_BIG_ENDIAN 1
149 #endif // __BIG_ENDIAN__
150 #endif // __BIG_ENDIAN__
152 #ifdef __BYTE_ORDER__
153 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
154 #define _LIBCPP_LITTLE_ENDIAN 1
155 #define _LIBCPP_BIG_ENDIAN 0
156 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
157 #define _LIBCPP_LITTLE_ENDIAN 0
158 #define _LIBCPP_BIG_ENDIAN 1
159 #endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
160 #endif // __BYTE_ORDER__
163 # include <sys/endian.h>
164 # if _BYTE_ORDER == _LITTLE_ENDIAN
165 # define _LIBCPP_LITTLE_ENDIAN 1
166 # define _LIBCPP_BIG_ENDIAN 0
167 # else // _BYTE_ORDER == _LITTLE_ENDIAN
168 # define _LIBCPP_LITTLE_ENDIAN 0
169 # define _LIBCPP_BIG_ENDIAN 1
170 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
171 # ifndef __LONG_LONG_SUPPORTED
172 # define _LIBCPP_HAS_NO_LONG_LONG
173 # endif // __LONG_LONG_SUPPORTED
174 #endif // __FreeBSD__
177 # include <sys/endian.h>
178 # if _BYTE_ORDER == _LITTLE_ENDIAN
179 # define _LIBCPP_LITTLE_ENDIAN 1
180 # define _LIBCPP_BIG_ENDIAN 0
181 # else // _BYTE_ORDER == _LITTLE_ENDIAN
182 # define _LIBCPP_LITTLE_ENDIAN 0
183 # define _LIBCPP_BIG_ENDIAN 1
184 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
185 # define _LIBCPP_HAS_QUICK_EXIT
189 # define _LIBCPP_WIN32API 1
190 # define _LIBCPP_LITTLE_ENDIAN 1
191 # define _LIBCPP_BIG_ENDIAN 0
192 # define _LIBCPP_SHORT_WCHAR 1
194 // If mingw not explicitly detected, assume using MS C runtime only.
196 # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
198 # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
199 # define _LIBCPP_HAS_BITSCAN64
201 #endif // defined(_WIN32)
204 # include <sys/isa_defs.h>
205 # ifdef _LITTLE_ENDIAN
206 # define _LIBCPP_LITTLE_ENDIAN 1
207 # define _LIBCPP_BIG_ENDIAN 0
209 # define _LIBCPP_LITTLE_ENDIAN 0
210 # define _LIBCPP_BIG_ENDIAN 1
214 #if defined(__CloudABI__)
215 // Certain architectures provide arc4random(). Prefer using
216 // arc4random() over /dev/{u,}random to make it possible to obtain
217 // random data even when using sandboxing mechanisms such as chroots,
219 # define _LIBCPP_USING_ARC4_RANDOM
220 #elif defined(__native_client__)
221 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
222 // including accesses to the special files under /dev. C++11's
223 // std::random_device is instead exposed through a NaCl syscall.
224 # define _LIBCPP_USING_NACL_RANDOM
225 #elif defined(_LIBCPP_WIN32API)
226 # define _LIBCPP_USING_WIN32_RANDOM
228 # define _LIBCPP_USING_DEV_RANDOM
231 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
233 # if __BYTE_ORDER == __LITTLE_ENDIAN
234 # define _LIBCPP_LITTLE_ENDIAN 1
235 # define _LIBCPP_BIG_ENDIAN 0
236 # elif __BYTE_ORDER == __BIG_ENDIAN
237 # define _LIBCPP_LITTLE_ENDIAN 0
238 # define _LIBCPP_BIG_ENDIAN 1
239 # else // __BYTE_ORDER == __BIG_ENDIAN
240 # error unable to determine endian
242 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
244 #if __has_attribute(__no_sanitize__)
245 #define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
247 #define _LIBCPP_NO_CFI
250 #if defined(_LIBCPP_COMPILER_CLANG)
252 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
253 // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
254 #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
255 !defined(__arm__)) || \
256 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
257 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
260 #if __has_feature(cxx_alignas)
261 # define _ALIGNAS_TYPE(x) alignas(x)
262 # define _ALIGNAS(x) alignas(x)
264 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
265 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
268 #if __cplusplus < 201103L
269 typedef __char16_t char16_t;
270 typedef __char32_t char32_t;
273 #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
274 #define _LIBCPP_NO_EXCEPTIONS
277 #if !(__has_feature(cxx_rtti))
278 #define _LIBCPP_NO_RTTI
281 #if !(__has_feature(cxx_strong_enums))
282 #define _LIBCPP_HAS_NO_STRONG_ENUMS
285 #if !(__has_feature(cxx_decltype))
286 #define _LIBCPP_HAS_NO_DECLTYPE
289 #if __has_feature(cxx_attributes)
290 # define _LIBCPP_NORETURN [[noreturn]]
292 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
295 #if !(__has_feature(cxx_lambdas))
296 #define _LIBCPP_HAS_NO_LAMBDAS
299 #if !(__has_feature(cxx_nullptr))
300 # if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
301 # define nullptr __nullptr
303 # define _LIBCPP_HAS_NO_NULLPTR
307 #if !(__has_feature(cxx_rvalue_references))
308 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
311 #if !(__has_feature(cxx_auto_type))
312 #define _LIBCPP_HAS_NO_AUTO_TYPE
315 #if !(__has_feature(cxx_variadic_templates))
316 #define _LIBCPP_HAS_NO_VARIADICS
319 #if !(__has_feature(cxx_generalized_initializers))
320 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
323 #if __has_feature(is_base_of)
324 # define _LIBCPP_HAS_IS_BASE_OF
327 #if __has_feature(is_final)
328 # define _LIBCPP_HAS_IS_FINAL
331 // Objective-C++ features (opt-in)
332 #if __has_feature(objc_arc)
333 #define _LIBCPP_HAS_OBJC_ARC
336 #if __has_feature(objc_arc_weak)
337 #define _LIBCPP_HAS_OBJC_ARC_WEAK
338 #define _LIBCPP_HAS_NO_STRONG_ENUMS
341 #if !(__has_feature(cxx_constexpr))
342 #define _LIBCPP_HAS_NO_CONSTEXPR
345 #if !(__has_feature(cxx_relaxed_constexpr))
346 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
349 #if !(__has_feature(cxx_variable_templates))
350 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
353 #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
354 #if defined(__FreeBSD__)
355 #define _LIBCPP_HAS_QUICK_EXIT
356 #define _LIBCPP_HAS_C11_FEATURES
357 #elif defined(__Fuchsia__)
358 #define _LIBCPP_HAS_QUICK_EXIT
359 #define _LIBCPP_HAS_C11_FEATURES
360 #elif defined(__linux__)
361 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
362 #if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
363 #define _LIBCPP_HAS_QUICK_EXIT
365 #if __GLIBC_PREREQ(2, 17)
366 #define _LIBCPP_HAS_C11_FEATURES
368 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
369 #define _LIBCPP_HAS_QUICK_EXIT
370 #define _LIBCPP_HAS_C11_FEATURES
375 #if !(__has_feature(cxx_noexcept))
376 #define _LIBCPP_HAS_NO_NOEXCEPT
379 #if __has_feature(underlying_type)
380 # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
383 #if __has_feature(is_literal)
384 # define _LIBCPP_IS_LITERAL(T) __is_literal(T)
387 // Inline namespaces are available in Clang regardless of C++ dialect.
388 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
389 #define _LIBCPP_END_NAMESPACE_STD } }
390 #define _VSTD std::_LIBCPP_NAMESPACE
393 inline namespace _LIBCPP_NAMESPACE {
397 #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
398 #define _LIBCPP_HAS_NO_ASAN
401 // Allow for build-time disabling of unsigned integer sanitization
402 #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
403 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
406 // A constexpr version of __builtin_memcmp was added in clang 4.0
407 #if __has_builtin(__builtin_memcmp)
408 # ifdef __apple_build_version__
409 // No shipping version of Apple's clang has constexpr __builtin_memcmp
410 # elif __clang_major__ > 3
411 # define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR
415 #elif defined(_LIBCPP_COMPILER_GCC)
417 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
418 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
420 #define _LIBCPP_NORETURN __attribute__((noreturn))
423 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
424 #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
425 #define _LIBCPP_HAS_IS_FINAL
428 #if defined(__GNUC__) && _GNUC_VER >= 403
429 # define _LIBCPP_HAS_IS_BASE_OF
433 #define _LIBCPP_NO_EXCEPTIONS
436 // constexpr was added to GCC in 4.6.
438 #define _LIBCPP_HAS_NO_CONSTEXPR
439 // Can only use constexpr in c++11 mode.
440 #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
441 #define _LIBCPP_HAS_NO_CONSTEXPR
444 // Determine if GCC supports relaxed constexpr
445 #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
446 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
449 // GCC 5 will support variable templates
450 #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
451 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
454 #ifndef __GXX_EXPERIMENTAL_CXX0X__
455 #define _LIBCPP_HAS_NO_DECLTYPE
456 #define _LIBCPP_HAS_NO_NULLPTR
457 #define _LIBCPP_HAS_NO_UNICODE_CHARS
458 #define _LIBCPP_HAS_NO_VARIADICS
459 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
460 #define _LIBCPP_HAS_NO_STRONG_ENUMS
461 #define _LIBCPP_HAS_NO_NOEXCEPT
463 #else // __GXX_EXPERIMENTAL_CXX0X__
466 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
471 #define _LIBCPP_HAS_NO_DECLTYPE
472 #define _LIBCPP_HAS_NO_UNICODE_CHARS
473 #define _LIBCPP_HAS_NO_VARIADICS
474 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
475 #endif // _GNUC_VER < 404
478 #define _LIBCPP_HAS_NO_NOEXCEPT
479 #define _LIBCPP_HAS_NO_NULLPTR
482 #endif // __GXX_EXPERIMENTAL_CXX0X__
484 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
485 #define _LIBCPP_END_NAMESPACE_STD } }
486 #define _VSTD std::_LIBCPP_NAMESPACE
489 namespace _LIBCPP_NAMESPACE {
491 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
494 #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
495 #define _LIBCPP_HAS_NO_ASAN
498 #elif defined(_LIBCPP_COMPILER_MSVC)
500 #define _LIBCPP_TOSTRING2(x) #x
501 #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
502 #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
505 #error "MSVC versions prior to Visual Studio 2015 are not supported"
508 #define _LIBCPP_HAS_IS_BASE_OF
509 #define _LIBCPP_HAS_NO_CONSTEXPR
510 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
511 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
513 #define _LIBCPP_HAS_NO_UNICODE_CHARS
515 #define _LIBCPP_HAS_NO_NOEXCEPT
516 #define __alignof__ __alignof
517 #define _LIBCPP_NORETURN __declspec(noreturn)
518 #define _ALIGNAS(x) __declspec(align(x))
519 #define _LIBCPP_HAS_NO_VARIADICS
521 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
522 #define _LIBCPP_END_NAMESPACE_STD }
525 # define _LIBCPP_WEAK
529 #define _LIBCPP_HAS_NO_ASAN
531 #elif defined(_LIBCPP_COMPILER_IBM)
533 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
534 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
535 #define _ATTRIBUTE(x) __attribute__((x))
536 #define _LIBCPP_NORETURN __attribute__((noreturn))
538 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
539 #define _LIBCPP_HAS_NO_NOEXCEPT
540 #define _LIBCPP_HAS_NO_NULLPTR
541 #define _LIBCPP_HAS_NO_UNICODE_CHARS
542 #define _LIBCPP_HAS_IS_BASE_OF
543 #define _LIBCPP_HAS_IS_FINAL
544 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
547 #define __MULTILOCALE_API
550 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
551 #define _LIBCPP_END_NAMESPACE_STD } }
552 #define _VSTD std::_LIBCPP_NAMESPACE
555 inline namespace _LIBCPP_NAMESPACE {
559 #define _LIBCPP_HAS_NO_ASAN
561 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
564 #define _LIBCPP_OBJECT_FORMAT_ELF 1
565 #elif defined(__MACH__)
566 #define _LIBCPP_OBJECT_FORMAT_MACHO 1
568 #define _LIBCPP_OBJECT_FORMAT_COFF 1
571 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
572 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
573 # define _LIBCPP_DLL_VIS
574 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
575 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
576 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
577 #elif defined(_LIBCPP_BUILDING_LIBRARY)
578 # define _LIBCPP_DLL_VIS __declspec(dllexport)
579 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
580 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
581 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
583 # define _LIBCPP_DLL_VIS __declspec(dllimport)
584 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
585 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
586 # define _LIBCPP_OVERRIDABLE_FUNC_VIS
589 #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
590 #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
591 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
592 #define _LIBCPP_HIDDEN
593 #define _LIBCPP_TEMPLATE_VIS
594 #define _LIBCPP_FUNC_VIS_ONLY
595 #define _LIBCPP_ENUM_VIS
597 #if defined(_LIBCPP_COMPILER_MSVC)
598 # define _LIBCPP_INLINE_VISIBILITY __forceinline
599 # define _LIBCPP_ALWAYS_INLINE __forceinline
600 # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
602 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
603 # define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
604 # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
606 #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
608 #ifndef _LIBCPP_HIDDEN
609 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
610 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
612 #define _LIBCPP_HIDDEN
616 #ifndef _LIBCPP_FUNC_VIS
617 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
618 #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
620 #define _LIBCPP_FUNC_VIS
624 #ifndef _LIBCPP_TYPE_VIS
625 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
626 # if __has_attribute(__type_visibility__)
627 # define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
629 # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
632 # define _LIBCPP_TYPE_VIS
636 #ifndef _LIBCPP_TEMPLATE_VIS
637 # define _LIBCPP_TEMPLATE_VIS _LIBCPP_TYPE_VIS
640 #ifndef _LIBCPP_FUNC_VIS_ONLY
641 # define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
644 #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
645 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
648 #ifndef _LIBCPP_EXCEPTION_ABI
649 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
650 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
652 #define _LIBCPP_EXCEPTION_ABI
656 #ifndef _LIBCPP_ENUM_VIS
657 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
658 # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
660 # define _LIBCPP_ENUM_VIS
664 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
665 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
666 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
668 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
672 #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
673 # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
676 #ifndef _LIBCPP_INLINE_VISIBILITY
677 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
678 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
680 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
684 #ifndef _LIBCPP_ALWAYS_INLINE
685 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
686 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
688 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
692 #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
693 # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
694 # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
696 # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
700 #ifndef _LIBCPP_PREFERRED_OVERLOAD
701 # if __has_attribute(__enable_if__)
702 # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
706 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
707 # define _NOEXCEPT noexcept
708 # define _NOEXCEPT_(x) noexcept(x)
710 # define _NOEXCEPT throw()
711 # define _NOEXCEPT_(x)
714 #if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
715 # if !defined(_LIBCPP_DEBUG)
716 # error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
718 # define _NOEXCEPT_DEBUG noexcept(false)
719 # define _NOEXCEPT_DEBUG_(x) noexcept(false)
721 # define _NOEXCEPT_DEBUG _NOEXCEPT
722 # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
725 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
726 typedef unsigned short char16_t;
727 typedef unsigned int char32_t;
728 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
730 #ifndef __SIZEOF_INT128__
731 #define _LIBCPP_HAS_NO_INT128
734 #ifdef _LIBCPP_CXX03_LANG
735 # if __has_extension(c_static_assert)
736 # define static_assert(__b, __m) _Static_assert(__b, __m)
739 template <bool> struct __static_assert_test;
740 template <> struct __static_assert_test<true> {};
741 template <unsigned> struct __static_assert_check {};
743 #define static_assert(__b, __m) \
744 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
745 _LIBCPP_CONCAT(__t, __LINE__)
746 # endif // __has_extension(c_static_assert)
747 #endif // _LIBCPP_CXX03_LANG
749 #ifdef _LIBCPP_HAS_NO_DECLTYPE
750 // GCC 4.6 provides __decltype in all standard modes.
751 #if !__is_identifier(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
752 # define decltype(__x) __decltype(__x)
754 # define decltype(__x) __typeof__(__x)
758 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
759 #define _LIBCPP_CONSTEXPR
761 #define _LIBCPP_CONSTEXPR constexpr
764 #ifdef _LIBCPP_CXX03_LANG
765 #define _LIBCPP_DEFAULT {}
767 #define _LIBCPP_DEFAULT = default;
770 #ifdef _LIBCPP_CXX03_LANG
771 #define _LIBCPP_EQUAL_DELETE
773 #define _LIBCPP_EQUAL_DELETE = delete
777 #define _NOALIAS __attribute__((__malloc__))
782 #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
783 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
784 # define _LIBCPP_EXPLICIT explicit
786 # define _LIBCPP_EXPLICIT
789 #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
790 # define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
793 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
794 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
795 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
797 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
798 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
799 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
801 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
802 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
803 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
804 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
807 # if _LIBCPP_DEBUG == 0
808 # define _LIBCPP_DEBUG_LEVEL 1
809 # elif _LIBCPP_DEBUG == 1
810 # define _LIBCPP_DEBUG_LEVEL 2
812 # error Supported values for _LIBCPP_DEBUG are 0 and 1
814 # define _LIBCPP_EXTERN_TEMPLATE(...)
817 #ifndef _LIBCPP_EXTERN_TEMPLATE
818 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
821 #ifndef _LIBCPP_EXTERN_TEMPLATE2
822 #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
825 #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
826 #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
829 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
830 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
831 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
834 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
835 // Most unix variants have catopen. These are the specific ones that don't.
836 #if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
837 #define _LIBCPP_HAS_CATOPEN 1
842 #define _DECLARE_C99_LDBL_MATH 1
845 #if defined(__APPLE__)
846 # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
847 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
848 # define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
850 # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
851 # if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
852 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
855 #endif // defined(__APPLE__)
857 #if defined(__APPLE__) || defined(__FreeBSD__)
858 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
861 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
862 #define _LIBCPP_WCTYPE_IS_MASK
865 #ifndef _LIBCPP_STD_VER
866 # if __cplusplus <= 201103L
867 # define _LIBCPP_STD_VER 11
868 # elif __cplusplus <= 201402L
869 # define _LIBCPP_STD_VER 14
871 # define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
873 #endif // _LIBCPP_STD_VER
875 #if _LIBCPP_STD_VER > 11
876 #define _LIBCPP_DEPRECATED [[deprecated]]
878 #define _LIBCPP_DEPRECATED
881 #if _LIBCPP_STD_VER <= 11
882 #define _LIBCPP_EXPLICIT_AFTER_CXX11
883 #define _LIBCPP_DEPRECATED_AFTER_CXX11
885 #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
886 #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
889 #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
890 #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
892 #define _LIBCPP_CONSTEXPR_AFTER_CXX11
895 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
896 #define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
898 #define _LIBCPP_CONSTEXPR_AFTER_CXX14
901 // FIXME: Remove all usages of this macro once compilers catch up.
902 #if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L)
903 # define _LIBCPP_HAS_NO_INLINE_VARIABLES
906 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
907 # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
909 # define _LIBCPP_EXPLICIT_MOVE(x) (x)
912 #ifndef _LIBCPP_HAS_NO_ASAN
913 _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
914 const void *, const void *, const void *, const void *);
917 // Try to find out if RTTI is disabled.
918 // g++ and cl.exe have RTTI on by default and define a macro when it is.
919 // g++ only defines the macro in 4.3.2 and onwards.
920 #if !defined(_LIBCPP_NO_RTTI)
921 # if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
922 (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
923 # define _LIBCPP_NO_RTTI
924 # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
925 # define _LIBCPP_NO_RTTI
930 # define _LIBCPP_WEAK __attribute__((__weak__))
934 #if !defined(_LIBCPP_HAS_NO_THREADS) && \
935 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
936 # if defined(__FreeBSD__) || \
937 defined(__Fuchsia__) || \
938 defined(__NetBSD__) || \
939 defined(__linux__) || \
940 defined(__APPLE__) || \
941 defined(__CloudABI__) || \
943 # define _LIBCPP_HAS_THREAD_API_PTHREAD
944 # elif defined(_LIBCPP_WIN32API)
945 # define _LIBCPP_HAS_THREAD_API_WIN32
947 # error "No thread API"
948 # endif // _LIBCPP_HAS_THREAD_API
949 #endif // _LIBCPP_HAS_NO_THREADS
951 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
952 # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
953 _LIBCPP_HAS_NO_THREADS is not defined.
956 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
957 # error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
958 _LIBCPP_HAS_NO_THREADS is defined.
961 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
962 # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
963 _LIBCPP_HAS_NO_THREADS is defined.
966 // Systems that use capability-based security (FreeBSD with Capsicum,
967 // Nuxi CloudABI) may only provide local filesystem access (using *at()).
968 // Functions like open(), rename(), unlink() and stat() should not be
969 // used, as they attempt to access the global filesystem namespace.
971 #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
974 // CloudABI is intended for running networked services. Processes do not
975 // have standard input and output channels.
977 #define _LIBCPP_HAS_NO_STDIN
978 #define _LIBCPP_HAS_NO_STDOUT
981 #if defined(__BIONIC__) || defined(__CloudABI__) || \
982 defined(_LIBCPP_HAS_MUSL_LIBC)
983 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
986 // Thread-unsafe functions such as strtok() and localtime()
987 // are not available.
989 #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
992 #if __has_feature(cxx_atomic) || __has_extension(c_atomic)
993 #define _LIBCPP_HAS_C_ATOMIC_IMP
994 #elif _GNUC_VER > 407
995 #define _LIBCPP_HAS_GCC_ATOMIC_IMP
998 #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
999 || defined(_LIBCPP_HAS_NO_THREADS)
1000 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
1003 #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1004 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1007 #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
1008 && __has_attribute(acquire_capability))
1009 #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1012 #if __has_attribute(require_constant_initialization)
1013 #define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1015 #define _LIBCPP_SAFE_STATIC
1018 #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1019 #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1022 #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1023 #if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1024 #define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1028 #endif // __cplusplus
1030 #endif // _LIBCPP_CONFIG