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