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#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16#endif
17
18#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
19#pragma GCC system_header
20#endif
21
22#ifdef __cplusplus
23
24#ifdef __GNUC__
25#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
26#else
27#define _GNUC_VER 0
28#endif
29
30#define _LIBCPP_VERSION 4000
31
32#ifndef _LIBCPP_ABI_VERSION
33#define _LIBCPP_ABI_VERSION 1
34#endif
35
36#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
37// Change short string representation so that string data starts at offset 0,
38// improving its alignment in some cases.
39#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
40// Fix deque iterator type in order to support incomplete types.
41#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
42// Fix undefined behavior in how std::list stores it's linked nodes.
43#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
44// Fix undefined behavior in  how __tree stores its end and parent nodes.
45#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
46// Fix undefined behavior in how __hash_table stores it's pointer types
47#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
48#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
49#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
50#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
51// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
52// provided under the alternate keyword __nullptr, which changes the mangling
53// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
54#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
55// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
56// instead of as a class simulating an enum. If this option is enabled
57// `pointer_safety` and `get_pointer_safety()` will no longer be available
58// in C++03.
59#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
60#elif _LIBCPP_ABI_VERSION == 1
61#if !defined(_WIN32)
62// Enable compiling a definition of error_category() into the libc++ dylib.
63#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
64#endif
65// Feature macros for disabling pre ABI v1 features. All of these options
66// are deprecated.
67#if defined(__FreeBSD__)
68#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
69#endif
70#endif
71
72#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
73#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
74       use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
75#endif
76
77#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
78#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
79
80#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
81
82#if __cplusplus < 201103L
83#define _LIBCPP_CXX03_LANG
84#endif
85
86#ifndef __has_attribute
87#define __has_attribute(__x) 0
88#endif
89#ifndef __has_builtin
90#define __has_builtin(__x) 0
91#endif
92#ifndef __has_extension
93#define __has_extension(__x) 0
94#endif
95#ifndef __has_feature
96#define __has_feature(__x) 0
97#endif
98// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
99// the compiler and '1' otherwise.
100#ifndef __is_identifier
101#define __is_identifier(__x) 1
102#endif
103
104#if defined(__clang__)
105#define _LIBCPP_COMPILER_CLANG
106#elif defined(__GNUC__)
107#define _LIBCPP_COMPILER_GCC
108#elif defined(_MSC_VER)
109#define _LIBCPP_COMPILER_MSVC
110#elif defined(__IBMCPP__)
111#define _LIBCPP_COMPILER_IBM
112#endif
113
114// FIXME: ABI detection should be done via compiler builtin macros. This
115// is just a placeholder until Clang implements such macros. For now assume
116// that Windows compilers pretending to be MSVC++ target the microsoft ABI.
117#if defined(_WIN32) && defined(_MSC_VER)
118# define _LIBCPP_ABI_MICROSOFT
119#else
120# define _LIBCPP_ABI_ITANIUM
121#endif
122
123// Need to detect which libc we're using if we're on Linux.
124#if defined(__linux__)
125#include <features.h>
126#if !defined(__GLIBC_PREREQ)
127#define __GLIBC_PREREQ(a, b) 0
128#endif // !defined(__GLIBC_PREREQ)
129#endif // defined(__linux__)
130
131#ifdef __LITTLE_ENDIAN__
132#if __LITTLE_ENDIAN__
133#define _LIBCPP_LITTLE_ENDIAN 1
134#define _LIBCPP_BIG_ENDIAN    0
135#endif  // __LITTLE_ENDIAN__
136#endif  // __LITTLE_ENDIAN__
137
138#ifdef __BIG_ENDIAN__
139#if __BIG_ENDIAN__
140#define _LIBCPP_LITTLE_ENDIAN 0
141#define _LIBCPP_BIG_ENDIAN    1
142#endif  // __BIG_ENDIAN__
143#endif  // __BIG_ENDIAN__
144
145#ifdef __BYTE_ORDER__
146#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
147#define _LIBCPP_LITTLE_ENDIAN 1
148#define _LIBCPP_BIG_ENDIAN 0
149#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
150#define _LIBCPP_LITTLE_ENDIAN 0
151#define _LIBCPP_BIG_ENDIAN 1
152#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
153#endif // __BYTE_ORDER__
154
155#ifdef __FreeBSD__
156# include <sys/endian.h>
157#  if _BYTE_ORDER == _LITTLE_ENDIAN
158#   define _LIBCPP_LITTLE_ENDIAN 1
159#   define _LIBCPP_BIG_ENDIAN    0
160# else  // _BYTE_ORDER == _LITTLE_ENDIAN
161#   define _LIBCPP_LITTLE_ENDIAN 0
162#   define _LIBCPP_BIG_ENDIAN    1
163# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
164# ifndef __LONG_LONG_SUPPORTED
165#  define _LIBCPP_HAS_NO_LONG_LONG
166# endif  // __LONG_LONG_SUPPORTED
167#endif  // __FreeBSD__
168
169#ifdef __NetBSD__
170# include <sys/endian.h>
171#  if _BYTE_ORDER == _LITTLE_ENDIAN
172#   define _LIBCPP_LITTLE_ENDIAN 1
173#   define _LIBCPP_BIG_ENDIAN    0
174# else  // _BYTE_ORDER == _LITTLE_ENDIAN
175#   define _LIBCPP_LITTLE_ENDIAN 0
176#   define _LIBCPP_BIG_ENDIAN    1
177# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
178# define _LIBCPP_HAS_QUICK_EXIT
179#endif  // __NetBSD__
180
181#if defined(_WIN32)
182#  define _LIBCPP_WIN32API      1
183#  define _LIBCPP_LITTLE_ENDIAN 1
184#  define _LIBCPP_BIG_ENDIAN    0
185#  define _LIBCPP_SHORT_WCHAR   1
186
187// If mingw not explicitly detected, assume using MS C runtime only.
188#  ifndef __MINGW32__
189#    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
190#  endif
191#  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
192#    define _LIBCPP_HAS_BITSCAN64
193#  endif
194#endif // defined(_WIN32)
195
196#ifdef __sun__
197# include <sys/isa_defs.h>
198# ifdef _LITTLE_ENDIAN
199#   define _LIBCPP_LITTLE_ENDIAN 1
200#   define _LIBCPP_BIG_ENDIAN    0
201# else
202#   define _LIBCPP_LITTLE_ENDIAN 0
203#   define _LIBCPP_BIG_ENDIAN    1
204# endif
205#endif // __sun__
206
207#if defined(__CloudABI__)
208  // Certain architectures provide arc4random(). Prefer using
209  // arc4random() over /dev/{u,}random to make it possible to obtain
210  // random data even when using sandboxing mechanisms such as chroots,
211  // Capsicum, etc.
212# define _LIBCPP_USING_ARC4_RANDOM
213#elif defined(__native_client__)
214  // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
215  // including accesses to the special files under /dev. C++11's
216  // std::random_device is instead exposed through a NaCl syscall.
217# define _LIBCPP_USING_NACL_RANDOM
218#elif defined(_LIBCPP_WIN32API)
219# define _LIBCPP_USING_WIN32_RANDOM
220#else
221# define _LIBCPP_USING_DEV_RANDOM
222#endif
223
224#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
225# include <endian.h>
226# if __BYTE_ORDER == __LITTLE_ENDIAN
227#  define _LIBCPP_LITTLE_ENDIAN 1
228#  define _LIBCPP_BIG_ENDIAN    0
229# elif __BYTE_ORDER == __BIG_ENDIAN
230#  define _LIBCPP_LITTLE_ENDIAN 0
231#  define _LIBCPP_BIG_ENDIAN    1
232# else  // __BYTE_ORDER == __BIG_ENDIAN
233#  error unable to determine endian
234# endif
235#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
236
237#if __has_attribute(__no_sanitize__)
238#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
239#else
240#define _LIBCPP_NO_CFI
241#endif
242
243#if defined(_LIBCPP_COMPILER_CLANG)
244
245// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
246// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
247#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
248     !defined(__arm__)) ||                                                     \
249    defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
250#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
251#endif
252
253#if __has_feature(cxx_alignas)
254#  define _ALIGNAS_TYPE(x) alignas(x)
255#  define _ALIGNAS(x) alignas(x)
256#else
257#  define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
258#  define _ALIGNAS(x) __attribute__((__aligned__(x)))
259#endif
260
261#if __cplusplus < 201103L
262typedef __char16_t char16_t;
263typedef __char32_t char32_t;
264#endif
265
266#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
267#define _LIBCPP_NO_EXCEPTIONS
268#endif
269
270#if !(__has_feature(cxx_rtti))
271#define _LIBCPP_NO_RTTI
272#endif
273
274#if !(__has_feature(cxx_strong_enums))
275#define _LIBCPP_HAS_NO_STRONG_ENUMS
276#endif
277
278#if !(__has_feature(cxx_decltype))
279#define _LIBCPP_HAS_NO_DECLTYPE
280#endif
281
282#if __has_feature(cxx_attributes)
283#  define _LIBCPP_NORETURN [[noreturn]]
284#else
285#  define _LIBCPP_NORETURN __attribute__ ((noreturn))
286#endif
287
288#if !(__has_feature(cxx_lambdas))
289#define _LIBCPP_HAS_NO_LAMBDAS
290#endif
291
292#if !(__has_feature(cxx_nullptr))
293# if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
294#   define nullptr __nullptr
295# else
296#   define _LIBCPP_HAS_NO_NULLPTR
297# endif
298#endif
299
300#if !(__has_feature(cxx_rvalue_references))
301#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
302#endif
303
304#if !(__has_feature(cxx_auto_type))
305#define _LIBCPP_HAS_NO_AUTO_TYPE
306#endif
307
308#if !(__has_feature(cxx_variadic_templates))
309#define _LIBCPP_HAS_NO_VARIADICS
310#endif
311
312#if !(__has_feature(cxx_generalized_initializers))
313#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
314#endif
315
316#if __has_feature(is_base_of)
317#  define _LIBCPP_HAS_IS_BASE_OF
318#endif
319
320#if __has_feature(is_final)
321#  define _LIBCPP_HAS_IS_FINAL
322#endif
323
324// Objective-C++ features (opt-in)
325#if __has_feature(objc_arc)
326#define _LIBCPP_HAS_OBJC_ARC
327#endif
328
329#if __has_feature(objc_arc_weak)
330#define _LIBCPP_HAS_OBJC_ARC_WEAK
331#define _LIBCPP_HAS_NO_STRONG_ENUMS
332#endif
333
334#if !(__has_feature(cxx_constexpr))
335#define _LIBCPP_HAS_NO_CONSTEXPR
336#endif
337
338#if !(__has_feature(cxx_relaxed_constexpr))
339#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
340#endif
341
342#if !(__has_feature(cxx_variable_templates))
343#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
344#endif
345
346#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
347#if defined(__FreeBSD__)
348#define _LIBCPP_HAS_QUICK_EXIT
349#define _LIBCPP_HAS_C11_FEATURES
350#elif defined(__Fuchsia__)
351#define _LIBCPP_HAS_QUICK_EXIT
352#define _LIBCPP_HAS_C11_FEATURES
353#elif defined(__linux__)
354#if !defined(_LIBCPP_HAS_MUSL_LIBC)
355#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
356#define _LIBCPP_HAS_QUICK_EXIT
357#endif
358#if __GLIBC_PREREQ(2, 17)
359#define _LIBCPP_HAS_C11_FEATURES
360#endif
361#else // defined(_LIBCPP_HAS_MUSL_LIBC)
362#define _LIBCPP_HAS_QUICK_EXIT
363#define _LIBCPP_HAS_C11_FEATURES
364#endif
365#endif // __linux__
366#endif
367
368#if !(__has_feature(cxx_noexcept))
369#define _LIBCPP_HAS_NO_NOEXCEPT
370#endif
371
372#if __has_feature(underlying_type)
373#  define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
374#endif
375
376#if __has_feature(is_literal)
377#  define _LIBCPP_IS_LITERAL(T) __is_literal(T)
378#endif
379
380// Inline namespaces are available in Clang regardless of C++ dialect.
381#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
382#define _LIBCPP_END_NAMESPACE_STD  } }
383#define _VSTD std::_LIBCPP_NAMESPACE
384
385namespace std {
386  inline namespace _LIBCPP_NAMESPACE {
387  }
388}
389
390#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
391#define _LIBCPP_HAS_NO_ASAN
392#endif
393
394// Allow for build-time disabling of unsigned integer sanitization
395#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
396#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
397#endif
398
399// A constexpr version of __builtin_memcmp was added in clang 4.0
400#if __has_builtin(__builtin_memcmp)
401# ifdef __apple_build_version__
402// No shipping version of Apple's clang has constexpr __builtin_memcmp
403# elif __clang_major__ > 3
404#  define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR
405# endif
406#endif
407
408#elif defined(_LIBCPP_COMPILER_GCC)
409
410#define _ALIGNAS(x) __attribute__((__aligned__(x)))
411#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
412
413#define _LIBCPP_NORETURN __attribute__((noreturn))
414
415#if _GNUC_VER >= 407
416#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
417#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
418#define _LIBCPP_HAS_IS_FINAL
419#endif
420
421#if defined(__GNUC__) && _GNUC_VER >= 403
422#  define _LIBCPP_HAS_IS_BASE_OF
423#endif
424
425#if !__EXCEPTIONS
426#define _LIBCPP_NO_EXCEPTIONS
427#endif
428
429// constexpr was added to GCC in 4.6.
430#if _GNUC_VER < 406
431#define _LIBCPP_HAS_NO_CONSTEXPR
432// Can only use constexpr in c++11 mode.
433#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
434#define _LIBCPP_HAS_NO_CONSTEXPR
435#endif
436
437// Determine if GCC supports relaxed constexpr
438#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
439#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
440#endif
441
442// GCC 5 will support variable templates
443#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
444#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
445#endif
446
447#ifndef __GXX_EXPERIMENTAL_CXX0X__
448#define _LIBCPP_HAS_NO_DECLTYPE
449#define _LIBCPP_HAS_NO_NULLPTR
450#define _LIBCPP_HAS_NO_UNICODE_CHARS
451#define _LIBCPP_HAS_NO_VARIADICS
452#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
453#define _LIBCPP_HAS_NO_STRONG_ENUMS
454#define _LIBCPP_HAS_NO_NOEXCEPT
455
456#else  // __GXX_EXPERIMENTAL_CXX0X__
457
458#if _GNUC_VER < 403
459#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
460#endif
461
462
463#if _GNUC_VER < 404
464#define _LIBCPP_HAS_NO_DECLTYPE
465#define _LIBCPP_HAS_NO_UNICODE_CHARS
466#define _LIBCPP_HAS_NO_VARIADICS
467#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
468#endif  // _GNUC_VER < 404
469
470#if _GNUC_VER < 406
471#define _LIBCPP_HAS_NO_NOEXCEPT
472#define _LIBCPP_HAS_NO_NULLPTR
473#endif
474
475#endif  // __GXX_EXPERIMENTAL_CXX0X__
476
477#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
478#define _LIBCPP_END_NAMESPACE_STD  } }
479#define _VSTD std::_LIBCPP_NAMESPACE
480
481namespace std {
482namespace _LIBCPP_NAMESPACE {
483}
484using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
485}
486
487#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
488#define _LIBCPP_HAS_NO_ASAN
489#endif
490
491#elif defined(_LIBCPP_COMPILER_MSVC)
492
493#define _LIBCPP_TOSTRING2(x) #x
494#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
495#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
496
497#if _MSC_VER < 1900
498#error "MSVC versions prior to Visual Studio 2015 are not supported"
499#endif
500
501#define _LIBCPP_HAS_IS_BASE_OF
502#define _LIBCPP_HAS_NO_CONSTEXPR
503#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
504#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
505#if _MSC_VER <= 1800
506#define _LIBCPP_HAS_NO_UNICODE_CHARS
507#endif
508#define _LIBCPP_HAS_NO_NOEXCEPT
509#define __alignof__ __alignof
510#define _LIBCPP_NORETURN __declspec(noreturn)
511#define _ALIGNAS(x) __declspec(align(x))
512#define _LIBCPP_HAS_NO_VARIADICS
513
514#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
515#define _LIBCPP_END_NAMESPACE_STD  }
516#define _VSTD std
517
518#  define _LIBCPP_WEAK
519namespace std {
520}
521
522#define _LIBCPP_HAS_NO_ASAN
523
524#elif defined(_LIBCPP_COMPILER_IBM)
525
526#define _ALIGNAS(x) __attribute__((__aligned__(x)))
527#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
528#define _ATTRIBUTE(x) __attribute__((x))
529#define _LIBCPP_NORETURN __attribute__((noreturn))
530
531#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
532#define _LIBCPP_HAS_NO_NOEXCEPT
533#define _LIBCPP_HAS_NO_NULLPTR
534#define _LIBCPP_HAS_NO_UNICODE_CHARS
535#define _LIBCPP_HAS_IS_BASE_OF
536#define _LIBCPP_HAS_IS_FINAL
537#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
538
539#if defined(_AIX)
540#define __MULTILOCALE_API
541#endif
542
543#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
544#define _LIBCPP_END_NAMESPACE_STD  } }
545#define _VSTD std::_LIBCPP_NAMESPACE
546
547namespace std {
548  inline namespace _LIBCPP_NAMESPACE {
549  }
550}
551
552#define _LIBCPP_HAS_NO_ASAN
553
554#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
555
556#if defined(__ELF__)
557#define _LIBCPP_OBJECT_FORMAT_ELF   1
558#elif defined(__MACH__)
559#define _LIBCPP_OBJECT_FORMAT_MACHO 1
560#else
561#define _LIBCPP_OBJECT_FORMAT_COFF  1
562#endif
563
564#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
565#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
566# define _LIBCPP_DLL_VIS
567# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
568# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
569# define _LIBCPP_OVERRIDABLE_FUNC_VIS
570#elif defined(_LIBCPP_BUILDING_LIBRARY)
571# define _LIBCPP_DLL_VIS __declspec(dllexport)
572# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
573# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
574# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
575#else
576# define _LIBCPP_DLL_VIS __declspec(dllimport)
577# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
578# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
579# define _LIBCPP_OVERRIDABLE_FUNC_VIS
580#endif
581
582#define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
583#define _LIBCPP_FUNC_VIS            _LIBCPP_DLL_VIS
584#define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
585#define _LIBCPP_HIDDEN
586#define _LIBCPP_TEMPLATE_VIS
587#define _LIBCPP_FUNC_VIS_ONLY
588#define _LIBCPP_ENUM_VIS
589
590#if defined(_LIBCPP_COMPILER_MSVC)
591# define _LIBCPP_INLINE_VISIBILITY __forceinline
592# define _LIBCPP_ALWAYS_INLINE     __forceinline
593# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
594#else
595# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
596# define _LIBCPP_ALWAYS_INLINE     __attribute__ ((__always_inline__))
597# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
598#endif
599#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
600
601#ifndef _LIBCPP_HIDDEN
602#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
603#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
604#else
605#define _LIBCPP_HIDDEN
606#endif
607#endif
608
609#ifndef _LIBCPP_FUNC_VIS
610#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
611#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
612#else
613#define _LIBCPP_FUNC_VIS
614#endif
615#endif
616
617#ifndef _LIBCPP_TYPE_VIS
618#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
619#    if __has_attribute(__type_visibility__)
620#      define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
621#    else
622#      define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
623#    endif
624#  else
625#    define _LIBCPP_TYPE_VIS
626#  endif
627#endif
628
629#ifndef _LIBCPP_TEMPLATE_VIS
630# define _LIBCPP_TEMPLATE_VIS _LIBCPP_TYPE_VIS
631#endif
632
633#ifndef _LIBCPP_FUNC_VIS_ONLY
634# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
635#endif
636
637#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
638# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
639#endif
640
641#ifndef _LIBCPP_EXCEPTION_ABI
642#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
643#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
644#else
645#define _LIBCPP_EXCEPTION_ABI
646#endif
647#endif
648
649#ifndef _LIBCPP_ENUM_VIS
650#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
651#    define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
652#  else
653#    define _LIBCPP_ENUM_VIS
654#  endif
655#endif
656
657#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
658#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
659#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
660#  else
661#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
662#  endif
663#endif
664
665#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
666#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
667#endif
668
669#ifndef _LIBCPP_INLINE_VISIBILITY
670#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
671#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
672#else
673#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
674#endif
675#endif
676
677#ifndef _LIBCPP_ALWAYS_INLINE
678#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
679#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
680#else
681#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__always_inline__))
682#endif
683#endif
684
685#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
686# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
687#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
688# else
689#  define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
690# endif
691#endif
692
693#ifndef _LIBCPP_PREFERRED_OVERLOAD
694#  if __has_attribute(__enable_if__)
695#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
696#  endif
697#endif
698
699#ifndef _LIBCPP_HAS_NO_NOEXCEPT
700#  define _NOEXCEPT noexcept
701#  define _NOEXCEPT_(x) noexcept(x)
702#else
703#  define _NOEXCEPT throw()
704#  define _NOEXCEPT_(x)
705#endif
706
707#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
708# if !defined(_LIBCPP_DEBUG)
709#   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
710# endif
711# define _NOEXCEPT_DEBUG noexcept(false)
712# define _NOEXCEPT_DEBUG_(x) noexcept(false)
713#else
714# define _NOEXCEPT_DEBUG _NOEXCEPT
715# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
716#endif
717
718#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
719typedef unsigned short char16_t;
720typedef unsigned int   char32_t;
721#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
722
723#ifndef __SIZEOF_INT128__
724#define _LIBCPP_HAS_NO_INT128
725#endif
726
727#ifdef _LIBCPP_CXX03_LANG
728# if __has_extension(c_static_assert)
729#   define static_assert(__b, __m) _Static_assert(__b, __m)
730# else
731extern "C++" {
732template <bool> struct __static_assert_test;
733template <> struct __static_assert_test<true> {};
734template <unsigned> struct __static_assert_check {};
735}
736#define static_assert(__b, __m) \
737    typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
738    _LIBCPP_CONCAT(__t, __LINE__)
739# endif // __has_extension(c_static_assert)
740#endif  // _LIBCPP_CXX03_LANG
741
742#ifdef _LIBCPP_HAS_NO_DECLTYPE
743// GCC 4.6 provides __decltype in all standard modes.
744#if !__is_identifier(__decltype) || _GNUC_VER >= 406
745#  define decltype(__x) __decltype(__x)
746#else
747#  define decltype(__x) __typeof__(__x)
748#endif
749#endif
750
751#ifdef _LIBCPP_HAS_NO_CONSTEXPR
752#define _LIBCPP_CONSTEXPR
753#else
754#define _LIBCPP_CONSTEXPR constexpr
755#endif
756
757#ifdef _LIBCPP_CXX03_LANG
758#define _LIBCPP_DEFAULT {}
759#else
760#define _LIBCPP_DEFAULT = default;
761#endif
762
763#ifdef _LIBCPP_CXX03_LANG
764#define _LIBCPP_EQUAL_DELETE
765#else
766#define _LIBCPP_EQUAL_DELETE = delete
767#endif
768
769#ifdef __GNUC__
770#define _NOALIAS __attribute__((__malloc__))
771#else
772#define _NOALIAS
773#endif
774
775#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
776    (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
777#   define _LIBCPP_EXPLICIT explicit
778#else
779#   define _LIBCPP_EXPLICIT
780#endif
781
782#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
783#   define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
784#endif
785
786#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
787#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
788#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
789    __lx __v_; \
790    _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
791    _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
792    _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
793    };
794#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
795#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
796#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
797#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
798
799#ifdef _LIBCPP_DEBUG
800#   if _LIBCPP_DEBUG == 0
801#       define _LIBCPP_DEBUG_LEVEL 1
802#   elif _LIBCPP_DEBUG == 1
803#       define _LIBCPP_DEBUG_LEVEL 2
804#   else
805#       error Supported values for _LIBCPP_DEBUG are 0 and 1
806#   endif
807#   define _LIBCPP_EXTERN_TEMPLATE(...)
808#endif
809
810#ifndef _LIBCPP_EXTERN_TEMPLATE
811#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
812#endif
813
814#ifndef _LIBCPP_EXTERN_TEMPLATE2
815#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
816#endif
817
818#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
819#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
820#endif
821
822#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) ||   \
823    defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
824#define _LIBCPP_LOCALE__L_EXTENSIONS 1
825#endif
826
827#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
828// Most unix variants have catopen.  These are the specific ones that don't.
829#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
830#define _LIBCPP_HAS_CATOPEN 1
831#endif
832#endif
833
834#ifdef __FreeBSD__
835#define _DECLARE_C99_LDBL_MATH 1
836#endif
837
838#if defined(__APPLE__) || defined(__FreeBSD__)
839#define _LIBCPP_HAS_DEFAULTRUNELOCALE
840#endif
841
842#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
843#define _LIBCPP_WCTYPE_IS_MASK
844#endif
845
846#ifndef _LIBCPP_STD_VER
847#  if  __cplusplus <= 201103L
848#    define _LIBCPP_STD_VER 11
849#  elif __cplusplus <= 201402L
850#    define _LIBCPP_STD_VER 14
851#  else
852#    define _LIBCPP_STD_VER 16  // current year, or date of c++17 ratification
853#  endif
854#endif  // _LIBCPP_STD_VER
855
856#if _LIBCPP_STD_VER > 11
857#define _LIBCPP_DEPRECATED [[deprecated]]
858#else
859#define _LIBCPP_DEPRECATED
860#endif
861
862#if _LIBCPP_STD_VER <= 11
863#define _LIBCPP_EXPLICIT_AFTER_CXX11
864#define _LIBCPP_DEPRECATED_AFTER_CXX11
865#else
866#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
867#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
868#endif
869
870#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
871#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
872#else
873#define _LIBCPP_CONSTEXPR_AFTER_CXX11
874#endif
875
876#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
877#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
878#else
879#define _LIBCPP_CONSTEXPR_AFTER_CXX14
880#endif
881
882// FIXME: Remove all usages of this macro once compilers catch up.
883#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L)
884# define _LIBCPP_HAS_NO_INLINE_VARIABLES
885#endif
886
887#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
888#  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
889#else
890#  define _LIBCPP_EXPLICIT_MOVE(x) (x)
891#endif
892
893#ifndef _LIBCPP_HAS_NO_ASAN
894_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
895  const void *, const void *, const void *, const void *);
896#endif
897
898// Try to find out if RTTI is disabled.
899// g++ and cl.exe have RTTI on by default and define a macro when it is.
900// g++ only defines the macro in 4.3.2 and onwards.
901#if !defined(_LIBCPP_NO_RTTI)
902#  if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
903   (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
904#    define _LIBCPP_NO_RTTI
905#  elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
906#    define _LIBCPP_NO_RTTI
907#  endif
908#endif
909
910#ifndef _LIBCPP_WEAK
911#  define _LIBCPP_WEAK __attribute__((__weak__))
912#endif
913
914// Thread API
915#if !defined(_LIBCPP_HAS_NO_THREADS) && \
916    !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
917# if defined(__FreeBSD__) || \
918    defined(__Fuchsia__) || \
919    defined(__NetBSD__) || \
920    defined(__linux__) || \
921    defined(__APPLE__) || \
922    defined(__CloudABI__) || \
923    defined(__sun__)
924#   define _LIBCPP_HAS_THREAD_API_PTHREAD
925# elif defined(_LIBCPP_WIN32API)
926#  define _LIBCPP_HAS_THREAD_API_WIN32
927# else
928#  error "No thread API"
929# endif // _LIBCPP_HAS_THREAD_API
930#endif // _LIBCPP_HAS_NO_THREADS
931
932#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
933#  error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
934         _LIBCPP_HAS_NO_THREADS is not defined.
935#endif
936
937#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
938#  error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
939         _LIBCPP_HAS_NO_THREADS is defined.
940#endif
941
942#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
943#  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
944         _LIBCPP_HAS_NO_THREADS is defined.
945#endif
946
947// Systems that use capability-based security (FreeBSD with Capsicum,
948// Nuxi CloudABI) may only provide local filesystem access (using *at()).
949// Functions like open(), rename(), unlink() and stat() should not be
950// used, as they attempt to access the global filesystem namespace.
951#ifdef __CloudABI__
952#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
953#endif
954
955// CloudABI is intended for running networked services. Processes do not
956// have standard input and output channels.
957#ifdef __CloudABI__
958#define _LIBCPP_HAS_NO_STDIN
959#define _LIBCPP_HAS_NO_STDOUT
960#endif
961
962#if defined(__BIONIC__) || defined(__CloudABI__) ||                            \
963    defined(_LIBCPP_HAS_MUSL_LIBC)
964#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
965#endif
966
967// Thread-unsafe functions such as strtok() and localtime()
968// are not available.
969#ifdef __CloudABI__
970#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
971#endif
972
973#if __has_feature(cxx_atomic) || __has_extension(c_atomic)
974#define _LIBCPP_HAS_C_ATOMIC_IMP
975#elif _GNUC_VER > 407
976#define _LIBCPP_HAS_GCC_ATOMIC_IMP
977#endif
978
979#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
980     || defined(_LIBCPP_HAS_NO_THREADS)
981#define _LIBCPP_HAS_NO_ATOMIC_HEADER
982#endif
983
984#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
985#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
986#endif
987
988#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
989      && __has_attribute(acquire_capability))
990#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
991#endif
992
993#if __has_attribute(require_constant_initialization)
994#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
995#else
996#define _LIBCPP_SAFE_STATIC
997#endif
998
999#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1000#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1001#endif
1002
1003#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1004#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1005#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1006#endif
1007#endif
1008
1009#endif // __cplusplus
1010
1011#endif // _LIBCPP_CONFIG
1012