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