17a984708SDavid Chisnall// -*- C++ -*-
27a984708SDavid Chisnall//===--------------------------- __config ---------------------------------===//
37a984708SDavid Chisnall//
47a984708SDavid Chisnall//                     The LLVM Compiler Infrastructure
57a984708SDavid Chisnall//
67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open
77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details.
87a984708SDavid Chisnall//
97a984708SDavid Chisnall//===----------------------------------------------------------------------===//
107a984708SDavid Chisnall
117a984708SDavid Chisnall#ifndef _LIBCPP_CONFIG
127a984708SDavid Chisnall#define _LIBCPP_CONFIG
137a984708SDavid Chisnall
149729cf09SDimitry Andric#if defined(_MSC_VER) && !defined(__clang__)
15540d2a8bSDimitry Andric#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
169729cf09SDimitry Andric#    define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
179729cf09SDimitry Andric#  endif
18540d2a8bSDimitry Andric#endif
199729cf09SDimitry Andric
209729cf09SDimitry Andric#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
217a984708SDavid Chisnall#pragma GCC system_header
227a984708SDavid Chisnall#endif
237a984708SDavid Chisnall
249729cf09SDimitry Andric#ifdef __cplusplus
259729cf09SDimitry Andric
26936e9439SDimitry Andric#ifdef __GNUC__
27936e9439SDimitry Andric#  define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
28540d2a8bSDimitry Andric// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
29540d2a8bSDimitry Andric// introduced in GCC 5.0.
30540d2a8bSDimitry Andric#  define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
31854fa44bSDimitry Andric#else
32854fa44bSDimitry Andric#  define _GNUC_VER 0
33540d2a8bSDimitry Andric#  define _GNUC_VER_NEW 0
34936e9439SDimitry Andric#endif
35936e9439SDimitry Andric
36*b5893f02SDimitry Andric#define _LIBCPP_VERSION 8000
377a984708SDavid Chisnall
389729cf09SDimitry Andric#ifndef _LIBCPP_ABI_VERSION
397a984708SDavid Chisnall#  define _LIBCPP_ABI_VERSION 1
409729cf09SDimitry Andric#endif
414ba319b5SDimitry Andric
424ba319b5SDimitry Andric#ifndef _LIBCPP_STD_VER
434ba319b5SDimitry Andric#  if  __cplusplus <= 201103L
444ba319b5SDimitry Andric#    define _LIBCPP_STD_VER 11
454ba319b5SDimitry Andric#  elif __cplusplus <= 201402L
464ba319b5SDimitry Andric#    define _LIBCPP_STD_VER 14
474ba319b5SDimitry Andric#  elif __cplusplus <= 201703L
484ba319b5SDimitry Andric#    define _LIBCPP_STD_VER 17
494ba319b5SDimitry Andric#  else
504ba319b5SDimitry Andric#    define _LIBCPP_STD_VER 18  // current year, or date of c++2a ratification
514ba319b5SDimitry Andric#  endif
524ba319b5SDimitry Andric#endif  // _LIBCPP_STD_VER
539729cf09SDimitry Andric
54540d2a8bSDimitry Andric#if defined(__ELF__)
55540d2a8bSDimitry Andric#  define _LIBCPP_OBJECT_FORMAT_ELF   1
56540d2a8bSDimitry Andric#elif defined(__MACH__)
57540d2a8bSDimitry Andric#  define _LIBCPP_OBJECT_FORMAT_MACHO 1
58540d2a8bSDimitry Andric#elif defined(_WIN32)
59540d2a8bSDimitry Andric#  define _LIBCPP_OBJECT_FORMAT_COFF  1
60b2c7081bSDimitry Andric#elif defined(__wasm__)
61b2c7081bSDimitry Andric#  define _LIBCPP_OBJECT_FORMAT_WASM  1
62540d2a8bSDimitry Andric#else
63540d2a8bSDimitry Andric#  error Unknown object file format
64540d2a8bSDimitry Andric#endif
65540d2a8bSDimitry Andric
669729cf09SDimitry Andric#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
67aed8d94eSDimitry Andric// Change short string representation so that string data starts at offset 0,
689729cf09SDimitry Andric// improving its alignment in some cases.
699729cf09SDimitry Andric#  define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
709729cf09SDimitry Andric// Fix deque iterator type in order to support incomplete types.
719729cf09SDimitry Andric#  define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
72b2c7081bSDimitry Andric// Fix undefined behavior in how std::list stores its linked nodes.
739729cf09SDimitry Andric#  define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
747c82a1ecSDimitry Andric// Fix undefined behavior in  how __tree stores its end and parent nodes.
757c82a1ecSDimitry Andric#  define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
76b2c7081bSDimitry Andric// Fix undefined behavior in how __hash_table stores its pointer types.
77aed8d94eSDimitry Andric#  define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
787c82a1ecSDimitry Andric#  define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
797c82a1ecSDimitry Andric#  define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
80aed8d94eSDimitry Andric// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
81aed8d94eSDimitry Andric// provided under the alternate keyword __nullptr, which changes the mangling
82aed8d94eSDimitry Andric// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
83aed8d94eSDimitry Andric#  define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
84aed8d94eSDimitry Andric// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
85aed8d94eSDimitry Andric// instead of as a class simulating an enum. If this option is enabled
86aed8d94eSDimitry Andric// `pointer_safety` and `get_pointer_safety()` will no longer be available
87aed8d94eSDimitry Andric// in C++03.
88aed8d94eSDimitry Andric#  define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
89540d2a8bSDimitry Andric// Define a key function for `bad_function_call` in the library, to centralize
90540d2a8bSDimitry Andric// its vtable and typeinfo to libc++ rather than having all other libraries
91540d2a8bSDimitry Andric// using that class define their own copies.
92540d2a8bSDimitry Andric#  define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
9324d58133SDimitry Andric// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
9424d58133SDimitry Andric#  define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
95b2c7081bSDimitry Andric// Use the smallest possible integer type to represent the index of the variant.
96b2c7081bSDimitry Andric// Previously libc++ used "unsigned int" exclusivly.
97b2c7081bSDimitry Andric#  define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
98*b5893f02SDimitry Andric// Unstable attempt to provide a more optimized std::function
99*b5893f02SDimitry Andric#  define _LIBCPP_ABI_OPTIMIZED_FUNCTION
1007c82a1ecSDimitry Andric#elif _LIBCPP_ABI_VERSION == 1
101540d2a8bSDimitry Andric#  if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
102540d2a8bSDimitry Andric// Enable compiling copies of now inline methods into the dylib to support
103540d2a8bSDimitry Andric// applications compiled against older libraries. This is unnecessary with
104540d2a8bSDimitry Andric// COFF dllexport semantics, since dllexport forces a non-inline definition
105540d2a8bSDimitry Andric// of inline functions to be emitted anyway. Our own non-inline copy would
106540d2a8bSDimitry Andric// conflict with the dllexport-emitted copy, so we disable it.
107540d2a8bSDimitry Andric#    define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
108aed8d94eSDimitry Andric#  endif
1097c82a1ecSDimitry Andric// Feature macros for disabling pre ABI v1 features. All of these options
1107c82a1ecSDimitry Andric// are deprecated.
1117c82a1ecSDimitry Andric#  if defined(__FreeBSD__)
1127c82a1ecSDimitry Andric#    define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
1137c82a1ecSDimitry Andric#  endif
1147c82a1ecSDimitry Andric#endif
1157c82a1ecSDimitry Andric
1167c82a1ecSDimitry Andric#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
1177c82a1ecSDimitry Andric#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
1187c82a1ecSDimitry Andric       use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
1199729cf09SDimitry Andric#endif
1207a984708SDavid Chisnall
1217a984708SDavid Chisnall#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
1227a984708SDavid Chisnall#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
1237a984708SDavid Chisnall
124*b5893f02SDimitry Andric#ifndef _LIBCPP_ABI_NAMESPACE
125*b5893f02SDimitry Andric# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
126*b5893f02SDimitry Andric#endif
1277a984708SDavid Chisnall
128aed8d94eSDimitry Andric#if __cplusplus < 201103L
129aed8d94eSDimitry Andric#define _LIBCPP_CXX03_LANG
130aed8d94eSDimitry Andric#endif
131854fa44bSDimitry Andric
132854fa44bSDimitry Andric#ifndef __has_attribute
133854fa44bSDimitry Andric#define __has_attribute(__x) 0
134854fa44bSDimitry Andric#endif
1354ba319b5SDimitry Andric
136854fa44bSDimitry Andric#ifndef __has_builtin
137854fa44bSDimitry Andric#define __has_builtin(__x) 0
138854fa44bSDimitry Andric#endif
1394ba319b5SDimitry Andric
1409729cf09SDimitry Andric#ifndef __has_extension
1419729cf09SDimitry Andric#define __has_extension(__x) 0
1429729cf09SDimitry Andric#endif
1434ba319b5SDimitry Andric
144854fa44bSDimitry Andric#ifndef __has_feature
145854fa44bSDimitry Andric#define __has_feature(__x) 0
146854fa44bSDimitry Andric#endif
1474ba319b5SDimitry Andric
148b2c7081bSDimitry Andric#ifndef __has_cpp_attribute
149b2c7081bSDimitry Andric#define __has_cpp_attribute(__x) 0
150b2c7081bSDimitry Andric#endif
1514ba319b5SDimitry Andric
152854fa44bSDimitry Andric// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
153854fa44bSDimitry Andric// the compiler and '1' otherwise.
154854fa44bSDimitry Andric#ifndef __is_identifier
155854fa44bSDimitry Andric#define __is_identifier(__x) 1
156854fa44bSDimitry Andric#endif
1574ba319b5SDimitry Andric
158540d2a8bSDimitry Andric#ifndef __has_declspec_attribute
159540d2a8bSDimitry Andric#define __has_declspec_attribute(__x) 0
160540d2a8bSDimitry Andric#endif
161540d2a8bSDimitry Andric
162540d2a8bSDimitry Andric#define __has_keyword(__x) !(__is_identifier(__x))
163854fa44bSDimitry Andric
1644ba319b5SDimitry Andric#ifndef __has_include
1654ba319b5SDimitry Andric#define __has_include(...) 0
1665517e702SDimitry Andric#endif
1675517e702SDimitry Andric
16880779b37SDimitry Andric#if defined(__clang__)
16980779b37SDimitry Andric#  define _LIBCPP_COMPILER_CLANG
170b1c1e77aSDimitry Andric#  ifndef __apple_build_version__
171b1c1e77aSDimitry Andric#    define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
172b1c1e77aSDimitry Andric#  endif
17380779b37SDimitry Andric#elif defined(__GNUC__)
17480779b37SDimitry Andric#  define _LIBCPP_COMPILER_GCC
17580779b37SDimitry Andric#elif defined(_MSC_VER)
17680779b37SDimitry Andric#  define _LIBCPP_COMPILER_MSVC
17780779b37SDimitry Andric#elif defined(__IBMCPP__)
17880779b37SDimitry Andric#  define _LIBCPP_COMPILER_IBM
17980779b37SDimitry Andric#endif
18080779b37SDimitry Andric
181b1c1e77aSDimitry Andric#ifndef _LIBCPP_CLANG_VER
182b1c1e77aSDimitry Andric#define _LIBCPP_CLANG_VER 0
183b1c1e77aSDimitry Andric#endif
184b1c1e77aSDimitry Andric
18580779b37SDimitry Andric// FIXME: ABI detection should be done via compiler builtin macros. This
18680779b37SDimitry Andric// is just a placeholder until Clang implements such macros. For now assume
187b2c7081bSDimitry Andric// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
188b2c7081bSDimitry Andric// and allow the user to explicitly specify the ABI to handle cases where this
189b2c7081bSDimitry Andric// heuristic falls short.
190b2c7081bSDimitry Andric#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
191b2c7081bSDimitry Andric#  error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
192b2c7081bSDimitry Andric#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
193b2c7081bSDimitry Andric#  define _LIBCPP_ABI_ITANIUM
194b2c7081bSDimitry Andric#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
195b2c7081bSDimitry Andric#  define _LIBCPP_ABI_MICROSOFT
196b2c7081bSDimitry Andric#else
19780779b37SDimitry Andric#  if defined(_WIN32) && defined(_MSC_VER)
19880779b37SDimitry Andric#    define _LIBCPP_ABI_MICROSOFT
19980779b37SDimitry Andric#  else
20080779b37SDimitry Andric#    define _LIBCPP_ABI_ITANIUM
20180779b37SDimitry Andric#  endif
202b2c7081bSDimitry Andric#endif
20380779b37SDimitry Andric
204aed8d94eSDimitry Andric// Need to detect which libc we're using if we're on Linux.
205aed8d94eSDimitry Andric#if defined(__linux__)
206aed8d94eSDimitry Andric#  include <features.h>
2074ba319b5SDimitry Andric#  if defined(__GLIBC_PREREQ)
2084ba319b5SDimitry Andric#    define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
2094ba319b5SDimitry Andric#  else
2104ba319b5SDimitry Andric#    define _LIBCPP_GLIBC_PREREQ(a, b) 0
2114ba319b5SDimitry Andric#  endif // defined(__GLIBC_PREREQ)
212aed8d94eSDimitry Andric#endif // defined(__linux__)
213854fa44bSDimitry Andric
2147a984708SDavid Chisnall#ifdef __LITTLE_ENDIAN__
2157a984708SDavid Chisnall#  if __LITTLE_ENDIAN__
216b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
2177a984708SDavid Chisnall#  endif  // __LITTLE_ENDIAN__
2187a984708SDavid Chisnall#endif  // __LITTLE_ENDIAN__
2197a984708SDavid Chisnall
2207a984708SDavid Chisnall#ifdef __BIG_ENDIAN__
2217a984708SDavid Chisnall#  if __BIG_ENDIAN__
222b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
2237a984708SDavid Chisnall#  endif  // __BIG_ENDIAN__
2247a984708SDavid Chisnall#endif  // __BIG_ENDIAN__
2257a984708SDavid Chisnall
2269729cf09SDimitry Andric#ifdef __BYTE_ORDER__
2279729cf09SDimitry Andric#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
228b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
2299729cf09SDimitry Andric#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
230b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
2319729cf09SDimitry Andric#  endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2329729cf09SDimitry Andric#endif // __BYTE_ORDER__
2339729cf09SDimitry Andric
2347a984708SDavid Chisnall#ifdef __FreeBSD__
2357a984708SDavid Chisnall#  include <sys/endian.h>
2367a984708SDavid Chisnall#  if _BYTE_ORDER == _LITTLE_ENDIAN
237b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
2387a984708SDavid Chisnall#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
239b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
2407a984708SDavid Chisnall#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
2415f5f8832SDimitry Andric#  ifndef __LONG_LONG_SUPPORTED
2425f5f8832SDimitry Andric#    define _LIBCPP_HAS_NO_LONG_LONG
2435f5f8832SDimitry Andric#  endif  // __LONG_LONG_SUPPORTED
2447a984708SDavid Chisnall#endif  // __FreeBSD__
2457a984708SDavid Chisnall
2464bab9fd9SDavid Chisnall#ifdef __NetBSD__
2474bab9fd9SDavid Chisnall#  include <sys/endian.h>
2484bab9fd9SDavid Chisnall#  if _BYTE_ORDER == _LITTLE_ENDIAN
249b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
2504bab9fd9SDavid Chisnall#  else  // _BYTE_ORDER == _LITTLE_ENDIAN
251b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
2524bab9fd9SDavid Chisnall#  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
2534bab9fd9SDavid Chisnall#  define _LIBCPP_HAS_QUICK_EXIT
2544bab9fd9SDavid Chisnall#endif  // __NetBSD__
2554bab9fd9SDavid Chisnall
256aed8d94eSDimitry Andric#if defined(_WIN32)
257f9448bf3SDimitry Andric#  define _LIBCPP_WIN32API
258b2c7081bSDimitry Andric#  define _LIBCPP_LITTLE_ENDIAN
259aed8d94eSDimitry Andric#  define _LIBCPP_SHORT_WCHAR   1
260f9448bf3SDimitry Andric// Both MinGW and native MSVC provide a "MSVC"-like enviroment
261f9448bf3SDimitry Andric#  define _LIBCPP_MSVCRT_LIKE
262b40b48b8SDimitry Andric// If mingw not explicitly detected, assume using MS C runtime only if
263b40b48b8SDimitry Andric// a MS compatibility version is specified.
264b40b48b8SDimitry Andric#  if defined(_MSC_VER) && !defined(__MINGW32__)
2654f7ab58eSDimitry Andric#    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
2667a984708SDavid Chisnall#  endif
267aed8d94eSDimitry Andric#  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
268aed8d94eSDimitry Andric#    define _LIBCPP_HAS_BITSCAN64
269aed8d94eSDimitry Andric#  endif
2704ba319b5SDimitry Andric#  define _LIBCPP_HAS_OPEN_WITH_WCHAR
271540d2a8bSDimitry Andric#  if defined(_LIBCPP_MSVCRT)
272540d2a8bSDimitry Andric#    define _LIBCPP_HAS_QUICK_EXIT
273540d2a8bSDimitry Andric#  endif
274540d2a8bSDimitry Andric
275540d2a8bSDimitry Andric// Some CRT APIs are unavailable to store apps
276540d2a8bSDimitry Andric#  if defined(WINAPI_FAMILY)
277540d2a8bSDimitry Andric#    include <winapifamily.h>
278540d2a8bSDimitry Andric#    if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                  \
279540d2a8bSDimitry Andric        (!defined(WINAPI_PARTITION_SYSTEM) ||                                  \
280540d2a8bSDimitry Andric         !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
281540d2a8bSDimitry Andric#      define _LIBCPP_WINDOWS_STORE_APP
282540d2a8bSDimitry Andric#    endif
283540d2a8bSDimitry Andric#  endif
284aed8d94eSDimitry Andric#endif // defined(_WIN32)
2857a984708SDavid Chisnall
28694e3ee44SDavid Chisnall#ifdef __sun__
28794e3ee44SDavid Chisnall#  include <sys/isa_defs.h>
28894e3ee44SDavid Chisnall#  ifdef _LITTLE_ENDIAN
289b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
29094e3ee44SDavid Chisnall#  else
291b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
29294e3ee44SDavid Chisnall#  endif
29394e3ee44SDavid Chisnall#endif // __sun__
29494e3ee44SDavid Chisnall
295854fa44bSDimitry Andric#if defined(__CloudABI__)
296854fa44bSDimitry Andric   // Certain architectures provide arc4random(). Prefer using
297854fa44bSDimitry Andric   // arc4random() over /dev/{u,}random to make it possible to obtain
298854fa44bSDimitry Andric   // random data even when using sandboxing mechanisms such as chroots,
299854fa44bSDimitry Andric   // Capsicum, etc.
300854fa44bSDimitry Andric#  define _LIBCPP_USING_ARC4_RANDOM
301b2c7081bSDimitry Andric#elif defined(__Fuchsia__)
302b2c7081bSDimitry Andric#  define _LIBCPP_USING_GETENTROPY
303854fa44bSDimitry Andric#elif defined(__native_client__)
304d72607e9SDimitry Andric   // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
305d72607e9SDimitry Andric   // including accesses to the special files under /dev. C++11's
306d72607e9SDimitry Andric   // std::random_device is instead exposed through a NaCl syscall.
307d72607e9SDimitry Andric#  define _LIBCPP_USING_NACL_RANDOM
308aed8d94eSDimitry Andric#elif defined(_LIBCPP_WIN32API)
309854fa44bSDimitry Andric#  define _LIBCPP_USING_WIN32_RANDOM
310854fa44bSDimitry Andric#else
311854fa44bSDimitry Andric#  define _LIBCPP_USING_DEV_RANDOM
312854fa44bSDimitry Andric#endif
313d72607e9SDimitry Andric
314b2c7081bSDimitry Andric#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
3157a984708SDavid Chisnall#  include <endian.h>
3167a984708SDavid Chisnall#  if __BYTE_ORDER == __LITTLE_ENDIAN
317b2c7081bSDimitry Andric#    define _LIBCPP_LITTLE_ENDIAN
3187a984708SDavid Chisnall#  elif __BYTE_ORDER == __BIG_ENDIAN
319b2c7081bSDimitry Andric#    define _LIBCPP_BIG_ENDIAN
3207a984708SDavid Chisnall#  else  // __BYTE_ORDER == __BIG_ENDIAN
3217a984708SDavid Chisnall#    error unable to determine endian
3227a984708SDavid Chisnall#  endif
323b2c7081bSDimitry Andric#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
3247a984708SDavid Chisnall
32524d58133SDimitry Andric#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
3267c82a1ecSDimitry Andric#  define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
3277c82a1ecSDimitry Andric#else
3287c82a1ecSDimitry Andric#  define _LIBCPP_NO_CFI
3297c82a1ecSDimitry Andric#endif
3307c82a1ecSDimitry Andric
3314ba319b5SDimitry Andric#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
3324ba319b5SDimitry Andric#  if defined(__FreeBSD__)
3334ba319b5SDimitry Andric#    define _LIBCPP_HAS_QUICK_EXIT
3344ba319b5SDimitry Andric#    define _LIBCPP_HAS_C11_FEATURES
3354ba319b5SDimitry Andric#  elif defined(__Fuchsia__)
3364ba319b5SDimitry Andric#    define _LIBCPP_HAS_QUICK_EXIT
3374ba319b5SDimitry Andric#    define _LIBCPP_HAS_TIMESPEC_GET
3384ba319b5SDimitry Andric#    define _LIBCPP_HAS_C11_FEATURES
3394ba319b5SDimitry Andric#  elif defined(__linux__)
3404ba319b5SDimitry Andric#    if !defined(_LIBCPP_HAS_MUSL_LIBC)
3414ba319b5SDimitry Andric#      if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
3424ba319b5SDimitry Andric#        define _LIBCPP_HAS_QUICK_EXIT
3434ba319b5SDimitry Andric#      endif
3444ba319b5SDimitry Andric#      if _LIBCPP_GLIBC_PREREQ(2, 17)
3454ba319b5SDimitry Andric#        define _LIBCPP_HAS_C11_FEATURES
3464ba319b5SDimitry Andric#        define _LIBCPP_HAS_TIMESPEC_GET
3474ba319b5SDimitry Andric#      endif
3484ba319b5SDimitry Andric#    else // defined(_LIBCPP_HAS_MUSL_LIBC)
3494ba319b5SDimitry Andric#      define _LIBCPP_HAS_QUICK_EXIT
3504ba319b5SDimitry Andric#      define _LIBCPP_HAS_TIMESPEC_GET
3514ba319b5SDimitry Andric#      define _LIBCPP_HAS_C11_FEATURES
3524ba319b5SDimitry Andric#    endif
3534ba319b5SDimitry Andric#  endif // __linux__
3544ba319b5SDimitry Andric#endif
3554ba319b5SDimitry Andric
356*b5893f02SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
357*b5893f02SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
358*b5893f02SDimitry Andric#elif defined(_LIBCPP_COMPILER_CLANG)
359*b5893f02SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
360*b5893f02SDimitry Andric#else
361*b5893f02SDimitry Andric// This definition is potentially buggy, but it's only taken with GCC in C++03,
362*b5893f02SDimitry Andric// which we barely support anyway. See llvm.org/PR39713
363*b5893f02SDimitry Andric# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
364*b5893f02SDimitry Andric#endif
365*b5893f02SDimitry Andric
366*b5893f02SDimitry Andric#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
367*b5893f02SDimitry Andric
36880779b37SDimitry Andric#if defined(_LIBCPP_COMPILER_CLANG)
3697a984708SDavid Chisnall
3709729cf09SDimitry Andric// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
3719729cf09SDimitry Andric// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
3729729cf09SDimitry Andric#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
373540d2a8bSDimitry Andric     (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) ||                           \
3749729cf09SDimitry Andric    defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
3759729cf09SDimitry Andric#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
376d72607e9SDimitry Andric#endif
377d72607e9SDimitry Andric
3787a984708SDavid Chisnall#if __has_feature(cxx_alignas)
379936e9439SDimitry Andric#  define _ALIGNAS_TYPE(x) alignas(x)
3807a984708SDavid Chisnall#  define _ALIGNAS(x) alignas(x)
3817a984708SDavid Chisnall#else
382*b5893f02SDimitry Andric#  define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
3837a984708SDavid Chisnall#  define _ALIGNAS(x) __attribute__((__aligned__(x)))
3847a984708SDavid Chisnall#endif
3857a984708SDavid Chisnall
386d72607e9SDimitry Andric#if __cplusplus < 201103L
3877a984708SDavid Chisnalltypedef __char16_t char16_t;
3887a984708SDavid Chisnalltypedef __char32_t char32_t;
3897a984708SDavid Chisnall#endif
3907a984708SDavid Chisnall
3917c82a1ecSDimitry Andric#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
3927a984708SDavid Chisnall#define _LIBCPP_NO_EXCEPTIONS
3937a984708SDavid Chisnall#endif
3947a984708SDavid Chisnall
3950f5676f4SDimitry Andric#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
3967a984708SDavid Chisnall#define _LIBCPP_NO_RTTI
3977a984708SDavid Chisnall#endif
3987a984708SDavid Chisnall
39994e3ee44SDavid Chisnall#if !(__has_feature(cxx_strong_enums))
40094e3ee44SDavid Chisnall#define _LIBCPP_HAS_NO_STRONG_ENUMS
40194e3ee44SDavid Chisnall#endif
40294e3ee44SDavid Chisnall
4037a984708SDavid Chisnall#if !(__has_feature(cxx_decltype))
4047a984708SDavid Chisnall#define _LIBCPP_HAS_NO_DECLTYPE
4057a984708SDavid Chisnall#endif
4067a984708SDavid Chisnall
4077a984708SDavid Chisnall#if __has_feature(cxx_attributes)
408936e9439SDimitry Andric#  define _LIBCPP_NORETURN [[noreturn]]
4097a984708SDavid Chisnall#else
410936e9439SDimitry Andric#  define _LIBCPP_NORETURN __attribute__ ((noreturn))
4117a984708SDavid Chisnall#endif
4127a984708SDavid Chisnall
4137a984708SDavid Chisnall#if !(__has_feature(cxx_lambdas))
4147a984708SDavid Chisnall#define _LIBCPP_HAS_NO_LAMBDAS
4157a984708SDavid Chisnall#endif
4167a984708SDavid Chisnall
4177a984708SDavid Chisnall#if !(__has_feature(cxx_nullptr))
418540d2a8bSDimitry Andric#  if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
419aed8d94eSDimitry Andric#    define nullptr __nullptr
420aed8d94eSDimitry Andric#  else
4217a984708SDavid Chisnall#    define _LIBCPP_HAS_NO_NULLPTR
4227a984708SDavid Chisnall#  endif
423aed8d94eSDimitry Andric#endif
4247a984708SDavid Chisnall
4257a984708SDavid Chisnall#if !(__has_feature(cxx_rvalue_references))
4267a984708SDavid Chisnall#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
4277a984708SDavid Chisnall#endif
4287a984708SDavid Chisnall
4297a984708SDavid Chisnall#if !(__has_feature(cxx_auto_type))
4307a984708SDavid Chisnall#define _LIBCPP_HAS_NO_AUTO_TYPE
4317a984708SDavid Chisnall#endif
4327a984708SDavid Chisnall
4337a984708SDavid Chisnall#if !(__has_feature(cxx_variadic_templates))
4347a984708SDavid Chisnall#define _LIBCPP_HAS_NO_VARIADICS
4357a984708SDavid Chisnall#endif
4367a984708SDavid Chisnall
4377a984708SDavid Chisnall#if !(__has_feature(cxx_generalized_initializers))
4387a984708SDavid Chisnall#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
4397a984708SDavid Chisnall#endif
4407a984708SDavid Chisnall
4417a984708SDavid Chisnall#if __has_feature(is_base_of)
4424f7ab58eSDimitry Andric#define _LIBCPP_HAS_IS_BASE_OF
4437a984708SDavid Chisnall#endif
4447a984708SDavid Chisnall
445854fa44bSDimitry Andric#if __has_feature(is_final)
446854fa44bSDimitry Andric#define _LIBCPP_HAS_IS_FINAL
447854fa44bSDimitry Andric#endif
448854fa44bSDimitry Andric
4497a984708SDavid Chisnall// Objective-C++ features (opt-in)
4507a984708SDavid Chisnall#if __has_feature(objc_arc)
4517a984708SDavid Chisnall#define _LIBCPP_HAS_OBJC_ARC
4527a984708SDavid Chisnall#endif
4537a984708SDavid Chisnall
4547a984708SDavid Chisnall#if __has_feature(objc_arc_weak)
4557a984708SDavid Chisnall#define _LIBCPP_HAS_OBJC_ARC_WEAK
4567a984708SDavid Chisnall#endif
4577a984708SDavid Chisnall
4587a984708SDavid Chisnall#if !(__has_feature(cxx_constexpr))
4597a984708SDavid Chisnall#define _LIBCPP_HAS_NO_CONSTEXPR
4607a984708SDavid Chisnall#endif
4617a984708SDavid Chisnall
462d72607e9SDimitry Andric#if !(__has_feature(cxx_relaxed_constexpr))
463d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
464d72607e9SDimitry Andric#endif
465d72607e9SDimitry Andric
466854fa44bSDimitry Andric#if !(__has_feature(cxx_variable_templates))
467854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
468854fa44bSDimitry Andric#endif
469854fa44bSDimitry Andric
470faaf0c6eSDimitry Andric#if !(__has_feature(cxx_noexcept))
471faaf0c6eSDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT
4727a984708SDavid Chisnall#endif
4737a984708SDavid Chisnall
4747a984708SDavid Chisnall#if __has_feature(underlying_type)
475d72607e9SDimitry Andric#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
476d72607e9SDimitry Andric#endif
477d72607e9SDimitry Andric
478d72607e9SDimitry Andric#if __has_feature(is_literal)
479d72607e9SDimitry Andric#define _LIBCPP_IS_LITERAL(T) __is_literal(T)
4807a984708SDavid Chisnall#endif
4817a984708SDavid Chisnall
482d72607e9SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
483d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_ASAN
484d72607e9SDimitry Andric#endif
485d72607e9SDimitry Andric
4869729cf09SDimitry Andric// Allow for build-time disabling of unsigned integer sanitization
4877c82a1ecSDimitry Andric#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
4887c82a1ecSDimitry Andric#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
4899729cf09SDimitry Andric#endif
4909729cf09SDimitry Andric
491b2c7081bSDimitry Andric#if __has_builtin(__builtin_launder)
492b2c7081bSDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
493b2c7081bSDimitry Andric#endif
494b2c7081bSDimitry Andric
49530785c0eSDimitry Andric#if !__is_identifier(__has_unique_object_representations)
49630785c0eSDimitry Andric#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
49730785c0eSDimitry Andric#endif
49830785c0eSDimitry Andric
4994ba319b5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
5004ba319b5SDimitry Andric
501*b5893f02SDimitry Andric// No apple compilers support ""d and ""y at this time.
502*b5893f02SDimitry Andric#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
503*b5893f02SDimitry Andric#define	_LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
504*b5893f02SDimitry Andric#endif
505*b5893f02SDimitry Andric
50680779b37SDimitry Andric#elif defined(_LIBCPP_COMPILER_GCC)
5077a984708SDavid Chisnall
5087a984708SDavid Chisnall#define _ALIGNAS(x) __attribute__((__aligned__(x)))
509*b5893f02SDimitry Andric#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
5107a984708SDavid Chisnall
511936e9439SDimitry Andric#define _LIBCPP_NORETURN __attribute__((noreturn))
5127a984708SDavid Chisnall
513d72607e9SDimitry Andric#if _GNUC_VER >= 407
514d72607e9SDimitry Andric#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
515d72607e9SDimitry Andric#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
516854fa44bSDimitry Andric#define _LIBCPP_HAS_IS_FINAL
517854fa44bSDimitry Andric#endif
518854fa44bSDimitry Andric
519854fa44bSDimitry Andric#if defined(__GNUC__) && _GNUC_VER >= 403
520854fa44bSDimitry Andric#define _LIBCPP_HAS_IS_BASE_OF
521d72607e9SDimitry Andric#endif
522d72607e9SDimitry Andric
5234ba319b5SDimitry Andric#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
5247a984708SDavid Chisnall#define _LIBCPP_NO_EXCEPTIONS
5257a984708SDavid Chisnall#endif
5267a984708SDavid Chisnall
527d72607e9SDimitry Andric// constexpr was added to GCC in 4.6.
528d72607e9SDimitry Andric#if _GNUC_VER < 406
5297a984708SDavid Chisnall#  define _LIBCPP_HAS_NO_CONSTEXPR
530d72607e9SDimitry Andric// Can only use constexpr in c++11 mode.
531d72607e9SDimitry Andric#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
532d72607e9SDimitry Andric#  define _LIBCPP_HAS_NO_CONSTEXPR
533d72607e9SDimitry Andric#endif
534d72607e9SDimitry Andric
53591325990SDimitry Andric// Determine if GCC supports relaxed constexpr
53691325990SDimitry Andric#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
537d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
53891325990SDimitry Andric#endif
53991325990SDimitry Andric
540854fa44bSDimitry Andric// GCC 5 will support variable templates
54191325990SDimitry Andric#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
542854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
54391325990SDimitry Andric#endif
5447a984708SDavid Chisnall
5457a984708SDavid Chisnall#ifndef __GXX_EXPERIMENTAL_CXX0X__
5464ba319b5SDimitry Andric
5477a984708SDavid Chisnall#define _LIBCPP_HAS_NO_DECLTYPE
5487a984708SDavid Chisnall#define _LIBCPP_HAS_NO_NULLPTR
5497a984708SDavid Chisnall#define _LIBCPP_HAS_NO_UNICODE_CHARS
5507a984708SDavid Chisnall#define _LIBCPP_HAS_NO_VARIADICS
5517a984708SDavid Chisnall#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
55278433c77SBaptiste Daroussin#define _LIBCPP_HAS_NO_STRONG_ENUMS
553faaf0c6eSDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT
5547a984708SDavid Chisnall
5557a984708SDavid Chisnall#else  // __GXX_EXPERIMENTAL_CXX0X__
5567a984708SDavid Chisnall
557936e9439SDimitry Andric#if _GNUC_VER < 403
5587a984708SDavid Chisnall#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
5597a984708SDavid Chisnall#endif
5607a984708SDavid Chisnall
5619729cf09SDimitry Andric
562936e9439SDimitry Andric#if _GNUC_VER < 404
5637a984708SDavid Chisnall#define _LIBCPP_HAS_NO_DECLTYPE
5647a984708SDavid Chisnall#define _LIBCPP_HAS_NO_UNICODE_CHARS
5657a984708SDavid Chisnall#define _LIBCPP_HAS_NO_VARIADICS
5667a984708SDavid Chisnall#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
567936e9439SDimitry Andric#endif  // _GNUC_VER < 404
5687a984708SDavid Chisnall
569936e9439SDimitry Andric#if _GNUC_VER < 406
570faaf0c6eSDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT
5717a984708SDavid Chisnall#define _LIBCPP_HAS_NO_NULLPTR
572d72607e9SDimitry Andric#endif
573d72607e9SDimitry Andric
5747a984708SDavid Chisnall#endif  // __GXX_EXPERIMENTAL_CXX0X__
5757a984708SDavid Chisnall
576d72607e9SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
577d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_ASAN
578d72607e9SDimitry Andric#endif
579d72607e9SDimitry Andric
580b2c7081bSDimitry Andric#if _GNUC_VER >= 700
581b2c7081bSDimitry Andric#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
582b2c7081bSDimitry Andric#endif
583b2c7081bSDimitry Andric
58430785c0eSDimitry Andric#if _GNUC_VER >= 700
58530785c0eSDimitry Andric#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
58630785c0eSDimitry Andric#endif
58730785c0eSDimitry Andric
5884ba319b5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
5894ba319b5SDimitry Andric
59080779b37SDimitry Andric#elif defined(_LIBCPP_COMPILER_MSVC)
5917a984708SDavid Chisnall
59280779b37SDimitry Andric#define _LIBCPP_TOSTRING2(x) #x
59380779b37SDimitry Andric#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
59480779b37SDimitry Andric#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
59580779b37SDimitry Andric
59680779b37SDimitry Andric#if _MSC_VER < 1900
59780779b37SDimitry Andric#error "MSVC versions prior to Visual Studio 2015 are not supported"
59880779b37SDimitry Andric#endif
59980779b37SDimitry Andric
60080779b37SDimitry Andric#define _LIBCPP_HAS_IS_BASE_OF
6017a984708SDavid Chisnall#define _LIBCPP_HAS_NO_CONSTEXPR
602d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
603854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
604faaf0c6eSDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT
6057a984708SDavid Chisnall#define __alignof__ __alignof
606936e9439SDimitry Andric#define _LIBCPP_NORETURN __declspec(noreturn)
6077a984708SDavid Chisnall#define _ALIGNAS(x) __declspec(align(x))
6084ba319b5SDimitry Andric#define _ALIGNAS_TYPE(x) alignas(x)
6097a984708SDavid Chisnall#define _LIBCPP_HAS_NO_VARIADICS
6107a984708SDavid Chisnall
6114ba319b5SDimitry Andric#define _LIBCPP_WEAK
6124ba319b5SDimitry Andric
613d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_ASAN
614d72607e9SDimitry Andric
6154ba319b5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __forceinline
6164ba319b5SDimitry Andric
6174ba319b5SDimitry Andric#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
6184ba319b5SDimitry Andric
61980779b37SDimitry Andric#elif defined(_LIBCPP_COMPILER_IBM)
6204f7ab58eSDimitry Andric
6214f7ab58eSDimitry Andric#define _ALIGNAS(x) __attribute__((__aligned__(x)))
622*b5893f02SDimitry Andric#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
6234f7ab58eSDimitry Andric#define _ATTRIBUTE(x) __attribute__((x))
6244f7ab58eSDimitry Andric#define _LIBCPP_NORETURN __attribute__((noreturn))
6254f7ab58eSDimitry Andric
6264f7ab58eSDimitry Andric#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
627faaf0c6eSDimitry Andric#define _LIBCPP_HAS_NO_NOEXCEPT
6284f7ab58eSDimitry Andric#define _LIBCPP_HAS_NO_NULLPTR
6294f7ab58eSDimitry Andric#define _LIBCPP_HAS_NO_UNICODE_CHARS
6304f7ab58eSDimitry Andric#define _LIBCPP_HAS_IS_BASE_OF
631854fa44bSDimitry Andric#define _LIBCPP_HAS_IS_FINAL
632854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
6334f7ab58eSDimitry Andric
6344f7ab58eSDimitry Andric#if defined(_AIX)
6354f7ab58eSDimitry Andric#define __MULTILOCALE_API
6364f7ab58eSDimitry Andric#endif
6374f7ab58eSDimitry Andric
638d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_ASAN
639d72607e9SDimitry Andric
6404ba319b5SDimitry Andric#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
6414ba319b5SDimitry Andric
6424ba319b5SDimitry Andric#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
6434ba319b5SDimitry Andric
64480779b37SDimitry Andric#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
6457a984708SDavid Chisnall
646aed8d94eSDimitry Andric#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
6474ba319b5SDimitry Andric
6484ba319b5SDimitry Andric#ifdef _DLL
6494ba319b5SDimitry Andric#  define _LIBCPP_CRT_FUNC __declspec(dllimport)
6504ba319b5SDimitry Andric#else
6514ba319b5SDimitry Andric#  define _LIBCPP_CRT_FUNC
6524ba319b5SDimitry Andric#endif
6534ba319b5SDimitry Andric
654aed8d94eSDimitry Andric#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
655aed8d94eSDimitry Andric#  define _LIBCPP_DLL_VIS
656aed8d94eSDimitry Andric#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
657aed8d94eSDimitry Andric#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
658aed8d94eSDimitry Andric#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
659*b5893f02SDimitry Andric#  define _LIBCPP_EXPORTED_FROM_ABI
660aed8d94eSDimitry Andric#elif defined(_LIBCPP_BUILDING_LIBRARY)
661aed8d94eSDimitry Andric#  define _LIBCPP_DLL_VIS __declspec(dllexport)
662aed8d94eSDimitry Andric#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
663aed8d94eSDimitry Andric#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
664aed8d94eSDimitry Andric#  define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
665*b5893f02SDimitry Andric#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
666aed8d94eSDimitry Andric#else
667aed8d94eSDimitry Andric#  define _LIBCPP_DLL_VIS __declspec(dllimport)
668aed8d94eSDimitry Andric#  define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
669aed8d94eSDimitry Andric#  define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
670aed8d94eSDimitry Andric#  define _LIBCPP_OVERRIDABLE_FUNC_VIS
671*b5893f02SDimitry Andric#  define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
672aed8d94eSDimitry Andric#endif
673aed8d94eSDimitry Andric
674aed8d94eSDimitry Andric#define _LIBCPP_TYPE_VIS            _LIBCPP_DLL_VIS
675aed8d94eSDimitry Andric#define _LIBCPP_FUNC_VIS            _LIBCPP_DLL_VIS
676aed8d94eSDimitry Andric#define _LIBCPP_EXCEPTION_ABI       _LIBCPP_DLL_VIS
677aed8d94eSDimitry Andric#define _LIBCPP_HIDDEN
678540d2a8bSDimitry Andric#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
679aed8d94eSDimitry Andric#define _LIBCPP_TEMPLATE_VIS
680aed8d94eSDimitry Andric#define _LIBCPP_ENUM_VIS
681aed8d94eSDimitry Andric
682aed8d94eSDimitry Andric#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
683aed8d94eSDimitry Andric
684aed8d94eSDimitry Andric#ifndef _LIBCPP_HIDDEN
685aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
686aed8d94eSDimitry Andric#    define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
687aed8d94eSDimitry Andric#  else
688aed8d94eSDimitry Andric#    define _LIBCPP_HIDDEN
689aed8d94eSDimitry Andric#  endif
690aed8d94eSDimitry Andric#endif
691aed8d94eSDimitry Andric
692540d2a8bSDimitry Andric#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
693540d2a8bSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
694540d2a8bSDimitry Andric// The inline should be removed once PR32114 is resolved
695540d2a8bSDimitry Andric#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
696540d2a8bSDimitry Andric#  else
697540d2a8bSDimitry Andric#    define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
698540d2a8bSDimitry Andric#  endif
699540d2a8bSDimitry Andric#endif
700540d2a8bSDimitry Andric
701aed8d94eSDimitry Andric#ifndef _LIBCPP_FUNC_VIS
702aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
703aed8d94eSDimitry Andric#    define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
704aed8d94eSDimitry Andric#  else
705aed8d94eSDimitry Andric#    define _LIBCPP_FUNC_VIS
706aed8d94eSDimitry Andric#  endif
707aed8d94eSDimitry Andric#endif
708aed8d94eSDimitry Andric
709aed8d94eSDimitry Andric#ifndef _LIBCPP_TYPE_VIS
710aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
711aed8d94eSDimitry Andric#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
712aed8d94eSDimitry Andric#  else
713aed8d94eSDimitry Andric#    define _LIBCPP_TYPE_VIS
714aed8d94eSDimitry Andric#  endif
715aed8d94eSDimitry Andric#endif
716aed8d94eSDimitry Andric
717aed8d94eSDimitry Andric#ifndef _LIBCPP_TEMPLATE_VIS
718540d2a8bSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
719540d2a8bSDimitry Andric#    if __has_attribute(__type_visibility__)
720540d2a8bSDimitry Andric#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
721540d2a8bSDimitry Andric#    else
722540d2a8bSDimitry Andric#      define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
723540d2a8bSDimitry Andric#    endif
724540d2a8bSDimitry Andric#  else
725540d2a8bSDimitry Andric#    define _LIBCPP_TEMPLATE_VIS
726540d2a8bSDimitry Andric#  endif
727aed8d94eSDimitry Andric#endif
728aed8d94eSDimitry Andric
729*b5893f02SDimitry Andric#ifndef _LIBCPP_EXPORTED_FROM_ABI
730*b5893f02SDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
731*b5893f02SDimitry Andric#    define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
732*b5893f02SDimitry Andric#  else
733*b5893f02SDimitry Andric#    define _LIBCPP_EXPORTED_FROM_ABI
734*b5893f02SDimitry Andric#  endif
735540d2a8bSDimitry Andric#endif
736540d2a8bSDimitry Andric
737aed8d94eSDimitry Andric#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
738aed8d94eSDimitry Andric#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
739aed8d94eSDimitry Andric#endif
740aed8d94eSDimitry Andric
741aed8d94eSDimitry Andric#ifndef _LIBCPP_EXCEPTION_ABI
742aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
743aed8d94eSDimitry Andric#    define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
744aed8d94eSDimitry Andric#  else
745aed8d94eSDimitry Andric#    define _LIBCPP_EXCEPTION_ABI
746aed8d94eSDimitry Andric#  endif
747aed8d94eSDimitry Andric#endif
748aed8d94eSDimitry Andric
749aed8d94eSDimitry Andric#ifndef _LIBCPP_ENUM_VIS
750aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
751aed8d94eSDimitry Andric#    define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
752aed8d94eSDimitry Andric#  else
753aed8d94eSDimitry Andric#    define _LIBCPP_ENUM_VIS
754aed8d94eSDimitry Andric#  endif
755aed8d94eSDimitry Andric#endif
756aed8d94eSDimitry Andric
757aed8d94eSDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
758aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
759540d2a8bSDimitry Andric#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
760aed8d94eSDimitry Andric#  else
761aed8d94eSDimitry Andric#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
762aed8d94eSDimitry Andric#  endif
763aed8d94eSDimitry Andric#endif
764aed8d94eSDimitry Andric
765aed8d94eSDimitry Andric#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
766aed8d94eSDimitry Andric#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
767aed8d94eSDimitry Andric#endif
768aed8d94eSDimitry Andric
7694ba319b5SDimitry Andric#if __has_attribute(internal_linkage)
7704ba319b5SDimitry Andric#  define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
771aed8d94eSDimitry Andric#else
7724ba319b5SDimitry Andric#  define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
7734ba319b5SDimitry Andric#endif
7744ba319b5SDimitry Andric
775*b5893f02SDimitry Andric#if __has_attribute(exclude_from_explicit_instantiation)
776*b5893f02SDimitry Andric#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
777*b5893f02SDimitry Andric#else
778*b5893f02SDimitry Andric   // Try to approximate the effect of exclude_from_explicit_instantiation
779*b5893f02SDimitry Andric   // (which is that entities are not assumed to be provided by explicit
780*b5893f02SDimitry Andric   // template instantitations in the dylib) by always inlining those entities.
781*b5893f02SDimitry Andric#  define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
782*b5893f02SDimitry Andric#endif
783*b5893f02SDimitry Andric
7844ba319b5SDimitry Andric#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
7854ba319b5SDimitry Andric#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
7864ba319b5SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
7874ba319b5SDimitry Andric#  else
7884ba319b5SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
789aed8d94eSDimitry Andric#  endif
790aed8d94eSDimitry Andric#endif
791aed8d94eSDimitry Andric
7924ba319b5SDimitry Andric#ifndef _LIBCPP_HIDE_FROM_ABI
7934ba319b5SDimitry Andric#  if _LIBCPP_HIDE_FROM_ABI_PER_TU
7944ba319b5SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
795aed8d94eSDimitry Andric#  else
796*b5893f02SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
797aed8d94eSDimitry Andric#  endif
798aed8d94eSDimitry Andric#endif
799aed8d94eSDimitry Andric
800*b5893f02SDimitry Andric#ifdef _LIBCPP_BUILDING_LIBRARY
801*b5893f02SDimitry Andric#  if _LIBCPP_ABI_VERSION > 1
802*b5893f02SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
803*b5893f02SDimitry Andric#  else
804*b5893f02SDimitry Andric#    define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
805*b5893f02SDimitry Andric#  endif
806*b5893f02SDimitry Andric#else
807*b5893f02SDimitry Andric#  define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
808*b5893f02SDimitry Andric#endif
809*b5893f02SDimitry Andric
810*b5893f02SDimitry Andric// Just so we can migrate to the new macros gradually.
8114ba319b5SDimitry Andric#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
8124ba319b5SDimitry Andric
813*b5893f02SDimitry Andric// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
814*b5893f02SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
815*b5893f02SDimitry Andric#define _LIBCPP_END_NAMESPACE_STD  } }
816*b5893f02SDimitry Andric#define _VSTD std::_LIBCPP_ABI_NAMESPACE
817*b5893f02SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
818*b5893f02SDimitry Andric
819*b5893f02SDimitry Andric#if _LIBCPP_STD_VER >= 17
820*b5893f02SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
821*b5893f02SDimitry Andric  _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
822aed8d94eSDimitry Andric#else
823*b5893f02SDimitry Andric#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
824*b5893f02SDimitry Andric  _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
825aed8d94eSDimitry Andric#endif
826*b5893f02SDimitry Andric
827*b5893f02SDimitry Andric#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
828*b5893f02SDimitry Andric  _LIBCPP_END_NAMESPACE_STD } }
829*b5893f02SDimitry Andric
830*b5893f02SDimitry Andric#define _VSTD_FS _VSTD::__fs::filesystem
831aed8d94eSDimitry Andric
832aed8d94eSDimitry Andric#ifndef _LIBCPP_PREFERRED_OVERLOAD
833aed8d94eSDimitry Andric#  if __has_attribute(__enable_if__)
834aed8d94eSDimitry Andric#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
835aed8d94eSDimitry Andric#  endif
836aed8d94eSDimitry Andric#endif
837aed8d94eSDimitry Andric
838faaf0c6eSDimitry Andric#ifndef _LIBCPP_HAS_NO_NOEXCEPT
839faaf0c6eSDimitry Andric#  define _NOEXCEPT noexcept
840faaf0c6eSDimitry Andric#  define _NOEXCEPT_(x) noexcept(x)
841faaf0c6eSDimitry Andric#else
842faaf0c6eSDimitry Andric#  define _NOEXCEPT throw()
843faaf0c6eSDimitry Andric#  define _NOEXCEPT_(x)
844faaf0c6eSDimitry Andric#endif
845faaf0c6eSDimitry Andric
846aed8d94eSDimitry Andric#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
847aed8d94eSDimitry Andric#  if !defined(_LIBCPP_DEBUG)
848aed8d94eSDimitry Andric#    error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
849aed8d94eSDimitry Andric#  endif
8504ba319b5SDimitry Andric#  ifdef _LIBCPP_HAS_NO_NOEXCEPT
8514ba319b5SDimitry Andric#    define _NOEXCEPT_DEBUG
8524ba319b5SDimitry Andric#    define _NOEXCEPT_DEBUG_(x)
8534ba319b5SDimitry Andric#  else
854aed8d94eSDimitry Andric#    define _NOEXCEPT_DEBUG noexcept(false)
855aed8d94eSDimitry Andric#    define _NOEXCEPT_DEBUG_(x) noexcept(false)
8564ba319b5SDimitry Andric#  endif
857aed8d94eSDimitry Andric#else
858aed8d94eSDimitry Andric#  define _NOEXCEPT_DEBUG _NOEXCEPT
859aed8d94eSDimitry Andric#  define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
860aed8d94eSDimitry Andric#endif
861aed8d94eSDimitry Andric
8627a984708SDavid Chisnall#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
8637a984708SDavid Chisnalltypedef unsigned short char16_t;
8647a984708SDavid Chisnalltypedef unsigned int   char32_t;
8657a984708SDavid Chisnall#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
8667a984708SDavid Chisnall
867d72607e9SDimitry Andric#ifndef __SIZEOF_INT128__
868d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_INT128
869d72607e9SDimitry Andric#endif
870d72607e9SDimitry Andric
871aed8d94eSDimitry Andric#ifdef _LIBCPP_CXX03_LANG
872aed8d94eSDimitry Andric#  if __has_extension(c_static_assert)
873aed8d94eSDimitry Andric#    define static_assert(__b, __m) _Static_assert(__b, __m)
874aed8d94eSDimitry Andric#  else
8759729cf09SDimitry Andricextern "C++" {
8767a984708SDavid Chisnalltemplate <bool> struct __static_assert_test;
8777a984708SDavid Chisnalltemplate <> struct __static_assert_test<true> {};
8787a984708SDavid Chisnalltemplate <unsigned> struct __static_assert_check {};
8799729cf09SDimitry Andric}
8807a984708SDavid Chisnall#    define static_assert(__b, __m) \
8817a984708SDavid Chisnall       typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
8827a984708SDavid Chisnall       _LIBCPP_CONCAT(__t, __LINE__)
883aed8d94eSDimitry Andric#  endif // __has_extension(c_static_assert)
884aed8d94eSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
8857a984708SDavid Chisnall
8867a984708SDavid Chisnall#ifdef _LIBCPP_HAS_NO_DECLTYPE
887854fa44bSDimitry Andric// GCC 4.6 provides __decltype in all standard modes.
888540d2a8bSDimitry Andric#  if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
889854fa44bSDimitry Andric#    define decltype(__x) __decltype(__x)
890854fa44bSDimitry Andric#  else
891854fa44bSDimitry Andric#    define decltype(__x) __typeof__(__x)
892854fa44bSDimitry Andric#  endif
8937a984708SDavid Chisnall#endif
8947a984708SDavid Chisnall
8957a984708SDavid Chisnall#ifdef _LIBCPP_HAS_NO_CONSTEXPR
896b03f91a8SDavid Chisnall#  define _LIBCPP_CONSTEXPR
897b03f91a8SDavid Chisnall#else
898b03f91a8SDavid Chisnall#  define _LIBCPP_CONSTEXPR constexpr
8997a984708SDavid Chisnall#endif
9007a984708SDavid Chisnall
901aed8d94eSDimitry Andric#ifdef _LIBCPP_CXX03_LANG
9024bab9fd9SDavid Chisnall#  define _LIBCPP_DEFAULT {}
9034bab9fd9SDavid Chisnall#else
9044bab9fd9SDavid Chisnall#  define _LIBCPP_DEFAULT = default;
9054bab9fd9SDavid Chisnall#endif
9064bab9fd9SDavid Chisnall
90780779b37SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
9087c82a1ecSDimitry Andric#  define _LIBCPP_EQUAL_DELETE
9097c82a1ecSDimitry Andric#else
9107c82a1ecSDimitry Andric#  define _LIBCPP_EQUAL_DELETE = delete
9117c82a1ecSDimitry Andric#endif
9127c82a1ecSDimitry Andric
913936e9439SDimitry Andric#ifdef __GNUC__
9144bab9fd9SDavid Chisnall#  define _NOALIAS __attribute__((__malloc__))
915936e9439SDimitry Andric#else
916936e9439SDimitry Andric#  define _NOALIAS
917936e9439SDimitry Andric#endif
918936e9439SDimitry Andric
9197a848d17SDimitry Andric#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
920aed8d94eSDimitry Andric    (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
92194e3ee44SDavid Chisnall#  define _LIBCPP_EXPLICIT explicit
92294e3ee44SDavid Chisnall#else
92394e3ee44SDavid Chisnall#  define _LIBCPP_EXPLICIT
92494e3ee44SDavid Chisnall#endif
92594e3ee44SDavid Chisnall
926d72607e9SDimitry Andric#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
927d72607e9SDimitry Andric#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
928d72607e9SDimitry Andric#endif
929d72607e9SDimitry Andric
93094e3ee44SDavid Chisnall#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
9311bf9f7c1SDimitry Andric#  define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
93294e3ee44SDavid Chisnall#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
9331e0896acSDavid Chisnall     __lx __v_; \
9344ba319b5SDimitry Andric     _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
9354ba319b5SDimitry Andric     _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
9364ba319b5SDimitry Andric     _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
93794e3ee44SDavid Chisnall     };
93894e3ee44SDavid Chisnall#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
939aed8d94eSDimitry Andric#  define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
94094e3ee44SDavid Chisnall#  define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
94194e3ee44SDavid Chisnall#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
94294e3ee44SDavid Chisnall
9434f7ab58eSDimitry Andric#ifdef _LIBCPP_DEBUG
9444f7ab58eSDimitry Andric#  if _LIBCPP_DEBUG == 0
9454f7ab58eSDimitry Andric#    define _LIBCPP_DEBUG_LEVEL 1
9464f7ab58eSDimitry Andric#  elif _LIBCPP_DEBUG == 1
9474f7ab58eSDimitry Andric#    define _LIBCPP_DEBUG_LEVEL 2
9484f7ab58eSDimitry Andric#  else
9494f7ab58eSDimitry Andric#    error Supported values for _LIBCPP_DEBUG are 0 and 1
9504f7ab58eSDimitry Andric#  endif
951540d2a8bSDimitry Andric#  if !defined(_LIBCPP_BUILDING_LIBRARY)
9524f7ab58eSDimitry Andric#    define _LIBCPP_EXTERN_TEMPLATE(...)
9534f7ab58eSDimitry Andric#  endif
954540d2a8bSDimitry Andric#endif
955540d2a8bSDimitry Andric
956540d2a8bSDimitry Andric#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
957540d2a8bSDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE(...)
958540d2a8bSDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE2(...)
959540d2a8bSDimitry Andric#endif
9604f7ab58eSDimitry Andric
9611e0896acSDavid Chisnall#ifndef _LIBCPP_EXTERN_TEMPLATE
962d72607e9SDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
9634f7ab58eSDimitry Andric#endif
9644f7ab58eSDimitry Andric
9654f7ab58eSDimitry Andric#ifndef _LIBCPP_EXTERN_TEMPLATE2
9664f7ab58eSDimitry Andric#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
9671e0896acSDavid Chisnall#endif
9681e0896acSDavid Chisnall
969d72607e9SDimitry Andric#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
970d72607e9SDimitry Andric#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
971d72607e9SDimitry Andric#endif
972d72607e9SDimitry Andric
973b2c7081bSDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
974854fa44bSDimitry Andric    defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
9757a984708SDavid Chisnall#define _LIBCPP_LOCALE__L_EXTENSIONS 1
9767a984708SDavid Chisnall#endif
977d72607e9SDimitry Andric
9787c82a1ecSDimitry Andric#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
9797c82a1ecSDimitry Andric// Most unix variants have catopen.  These are the specific ones that don't.
980aed8d94eSDimitry Andric#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
981854fa44bSDimitry Andric#    define _LIBCPP_HAS_CATOPEN 1
982854fa44bSDimitry Andric#  endif
9837c82a1ecSDimitry Andric#endif
984854fa44bSDimitry Andric
9851bf9f7c1SDimitry Andric#ifdef __FreeBSD__
9867a984708SDavid Chisnall#define _DECLARE_C99_LDBL_MATH 1
9877a984708SDavid Chisnall#endif
9887a984708SDavid Chisnall
9894ba319b5SDimitry Andric// If we are getting operator new from the MSVC CRT, then allocation overloads
9904ba319b5SDimitry Andric// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
9914ba319b5SDimitry Andric#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
992*b5893f02SDimitry Andric#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
993*b5893f02SDimitry Andric#elif defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
994*b5893f02SDimitry Andric#  define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
995*b5893f02SDimitry Andric#  if !defined(__cpp_aligned_new)
996*b5893f02SDimitry Andric     // We're defering to Microsoft's STL to provide aligned new et al. We don't
997*b5893f02SDimitry Andric     // have it unless the language feature test macro is defined.
998*b5893f02SDimitry Andric#    define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
999*b5893f02SDimitry Andric#  endif
10004ba319b5SDimitry Andric#endif
10014ba319b5SDimitry Andric
1002daf78e69SDimitry Andric#if defined(__APPLE__)
1003daf78e69SDimitry Andric#  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
1004daf78e69SDimitry Andric      defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
1005f8496407SDimitry Andric#    define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
1006daf78e69SDimitry Andric#  endif
1007daf78e69SDimitry Andric#endif // defined(__APPLE__)
1008daf78e69SDimitry Andric
10094ba319b5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
1010*b5893f02SDimitry Andric    (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
1011*b5893f02SDimitry Andric    (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
10124ba319b5SDimitry Andric#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
10134ba319b5SDimitry Andric#endif
10144ba319b5SDimitry Andric
10151bf9f7c1SDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__)
10167a984708SDavid Chisnall#define _LIBCPP_HAS_DEFAULTRUNELOCALE
10177a984708SDavid Chisnall#endif
10187a984708SDavid Chisnall
10191bf9f7c1SDimitry Andric#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
10207a984708SDavid Chisnall#define _LIBCPP_WCTYPE_IS_MASK
10217a984708SDavid Chisnall#endif
10227a984708SDavid Chisnall
1023*b5893f02SDimitry Andric#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
1024*b5893f02SDimitry Andric#define _LIBCPP_NO_HAS_CHAR8_T
1025*b5893f02SDimitry Andric#endif
1026*b5893f02SDimitry Andric
1027*b5893f02SDimitry Andric// Deprecation macros.
1028*b5893f02SDimitry Andric// Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined.
1029*b5893f02SDimitry Andric#if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS)
1030*b5893f02SDimitry Andric#  if __has_attribute(deprecated)
1031*b5893f02SDimitry Andric#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
1032*b5893f02SDimitry Andric#  elif _LIBCPP_STD_VER > 11
10334f7ab58eSDimitry Andric#    define _LIBCPP_DEPRECATED [[deprecated]]
10347a984708SDavid Chisnall#  else
10354f7ab58eSDimitry Andric#    define _LIBCPP_DEPRECATED
10364f7ab58eSDimitry Andric#  endif
1037*b5893f02SDimitry Andric#else
1038*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED
1039*b5893f02SDimitry Andric#endif
1040*b5893f02SDimitry Andric
1041*b5893f02SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG)
1042*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
1043*b5893f02SDimitry Andric#else
1044*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX11
1045*b5893f02SDimitry Andric#endif
1046*b5893f02SDimitry Andric
1047*b5893f02SDimitry Andric#if _LIBCPP_STD_VER >= 14
1048*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
1049*b5893f02SDimitry Andric#else
1050*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX14
1051*b5893f02SDimitry Andric#endif
1052*b5893f02SDimitry Andric
1053*b5893f02SDimitry Andric#if _LIBCPP_STD_VER >= 17
1054*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
1055*b5893f02SDimitry Andric#else
1056*b5893f02SDimitry Andric#  define _LIBCPP_DEPRECATED_IN_CXX17
1057*b5893f02SDimitry Andric#endif
10584f7ab58eSDimitry Andric
10594f7ab58eSDimitry Andric#if _LIBCPP_STD_VER <= 11
10604f7ab58eSDimitry Andric#  define _LIBCPP_EXPLICIT_AFTER_CXX11
10614f7ab58eSDimitry Andric#else
10624f7ab58eSDimitry Andric#  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
10634f7ab58eSDimitry Andric#endif
10644f7ab58eSDimitry Andric
1065d72607e9SDimitry Andric#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1066d72607e9SDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
1067d72607e9SDimitry Andric#else
1068d72607e9SDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX11
1069d72607e9SDimitry Andric#endif
1070d72607e9SDimitry Andric
10717c82a1ecSDimitry Andric#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
10727c82a1ecSDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
10737c82a1ecSDimitry Andric#else
10747c82a1ecSDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX14
10757c82a1ecSDimitry Andric#endif
10767c82a1ecSDimitry Andric
1077b2c7081bSDimitry Andric#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
1078b2c7081bSDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
1079b2c7081bSDimitry Andric#else
1080b2c7081bSDimitry Andric#  define _LIBCPP_CONSTEXPR_AFTER_CXX17
1081b2c7081bSDimitry Andric#endif
1082b2c7081bSDimitry Andric
1083*b5893f02SDimitry Andric// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
1084*b5893f02SDimitry Andric// NODISCARD macros to the correct attribute.
1085*b5893f02SDimitry Andric#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1086*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
1087*b5893f02SDimitry Andric#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
1088*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
1089*b5893f02SDimitry Andric#else
1090*b5893f02SDimitry Andric// We can't use GCC's [[gnu::warn_unused_result]] and
1091*b5893f02SDimitry Andric// __attribute__((warn_unused_result)), because GCC does not silence them via
1092*b5893f02SDimitry Andric// (void) cast.
1093*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_ATTRIBUTE
1094*b5893f02SDimitry Andric#endif
1095*b5893f02SDimitry Andric
1096*b5893f02SDimitry Andric// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1097*b5893f02SDimitry Andric// specified as such as an extension.
1098*b5893f02SDimitry Andric#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1099*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1100*b5893f02SDimitry Andric#else
1101*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_EXT
1102*b5893f02SDimitry Andric#endif
1103*b5893f02SDimitry Andric
1104*b5893f02SDimitry Andric#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1105*b5893f02SDimitry Andric    (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1106*b5893f02SDimitry Andric#  define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
1107b2c7081bSDimitry Andric#else
1108b2c7081bSDimitry Andric#  define _LIBCPP_NODISCARD_AFTER_CXX17
1109b2c7081bSDimitry Andric#endif
1110b2c7081bSDimitry Andric
111130785c0eSDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
111230785c0eSDimitry Andric#  define _LIBCPP_INLINE_VAR inline
111330785c0eSDimitry Andric#else
111430785c0eSDimitry Andric#  define _LIBCPP_INLINE_VAR
1115aed8d94eSDimitry Andric#endif
1116aed8d94eSDimitry Andric
11179729cf09SDimitry Andric#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
11189729cf09SDimitry Andric#  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
11199729cf09SDimitry Andric#else
11209729cf09SDimitry Andric#  define _LIBCPP_EXPLICIT_MOVE(x) (x)
11219729cf09SDimitry Andric#endif
11229729cf09SDimitry Andric
11234ba319b5SDimitry Andric#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
11244ba319b5SDimitry Andric#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
11254ba319b5SDimitry Andric#define _LIBCPP_CONSTEXPR_IF_NODEBUG
11264ba319b5SDimitry Andric#else
11274ba319b5SDimitry Andric#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
11284ba319b5SDimitry Andric#endif
11294ba319b5SDimitry Andric#endif
11304ba319b5SDimitry Andric
1131d72607e9SDimitry Andric#ifndef _LIBCPP_HAS_NO_ASAN
1132aed8d94eSDimitry Andric_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
1133d72607e9SDimitry Andric  const void *, const void *, const void *, const void *);
1134d72607e9SDimitry Andric#endif
1135d72607e9SDimitry Andric
11364f7ab58eSDimitry Andric// Try to find out if RTTI is disabled.
11374f7ab58eSDimitry Andric// g++ and cl.exe have RTTI on by default and define a macro when it is.
11384f7ab58eSDimitry Andric// g++ only defines the macro in 4.3.2 and onwards.
11394f7ab58eSDimitry Andric#if !defined(_LIBCPP_NO_RTTI)
11404ba319b5SDimitry Andric#  if defined(__GNUC__) && \
11414ba319b5SDimitry Andric      ((__GNUC__ >= 5) || \
11424ba319b5SDimitry Andric       (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \
11434ba319b5SDimitry Andric      !defined(__GXX_RTTI)
11444f7ab58eSDimitry Andric#    define _LIBCPP_NO_RTTI
11455517e702SDimitry Andric#  elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
11464f7ab58eSDimitry Andric#    define _LIBCPP_NO_RTTI
11474f7ab58eSDimitry Andric#  endif
11484f7ab58eSDimitry Andric#endif
11494f7ab58eSDimitry Andric
11504f7ab58eSDimitry Andric#ifndef _LIBCPP_WEAK
11514f7ab58eSDimitry Andric#define _LIBCPP_WEAK __attribute__((__weak__))
11527a984708SDavid Chisnall#endif
11537a984708SDavid Chisnall
11547c82a1ecSDimitry Andric// Thread API
1155aed8d94eSDimitry Andric#if !defined(_LIBCPP_HAS_NO_THREADS) && \
1156540d2a8bSDimitry Andric    !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
11575517e702SDimitry Andric    !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
1158540d2a8bSDimitry Andric    !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
11597c82a1ecSDimitry Andric#  if defined(__FreeBSD__) || \
1160aed8d94eSDimitry Andric      defined(__Fuchsia__) || \
11617c82a1ecSDimitry Andric      defined(__NetBSD__) || \
11627c82a1ecSDimitry Andric      defined(__linux__) || \
1163*b5893f02SDimitry Andric      defined(__GNU__) || \
11647c82a1ecSDimitry Andric      defined(__APPLE__) || \
11657c82a1ecSDimitry Andric      defined(__CloudABI__) || \
11665517e702SDimitry Andric      defined(__sun__) || \
11674ba319b5SDimitry Andric      (defined(__MINGW32__) && __has_include(<pthread.h>))
11687c82a1ecSDimitry Andric#    define _LIBCPP_HAS_THREAD_API_PTHREAD
116980779b37SDimitry Andric#  elif defined(_LIBCPP_WIN32API)
117080779b37SDimitry Andric#    define _LIBCPP_HAS_THREAD_API_WIN32
11717c82a1ecSDimitry Andric#  else
11727c82a1ecSDimitry Andric#    error "No thread API"
11737c82a1ecSDimitry Andric#  endif // _LIBCPP_HAS_THREAD_API
11747c82a1ecSDimitry Andric#endif // _LIBCPP_HAS_NO_THREADS
11757c82a1ecSDimitry Andric
11767c82a1ecSDimitry Andric#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
11777c82a1ecSDimitry Andric#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
11787c82a1ecSDimitry Andric       _LIBCPP_HAS_NO_THREADS is not defined.
11797c82a1ecSDimitry Andric#endif
11807c82a1ecSDimitry Andric
1181aed8d94eSDimitry Andric#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
1182540d2a8bSDimitry Andric#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1183aed8d94eSDimitry Andric       _LIBCPP_HAS_NO_THREADS is defined.
1184aed8d94eSDimitry Andric#endif
1185aed8d94eSDimitry Andric
1186d72607e9SDimitry Andric#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
1187d72607e9SDimitry Andric#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1188d72607e9SDimitry Andric       _LIBCPP_HAS_NO_THREADS is defined.
1189d72607e9SDimitry Andric#endif
1190d72607e9SDimitry Andric
1191854fa44bSDimitry Andric// Systems that use capability-based security (FreeBSD with Capsicum,
1192854fa44bSDimitry Andric// Nuxi CloudABI) may only provide local filesystem access (using *at()).
1193854fa44bSDimitry Andric// Functions like open(), rename(), unlink() and stat() should not be
1194854fa44bSDimitry Andric// used, as they attempt to access the global filesystem namespace.
1195854fa44bSDimitry Andric#ifdef __CloudABI__
1196854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1197854fa44bSDimitry Andric#endif
1198854fa44bSDimitry Andric
1199854fa44bSDimitry Andric// CloudABI is intended for running networked services. Processes do not
1200854fa44bSDimitry Andric// have standard input and output channels.
1201854fa44bSDimitry Andric#ifdef __CloudABI__
1202854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_STDIN
1203854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_STDOUT
1204854fa44bSDimitry Andric#endif
1205854fa44bSDimitry Andric
1206aed8d94eSDimitry Andric#if defined(__BIONIC__) || defined(__CloudABI__) ||                            \
1207540d2a8bSDimitry Andric    defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC)
1208854fa44bSDimitry Andric#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1209854fa44bSDimitry Andric#endif
1210854fa44bSDimitry Andric
1211aed8d94eSDimitry Andric// Thread-unsafe functions such as strtok() and localtime()
1212854fa44bSDimitry Andric// are not available.
1213854fa44bSDimitry Andric#ifdef __CloudABI__
1214854fa44bSDimitry Andric#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1215854fa44bSDimitry Andric#endif
1216854fa44bSDimitry Andric
1217540d2a8bSDimitry Andric#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
12189729cf09SDimitry Andric#  define _LIBCPP_HAS_C_ATOMIC_IMP
12199729cf09SDimitry Andric#elif _GNUC_VER > 407
12209729cf09SDimitry Andric#  define _LIBCPP_HAS_GCC_ATOMIC_IMP
12219729cf09SDimitry Andric#endif
12229729cf09SDimitry Andric
12239729cf09SDimitry Andric#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
12249729cf09SDimitry Andric     || defined(_LIBCPP_HAS_NO_THREADS)
12259729cf09SDimitry Andric#define _LIBCPP_HAS_NO_ATOMIC_HEADER
12269729cf09SDimitry Andric#endif
12279729cf09SDimitry Andric
12289729cf09SDimitry Andric#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
12299729cf09SDimitry Andric#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
12309729cf09SDimitry Andric#endif
12319729cf09SDimitry Andric
1232540d2a8bSDimitry Andric#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
1233540d2a8bSDimitry Andric#  if defined(__clang__) && __has_attribute(acquire_capability)
1234540d2a8bSDimitry Andric// Work around the attribute handling in clang.  When both __declspec and
1235540d2a8bSDimitry Andric// __attribute__ are present, the processing goes awry preventing the definition
1236540d2a8bSDimitry Andric// of the types.
1237540d2a8bSDimitry Andric#    if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
12387c82a1ecSDimitry Andric#      define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
12397c82a1ecSDimitry Andric#    endif
1240540d2a8bSDimitry Andric#  endif
1241540d2a8bSDimitry Andric#endif
12427c82a1ecSDimitry Andric
1243aed8d94eSDimitry Andric#if __has_attribute(require_constant_initialization)
1244aed8d94eSDimitry Andric#  define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
1245aed8d94eSDimitry Andric#else
1246aed8d94eSDimitry Andric#  define _LIBCPP_SAFE_STATIC
1247aed8d94eSDimitry Andric#endif
1248aed8d94eSDimitry Andric
1249aed8d94eSDimitry Andric#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
1250aed8d94eSDimitry Andric#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
1251aed8d94eSDimitry Andric#endif
1252aed8d94eSDimitry Andric
1253aed8d94eSDimitry Andric#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
1254aed8d94eSDimitry Andric#  if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1255aed8d94eSDimitry Andric#    define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1256aed8d94eSDimitry Andric#  endif
1257aed8d94eSDimitry Andric#endif
1258aed8d94eSDimitry Andric
1259540d2a8bSDimitry Andric#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1260540d2a8bSDimitry Andric#  define _LIBCPP_DIAGNOSE_WARNING(...) \
1261540d2a8bSDimitry Andric     __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1262540d2a8bSDimitry Andric#  define _LIBCPP_DIAGNOSE_ERROR(...) \
1263540d2a8bSDimitry Andric     __attribute__((diagnose_if(__VA_ARGS__, "error")))
1264540d2a8bSDimitry Andric#else
1265540d2a8bSDimitry Andric#  define _LIBCPP_DIAGNOSE_WARNING(...)
1266540d2a8bSDimitry Andric#  define _LIBCPP_DIAGNOSE_ERROR(...)
1267540d2a8bSDimitry Andric#endif
1268540d2a8bSDimitry Andric
12690f5676f4SDimitry Andric// Use a function like macro to imply that it must be followed by a semicolon
1270*b5893f02SDimitry Andric#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1271*b5893f02SDimitry Andric#  define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1272*b5893f02SDimitry Andric#elif __has_cpp_attribute(clang::fallthrough)
1273*b5893f02SDimitry Andric#  define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1274*b5893f02SDimitry Andric#elif __has_attribute(fallthough) || _GNUC_VER >= 700
12750f5676f4SDimitry Andric#  define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
12760f5676f4SDimitry Andric#else
12770f5676f4SDimitry Andric#  define _LIBCPP_FALLTHROUGH() ((void)0)
12780f5676f4SDimitry Andric#endif
12790f5676f4SDimitry Andric
1280540d2a8bSDimitry Andric#if defined(_LIBCPP_ABI_MICROSOFT) && \
1281540d2a8bSDimitry Andric    (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1282540d2a8bSDimitry Andric#  define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1283540d2a8bSDimitry Andric#else
1284540d2a8bSDimitry Andric#  define _LIBCPP_DECLSPEC_EMPTY_BASES
1285540d2a8bSDimitry Andric#endif
1286540d2a8bSDimitry Andric
1287540d2a8bSDimitry Andric#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1288540d2a8bSDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1289540d2a8bSDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1290540d2a8bSDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1291540d2a8bSDimitry Andric#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1292540d2a8bSDimitry Andric#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1293540d2a8bSDimitry Andric
1294540d2a8bSDimitry Andric#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
1295540d2a8bSDimitry Andric#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1296540d2a8bSDimitry Andric#endif
1297540d2a8bSDimitry Andric
1298540d2a8bSDimitry Andric#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
1299540d2a8bSDimitry Andric#define _LIBCPP_HAS_NO_IS_AGGREGATE
1300540d2a8bSDimitry Andric#endif
1301540d2a8bSDimitry Andric
1302302affcbSDimitry Andric#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
1303302affcbSDimitry Andric#define _LIBCPP_HAS_NO_COROUTINES
1304302affcbSDimitry Andric#endif
1305302affcbSDimitry Andric
13064ba319b5SDimitry Andric// FIXME: Correct this macro when either (A) a feature test macro for the
13074ba319b5SDimitry Andric// spaceship operator is provided, or (B) a compiler provides a complete
13084ba319b5SDimitry Andric// implementation.
13094ba319b5SDimitry Andric#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
13104ba319b5SDimitry Andric
13110f5676f4SDimitry Andric// Decide whether to use availability macros.
13120f5676f4SDimitry Andric#if !defined(_LIBCPP_BUILDING_LIBRARY) &&                                      \
13130f5676f4SDimitry Andric    !defined(_LIBCPP_DISABLE_AVAILABILITY) &&                                  \
13140f5676f4SDimitry Andric    __has_feature(attribute_availability_with_strict) &&                       \
13150f5676f4SDimitry Andric    __has_feature(attribute_availability_in_templates)
13160f5676f4SDimitry Andric#  ifdef __APPLE__
13170f5676f4SDimitry Andric#    define _LIBCPP_USE_AVAILABILITY_APPLE
13180f5676f4SDimitry Andric#  endif
13190f5676f4SDimitry Andric#endif
13200f5676f4SDimitry Andric
13210f5676f4SDimitry Andric// Define availability macros.
13220f5676f4SDimitry Andric#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
13230f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_SHARED_MUTEX                                    \
13240f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.12)))             \
13250f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=10.0)))                 \
13260f5676f4SDimitry Andric     __attribute__((availability(tvos,strict,introduced=10.0)))                \
13270f5676f4SDimitry Andric     __attribute__((availability(watchos,strict,introduced=3.0)))
1328*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS                             \
1329*b5893f02SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.14)))             \
1330*b5893f02SDimitry Andric     __attribute__((availability(ios,strict,introduced=12.0)))                 \
1331*b5893f02SDimitry Andric     __attribute__((availability(tvos,strict,introduced=12.0)))                \
1332*b5893f02SDimitry Andric     __attribute__((availability(watchos,strict,introduced=5.0)))
1333*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS                              \
1334*b5893f02SDimitry Andric     _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1335*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_ANY_CAST                                    \
1336*b5893f02SDimitry Andric     _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
13370f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS                             \
13380f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.12)))             \
13390f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=10.0)))                 \
13400f5676f4SDimitry Andric     __attribute__((availability(tvos,strict,introduced=10.0)))                \
13410f5676f4SDimitry Andric     __attribute__((availability(watchos,strict,introduced=3.0)))
13420f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE                                \
13430f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.12)))             \
13440f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=10.0)))                 \
13450f5676f4SDimitry Andric     __attribute__((availability(tvos,strict,introduced=10.0)))                \
13460f5676f4SDimitry Andric     __attribute__((availability(watchos,strict,introduced=3.0)))
13470f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_FUTURE_ERROR                                    \
13480f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=6.0)))
13490f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE                                 \
13500f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.9)))              \
13510f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=7.0)))
13520f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY                                 \
13530f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.9)))              \
13540f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=7.0)))
13550f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR                               \
13560f5676f4SDimitry Andric     __attribute__((availability(macosx,strict,introduced=10.9)))              \
13570f5676f4SDimitry Andric     __attribute__((availability(ios,strict,introduced=7.0)))
13580f5676f4SDimitry Andric#else
13590f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_SHARED_MUTEX
1360*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
13610f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1362edd7eaddSDimitry Andric#  define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
13630f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
13640f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
13650f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_FUTURE_ERROR
13660f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
13670f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
13680f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
13690f5676f4SDimitry Andric#endif
13700f5676f4SDimitry Andric
13710f5676f4SDimitry Andric// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
13720f5676f4SDimitry Andric#ifdef _LIBCPP_NO_EXCEPTIONS
13730f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_FUTURE
1374edd7eaddSDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
1375*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1376*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
13770f5676f4SDimitry Andric#else
13780f5676f4SDimitry Andric#  define _LIBCPP_AVAILABILITY_FUTURE                    _LIBCPP_AVAILABILITY_FUTURE_ERROR
1379*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST        _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1380*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1381*b5893f02SDimitry Andric#  define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS  _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
13820f5676f4SDimitry Andric#endif
13830f5676f4SDimitry Andric
1384*b5893f02SDimitry Andric// The stream API was dropped and re-added in the dylib shipped on macOS
1385*b5893f02SDimitry Andric// and iOS. We can only assume the dylib to provide these definitions for
1386*b5893f02SDimitry Andric// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
1387*b5893f02SDimitry Andric// from the headers, but not from the dylib. Explicit instantiation
1388*b5893f02SDimitry Andric// declarations for streams exist conditionally to this; if we provide
1389*b5893f02SDimitry Andric// an explicit instantiation declaration and we try to deploy to a dylib
1390*b5893f02SDimitry Andric// that does not provide those symbols, we'll get a load-time error.
1391*b5893f02SDimitry Andric#if !defined(_LIBCPP_BUILDING_LIBRARY) &&                                      \
13920f5676f4SDimitry Andric    ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                \
1393edd7eaddSDimitry Andric      __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) ||                 \
13940f5676f4SDimitry Andric     (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) &&               \
1395edd7eaddSDimitry Andric      __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
1396*b5893f02SDimitry Andric#  define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
13970f5676f4SDimitry Andric#endif
13980f5676f4SDimitry Andric
1399f9448bf3SDimitry Andric#if defined(_LIBCPP_COMPILER_IBM)
1400f9448bf3SDimitry Andric#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1401f9448bf3SDimitry Andric#endif
1402f9448bf3SDimitry Andric
1403f9448bf3SDimitry Andric#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1404f9448bf3SDimitry Andric#  define _LIBCPP_PUSH_MACROS
1405f9448bf3SDimitry Andric#  define _LIBCPP_POP_MACROS
1406f9448bf3SDimitry Andric#else
1407f9448bf3SDimitry Andric  // Don't warn about macro conflicts when we can restore them at the
1408f9448bf3SDimitry Andric  // end of the header.
1409f9448bf3SDimitry Andric#  ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1410f9448bf3SDimitry Andric#    define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1411f9448bf3SDimitry Andric#  endif
1412f9448bf3SDimitry Andric#  if defined(_LIBCPP_COMPILER_MSVC)
1413f9448bf3SDimitry Andric#    define _LIBCPP_PUSH_MACROS    \
1414f9448bf3SDimitry Andric       __pragma(push_macro("min")) \
1415f9448bf3SDimitry Andric       __pragma(push_macro("max"))
1416f9448bf3SDimitry Andric#    define _LIBCPP_POP_MACROS     \
1417f9448bf3SDimitry Andric       __pragma(pop_macro("min"))  \
1418f9448bf3SDimitry Andric       __pragma(pop_macro("max"))
1419f9448bf3SDimitry Andric#  else
1420f9448bf3SDimitry Andric#    define _LIBCPP_PUSH_MACROS        \
1421f9448bf3SDimitry Andric       _Pragma("push_macro(\"min\")")  \
1422f9448bf3SDimitry Andric       _Pragma("push_macro(\"max\")")
1423f9448bf3SDimitry Andric#    define _LIBCPP_POP_MACROS         \
1424f9448bf3SDimitry Andric       _Pragma("pop_macro(\"min\")")   \
1425f9448bf3SDimitry Andric       _Pragma("pop_macro(\"max\")")
1426f9448bf3SDimitry Andric#  endif
1427f9448bf3SDimitry Andric#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1428f9448bf3SDimitry Andric
14294ba319b5SDimitry Andric#ifndef _LIBCPP_NO_AUTO_LINK
1430b2c7081bSDimitry Andric#  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1431b2c7081bSDimitry Andric#    if defined(_DLL)
14324ba319b5SDimitry Andric#      pragma comment(lib, "c++.lib")
1433b2c7081bSDimitry Andric#    else
14344ba319b5SDimitry Andric#      pragma comment(lib, "libc++.lib")
1435b2c7081bSDimitry Andric#    endif
1436b2c7081bSDimitry Andric#  endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
14374ba319b5SDimitry Andric#endif // _LIBCPP_NO_AUTO_LINK
143824d58133SDimitry Andric
1439*b5893f02SDimitry Andric#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1440*b5893f02SDimitry Andric
144124d58133SDimitry Andric#endif // __cplusplus
144224d58133SDimitry Andric
14437a984708SDavid Chisnall#endif // _LIBCPP_CONFIG
1444