blob: 61ca5447976ab3fd887129b0816f449f1380aac6 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- __config ---------------------------------===//
3//
Chandler Carruth7c3769d2019-01-19 10:56:40 +00004// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CONFIG
11#define _LIBCPP_CONFIG
12
Eric Fiselier38e7a302015-11-06 06:30:12 +000013#if defined(_MSC_VER) && !defined(__clang__)
Logan Chien71028922018-02-24 07:57:32 +000014# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# endif
Saleem Abdulrasoolbc116592017-01-29 18:16:33 +000017#endif
Eric Fiselier38e7a302015-11-06 06:30:12 +000018
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000021#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022
Eric Fiselier38e7a302015-11-06 06:30:12 +000023#ifdef __cplusplus
24
Howard Hinnant75536ba2012-10-03 20:48:05 +000025#ifdef __GNUC__
Logan Chien71028922018-02-24 07:57:32 +000026# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
Eric Fiselier7b41c792017-04-12 23:08:46 +000027// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
28// introduced in GCC 5.0.
Logan Chien71028922018-02-24 07:57:32 +000029# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
Eric Fiseliereeeada12015-06-13 02:18:44 +000030#else
Logan Chien71028922018-02-24 07:57:32 +000031# define _GNUC_VER 0
32# define _GNUC_VER_NEW 0
Howard Hinnant75536ba2012-10-03 20:48:05 +000033#endif
34
Hans Wennborg548f2e82019-07-18 11:51:05 +000035#define _LIBCPP_VERSION 10000
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000036
Eric Fiselierde635b62019-06-26 00:05:14 +000037#ifndef _LIBCPP_ABI_VERSION
38# define _LIBCPP_ABI_VERSION 1
39#endif
40
Davide Italianoa0112222019-03-05 18:40:49 +000041#ifndef __STDC_HOSTED__
42# define _LIBCPP_FREESTANDING
43#endif
44
Eric Fiseliera0866c52018-07-27 03:07:09 +000045#ifndef _LIBCPP_STD_VER
46# if __cplusplus <= 201103L
47# define _LIBCPP_STD_VER 11
48# elif __cplusplus <= 201402L
49# define _LIBCPP_STD_VER 14
50# elif __cplusplus <= 201703L
51# define _LIBCPP_STD_VER 17
52# else
53# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
54# endif
55#endif // _LIBCPP_STD_VER
56
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +000057#if defined(__ELF__)
Logan Chien71028922018-02-24 07:57:32 +000058# define _LIBCPP_OBJECT_FORMAT_ELF 1
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +000059#elif defined(__MACH__)
Logan Chien71028922018-02-24 07:57:32 +000060# define _LIBCPP_OBJECT_FORMAT_MACHO 1
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +000061#elif defined(_WIN32)
Logan Chien71028922018-02-24 07:57:32 +000062# define _LIBCPP_OBJECT_FORMAT_COFF 1
Sam Clegg5638e7b2017-12-16 18:59:50 +000063#elif defined(__wasm__)
Logan Chien71028922018-02-24 07:57:32 +000064# define _LIBCPP_OBJECT_FORMAT_WASM 1
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +000065#else
Logan Chien71028922018-02-24 07:57:32 +000066# error Unknown object file format
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +000067#endif
68
Eric Fiselierde635b62019-06-26 00:05:14 +000069#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
Shoaib Meenaib6b8e1e2016-09-12 20:14:44 +000070// Change short string representation so that string data starts at offset 0,
Evgeniy Stepanov746572b2015-11-06 22:02:29 +000071// improving its alignment in some cases.
Logan Chien71028922018-02-24 07:57:32 +000072# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Evgeniy Stepanov746572b2015-11-06 22:02:29 +000073// Fix deque iterator type in order to support incomplete types.
Logan Chien71028922018-02-24 07:57:32 +000074# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
Nico Weberbfa81b02017-07-22 15:16:42 +000075// Fix undefined behavior in how std::list stores its linked nodes.
Logan Chien71028922018-02-24 07:57:32 +000076# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
Eric Fiselier7310ec82016-07-19 17:56:20 +000077// Fix undefined behavior in how __tree stores its end and parent nodes.
Logan Chien71028922018-02-24 07:57:32 +000078# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
Nico Weberbfa81b02017-07-22 15:16:42 +000079// Fix undefined behavior in how __hash_table stores its pointer types.
Logan Chien71028922018-02-24 07:57:32 +000080# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
81# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
82# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
Eric Fiselier7d0000f2016-12-28 11:09:18 +000083// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
Eric Fiselier8a549ab2016-12-28 09:50:23 +000084// provided under the alternate keyword __nullptr, which changes the mangling
85// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
Logan Chien71028922018-02-24 07:57:32 +000086# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
Eric Fiselier46a0c2e2017-01-05 01:15:42 +000087// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
88// instead of as a class simulating an enum. If this option is enabled
89// `pointer_safety` and `get_pointer_safety()` will no longer be available
90// in C++03.
Logan Chien71028922018-02-24 07:57:32 +000091# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
Shoaib Meenaif012f262017-03-28 19:33:31 +000092// Define a key function for `bad_function_call` in the library, to centralize
93// its vtable and typeinfo to libc++ rather than having all other libraries
94// using that class define their own copies.
Logan Chien71028922018-02-24 07:57:32 +000095# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
Aditya Kumaraa356d62017-06-14 23:17:45 +000096// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
Logan Chien71028922018-02-24 07:57:32 +000097# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
Eric Fiseliere7f8cd42017-11-19 04:19:44 +000098// Use the smallest possible integer type to represent the index of the variant.
Louis Dionne90096252019-03-20 17:05:52 +000099// Previously libc++ used "unsigned int" exclusively.
Logan Chien71028922018-02-24 07:57:32 +0000100# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
Eric Fiselierc1935f12018-12-11 00:14:34 +0000101// Unstable attempt to provide a more optimized std::function
102# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
Marshall Clowcc07c892019-03-28 17:30:23 +0000103// All the regex constants must be distinct and nonzero.
104# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
Eric Fiselierc71c3042016-07-18 01:58:37 +0000105#elif _LIBCPP_ABI_VERSION == 1
Logan Chien71028922018-02-24 07:57:32 +0000106# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
Eric Fiseliera7ae3032017-01-17 03:16:26 +0000107// Enable compiling copies of now inline methods into the dylib to support
Shoaib Meenai6d5fdc12017-04-12 19:56:37 +0000108// applications compiled against older libraries. This is unnecessary with
109// COFF dllexport semantics, since dllexport forces a non-inline definition
110// of inline functions to be emitted anyway. Our own non-inline copy would
111// conflict with the dllexport-emitted copy, so we disable it.
Logan Chien71028922018-02-24 07:57:32 +0000112# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
113# endif
Eric Fiselierc71c3042016-07-18 01:58:37 +0000114// Feature macros for disabling pre ABI v1 features. All of these options
115// are deprecated.
Logan Chien71028922018-02-24 07:57:32 +0000116# if defined(__FreeBSD__)
117# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
118# endif
Eric Fiselierc71c3042016-07-18 01:58:37 +0000119#endif
120
121#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
122#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
123 use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
Evgeniy Stepanov4f01aa82015-10-13 23:48:28 +0000124#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000125
126#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
127#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
128
Eric Fiseliere6f91d82018-10-30 21:44:53 +0000129#ifndef _LIBCPP_ABI_NAMESPACE
130# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
131#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000132
Eric Fiselier4e3e15a2016-09-25 03:34:28 +0000133#if __cplusplus < 201103L
134#define _LIBCPP_CXX03_LANG
135#endif
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000136
137#ifndef __has_attribute
138#define __has_attribute(__x) 0
139#endif
Logan Chien71028922018-02-24 07:57:32 +0000140
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000141#ifndef __has_builtin
142#define __has_builtin(__x) 0
143#endif
Logan Chien71028922018-02-24 07:57:32 +0000144
Eric Fiselier00f4a492015-08-19 17:21:46 +0000145#ifndef __has_extension
146#define __has_extension(__x) 0
147#endif
Logan Chien71028922018-02-24 07:57:32 +0000148
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000149#ifndef __has_feature
150#define __has_feature(__x) 0
151#endif
Logan Chien71028922018-02-24 07:57:32 +0000152
Marshall Clowc9f5f102017-11-14 22:26:50 +0000153#ifndef __has_cpp_attribute
154#define __has_cpp_attribute(__x) 0
155#endif
Logan Chien71028922018-02-24 07:57:32 +0000156
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000157// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
158// the compiler and '1' otherwise.
159#ifndef __is_identifier
160#define __is_identifier(__x) 1
161#endif
Logan Chien71028922018-02-24 07:57:32 +0000162
Eric Fiselier7d24e912017-01-16 21:15:08 +0000163#ifndef __has_declspec_attribute
164#define __has_declspec_attribute(__x) 0
165#endif
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000166
Eric Fiselier50ca3242017-01-14 04:27:58 +0000167#define __has_keyword(__x) !(__is_identifier(__x))
168
Alexander Richardson2be41bb2018-07-24 12:40:56 +0000169#ifndef __has_include
170#define __has_include(...) 0
Eric Fiselier2df956f2017-05-10 21:34:58 +0000171#endif
172
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000173#if defined(__clang__)
Logan Chien71028922018-02-24 07:57:32 +0000174# define _LIBCPP_COMPILER_CLANG
175# ifndef __apple_build_version__
176# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
177# endif
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000178#elif defined(__GNUC__)
Logan Chien71028922018-02-24 07:57:32 +0000179# define _LIBCPP_COMPILER_GCC
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000180#elif defined(_MSC_VER)
Logan Chien71028922018-02-24 07:57:32 +0000181# define _LIBCPP_COMPILER_MSVC
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000182#elif defined(__IBMCPP__)
Logan Chien71028922018-02-24 07:57:32 +0000183# define _LIBCPP_COMPILER_IBM
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000184#endif
185
Eric Fiseliercdb5d252017-01-23 21:41:13 +0000186#ifndef _LIBCPP_CLANG_VER
187#define _LIBCPP_CLANG_VER 0
188#endif
189
Eric Fiselierf68c6d52019-06-13 00:37:25 +0000190#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
191#error "libc++ does not support using GCC with C++03. Please enable C++11"
192#endif
193
Eric Fiselier32ff3272017-01-07 02:43:58 +0000194// FIXME: ABI detection should be done via compiler builtin macros. This
195// is just a placeholder until Clang implements such macros. For now assume
Shoaib Meenai36d0ee62017-10-04 23:44:38 +0000196// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
197// and allow the user to explicitly specify the ABI to handle cases where this
198// heuristic falls short.
Shoaib Meenai77627842017-10-05 02:18:08 +0000199#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
Logan Chien71028922018-02-24 07:57:32 +0000200# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
Shoaib Meenai77627842017-10-05 02:18:08 +0000201#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
Shoaib Meenai36d0ee62017-10-04 23:44:38 +0000202# define _LIBCPP_ABI_ITANIUM
Logan Chien71028922018-02-24 07:57:32 +0000203#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
204# define _LIBCPP_ABI_MICROSOFT
205#else
206# if defined(_WIN32) && defined(_MSC_VER)
207# define _LIBCPP_ABI_MICROSOFT
208# else
209# define _LIBCPP_ABI_ITANIUM
210# endif
Eric Fiselier32ff3272017-01-07 02:43:58 +0000211#endif
212
Eric Fiseliere718b5a2019-03-05 01:57:01 +0000213#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
214# define _LIBCPP_ABI_VCRUNTIME
215#endif
216
Dan Albert7d7f3cc2016-09-19 18:00:45 +0000217// Need to detect which libc we're using if we're on Linux.
218#if defined(__linux__)
Logan Chien71028922018-02-24 07:57:32 +0000219# include <features.h>
220# if defined(__GLIBC_PREREQ)
221# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
222# else
223# define _LIBCPP_GLIBC_PREREQ(a, b) 0
224# endif // defined(__GLIBC_PREREQ)
Dan Albert7d7f3cc2016-09-19 18:00:45 +0000225#endif // defined(__linux__)
Eric Fiselier8f7fe5c2015-07-10 20:26:38 +0000226
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000227#ifdef __LITTLE_ENDIAN__
Logan Chien71028922018-02-24 07:57:32 +0000228# if __LITTLE_ENDIAN__
229# define _LIBCPP_LITTLE_ENDIAN
230# endif // __LITTLE_ENDIAN__
Howard Hinnant324bb032010-08-22 00:02:43 +0000231#endif // __LITTLE_ENDIAN__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000232
233#ifdef __BIG_ENDIAN__
Logan Chien71028922018-02-24 07:57:32 +0000234# if __BIG_ENDIAN__
235# define _LIBCPP_BIG_ENDIAN
236# endif // __BIG_ENDIAN__
Howard Hinnant324bb032010-08-22 00:02:43 +0000237#endif // __BIG_ENDIAN__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000238
Dan Albert2897e782015-09-16 18:10:47 +0000239#ifdef __BYTE_ORDER__
Logan Chien71028922018-02-24 07:57:32 +0000240# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
241# define _LIBCPP_LITTLE_ENDIAN
242# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
243# define _LIBCPP_BIG_ENDIAN
244# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Dan Albert2897e782015-09-16 18:10:47 +0000245#endif // __BYTE_ORDER__
246
David Chisnall3e13d4f2010-08-11 16:27:20 +0000247#ifdef __FreeBSD__
Logan Chien71028922018-02-24 07:57:32 +0000248# include <sys/endian.h>
David Chisnall3e13d4f2010-08-11 16:27:20 +0000249# if _BYTE_ORDER == _LITTLE_ENDIAN
Logan Chien71028922018-02-24 07:57:32 +0000250# define _LIBCPP_LITTLE_ENDIAN
251# else // _BYTE_ORDER == _LITTLE_ENDIAN
252# define _LIBCPP_BIG_ENDIAN
253# endif // _BYTE_ORDER == _LITTLE_ENDIAN
254# ifndef __LONG_LONG_SUPPORTED
255# define _LIBCPP_HAS_NO_LONG_LONG
256# endif // __LONG_LONG_SUPPORTED
Howard Hinnant324bb032010-08-22 00:02:43 +0000257#endif // __FreeBSD__
David Chisnall3e13d4f2010-08-11 16:27:20 +0000258
Joerg Sonnenbergera71a9522013-05-17 21:17:34 +0000259#ifdef __NetBSD__
Logan Chien71028922018-02-24 07:57:32 +0000260# include <sys/endian.h>
Joerg Sonnenbergera71a9522013-05-17 21:17:34 +0000261# if _BYTE_ORDER == _LITTLE_ENDIAN
Logan Chien71028922018-02-24 07:57:32 +0000262# define _LIBCPP_LITTLE_ENDIAN
263# else // _BYTE_ORDER == _LITTLE_ENDIAN
264# define _LIBCPP_BIG_ENDIAN
265# endif // _BYTE_ORDER == _LITTLE_ENDIAN
266# define _LIBCPP_HAS_QUICK_EXIT
Joerg Sonnenbergera71a9522013-05-17 21:17:34 +0000267#endif // __NetBSD__
268
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000269#if defined(_WIN32)
Eric Fiselier7b7ac672017-05-31 22:14:05 +0000270# define _LIBCPP_WIN32API
Eric Fiselier5ccf0432017-10-17 13:16:01 +0000271# define _LIBCPP_LITTLE_ENDIAN
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000272# define _LIBCPP_SHORT_WCHAR 1
Louis Dionne90096252019-03-20 17:05:52 +0000273// Both MinGW and native MSVC provide a "MSVC"-like environment
Eric Fiselier7b7ac672017-05-31 22:14:05 +0000274# define _LIBCPP_MSVCRT_LIKE
Bruno Cardoso Lopesda4047d2017-07-17 21:52:31 +0000275// If mingw not explicitly detected, assume using MS C runtime only if
276// a MS compatibility version is specified.
277# if defined(_MSC_VER) && !defined(__MINGW32__)
Howard Hinnantef5aa932013-09-17 01:34:47 +0000278# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
279# endif
Saleem Abdulrasool5c737d82017-01-04 01:53:24 +0000280# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
281# define _LIBCPP_HAS_BITSCAN64
282# endif
Peter Collingbournef493c2f2018-01-23 02:07:27 +0000283# define _LIBCPP_HAS_OPEN_WITH_WCHAR
Logan Chien71028922018-02-24 07:57:32 +0000284# if defined(_LIBCPP_MSVCRT)
285# define _LIBCPP_HAS_QUICK_EXIT
286# endif
Shoaib Meenai9a13b432017-04-06 04:47:49 +0000287
288// Some CRT APIs are unavailable to store apps
Logan Chien71028922018-02-24 07:57:32 +0000289# if defined(WINAPI_FAMILY)
290# include <winapifamily.h>
291# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
292 (!defined(WINAPI_PARTITION_SYSTEM) || \
293 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
294# define _LIBCPP_WINDOWS_STORE_APP
295# endif
296# endif
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000297#endif // defined(_WIN32)
Howard Hinnant11a58a62011-05-13 17:16:06 +0000298
David Chisnall997e4542012-02-29 13:05:08 +0000299#ifdef __sun__
Logan Chien71028922018-02-24 07:57:32 +0000300# include <sys/isa_defs.h>
301# ifdef _LITTLE_ENDIAN
302# define _LIBCPP_LITTLE_ENDIAN
303# else
304# define _LIBCPP_BIG_ENDIAN
305# endif
David Chisnall997e4542012-02-29 13:05:08 +0000306#endif // __sun__
307
Ed Schouten63e70b62015-03-10 07:46:06 +0000308#if defined(__CloudABI__)
Logan Chien71028922018-02-24 07:57:32 +0000309 // Certain architectures provide arc4random(). Prefer using
310 // arc4random() over /dev/{u,}random to make it possible to obtain
311 // random data even when using sandboxing mechanisms such as chroots,
312 // Capsicum, etc.
313# define _LIBCPP_USING_ARC4_RANDOM
Dan Gohmand6842df2019-05-01 16:47:30 +0000314#elif defined(__Fuchsia__) || defined(__wasi__)
Logan Chien71028922018-02-24 07:57:32 +0000315# define _LIBCPP_USING_GETENTROPY
Ed Schouten63e70b62015-03-10 07:46:06 +0000316#elif defined(__native_client__)
Logan Chien71028922018-02-24 07:57:32 +0000317 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
318 // including accesses to the special files under /dev. C++11's
319 // std::random_device is instead exposed through a NaCl syscall.
320# define _LIBCPP_USING_NACL_RANDOM
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000321#elif defined(_LIBCPP_WIN32API)
Logan Chien71028922018-02-24 07:57:32 +0000322# define _LIBCPP_USING_WIN32_RANDOM
Ed Schouten63e70b62015-03-10 07:46:06 +0000323#else
Logan Chien71028922018-02-24 07:57:32 +0000324# define _LIBCPP_USING_DEV_RANDOM
Ed Schouten63e70b62015-03-10 07:46:06 +0000325#endif
JF Bastien2bd5ffd2014-12-01 19:19:55 +0000326
Eric Fiselier5ccf0432017-10-17 13:16:01 +0000327#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
Logan Chien71028922018-02-24 07:57:32 +0000328# include <endian.h>
329# if __BYTE_ORDER == __LITTLE_ENDIAN
330# define _LIBCPP_LITTLE_ENDIAN
331# elif __BYTE_ORDER == __BIG_ENDIAN
332# define _LIBCPP_BIG_ENDIAN
333# else // __BYTE_ORDER == __BIG_ENDIAN
334# error unable to determine endian
335# endif
Eric Fiselier5ccf0432017-10-17 13:16:01 +0000336#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000337
Eric Fiselier5f8e0d72017-06-15 03:50:02 +0000338#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
Logan Chien71028922018-02-24 07:57:32 +0000339# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
Evgeniy Stepanov45dca2c2016-02-10 21:53:28 +0000340#else
Logan Chien71028922018-02-24 07:57:32 +0000341# define _LIBCPP_NO_CFI
Evgeniy Stepanov45dca2c2016-02-10 21:53:28 +0000342#endif
343
Louis Dionne51a2f0c2018-08-15 00:16:41 +0000344#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
345# if defined(__FreeBSD__)
346# define _LIBCPP_HAS_QUICK_EXIT
347# define _LIBCPP_HAS_C11_FEATURES
Dan Gohmand6842df2019-05-01 16:47:30 +0000348# elif defined(__Fuchsia__) || defined(__wasi__)
Louis Dionne51a2f0c2018-08-15 00:16:41 +0000349# define _LIBCPP_HAS_QUICK_EXIT
Marshall Clow43d7c792018-08-15 21:19:08 +0000350# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne51a2f0c2018-08-15 00:16:41 +0000351# define _LIBCPP_HAS_C11_FEATURES
352# elif defined(__linux__)
353# if !defined(_LIBCPP_HAS_MUSL_LIBC)
354# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
355# define _LIBCPP_HAS_QUICK_EXIT
356# endif
357# if _LIBCPP_GLIBC_PREREQ(2, 17)
358# define _LIBCPP_HAS_C11_FEATURES
Marshall Clow43d7c792018-08-15 21:19:08 +0000359# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne51a2f0c2018-08-15 00:16:41 +0000360# endif
361# else // defined(_LIBCPP_HAS_MUSL_LIBC)
362# define _LIBCPP_HAS_QUICK_EXIT
Marshall Clow43d7c792018-08-15 21:19:08 +0000363# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne51a2f0c2018-08-15 00:16:41 +0000364# define _LIBCPP_HAS_C11_FEATURES
365# endif
366# endif // __linux__
367#endif
368
Eric Fiselier272871b2019-01-16 01:51:12 +0000369#ifndef _LIBCPP_CXX03_LANG
370# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
371#elif defined(_LIBCPP_COMPILER_CLANG)
372# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
373#else
374// This definition is potentially buggy, but it's only taken with GCC in C++03,
375// which we barely support anyway. See llvm.org/PR39713
376# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
377#endif
378
379#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
380
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000381#if defined(_LIBCPP_COMPILER_CLANG)
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000382
Evgeniy Stepanov4f01aa82015-10-13 23:48:28 +0000383// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
384// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
385#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
Mehdi Amini6dcde2c2017-04-06 01:10:22 +0000386 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \
Evgeniy Stepanov4f01aa82015-10-13 23:48:28 +0000387 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
388#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Tim Northoverc0300632014-03-30 11:34:22 +0000389#endif
390
Howard Hinnant08e17472011-10-17 20:05:10 +0000391#if __has_feature(cxx_alignas)
Howard Hinnantcbdd0892012-05-31 19:31:14 +0000392# define _ALIGNAS_TYPE(x) alignas(x)
Howard Hinnant08e17472011-10-17 20:05:10 +0000393# define _ALIGNAS(x) alignas(x)
394#else
Eric Fiselier272871b2019-01-16 01:51:12 +0000395# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnant08e17472011-10-17 20:05:10 +0000396# define _ALIGNAS(x) __attribute__((__aligned__(x)))
397#endif
398
Marshall Clow4ffb67e2014-02-22 15:13:48 +0000399#if __cplusplus < 201103L
Howard Hinnant3975ebd2010-09-16 23:27:26 +0000400typedef __char16_t char16_t;
401typedef __char32_t char32_t;
Howard Hinnant87eea6d2010-09-07 20:31:18 +0000402#endif
Howard Hinnant73d21a42010-09-04 23:28:19 +0000403
Weiming Zhao994fb962016-04-21 05:28:18 +0000404#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000405#define _LIBCPP_NO_EXCEPTIONS
406#endif
407
Eric Fiselierca57b142017-05-04 01:06:54 +0000408#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
Howard Hinnantd4444702010-08-11 17:04:31 +0000409#define _LIBCPP_NO_RTTI
410#endif
411
Howard Hinnantf6d875f2011-12-02 19:36:40 +0000412#if !(__has_feature(cxx_strong_enums))
413#define _LIBCPP_HAS_NO_STRONG_ENUMS
414#endif
415
Howard Hinnant4b7a43d2011-05-26 17:07:32 +0000416#if __has_feature(cxx_attributes)
Richard Smith0405cc42012-07-26 02:04:22 +0000417# define _LIBCPP_NORETURN [[noreturn]]
Howard Hinnant4b7a43d2011-05-26 17:07:32 +0000418#else
Richard Smith0405cc42012-07-26 02:04:22 +0000419# define _LIBCPP_NORETURN __attribute__ ((noreturn))
Howard Hinnant73d21a42010-09-04 23:28:19 +0000420#endif
421
Howard Hinnant73d21a42010-09-04 23:28:19 +0000422#if !(__has_feature(cxx_lambdas))
423#define _LIBCPP_HAS_NO_LAMBDAS
424#endif
425
426#if !(__has_feature(cxx_nullptr))
Logan Chien71028922018-02-24 07:57:32 +0000427# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
428# define nullptr __nullptr
429# else
430# define _LIBCPP_HAS_NO_NULLPTR
431# endif
Howard Hinnant73d21a42010-09-04 23:28:19 +0000432#endif
433
434#if !(__has_feature(cxx_rvalue_references))
435#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
436#endif
437
Howard Hinnant73d21a42010-09-04 23:28:19 +0000438#if !(__has_feature(cxx_auto_type))
439#define _LIBCPP_HAS_NO_AUTO_TYPE
Howard Hinnant23369ee2011-07-29 21:35:53 +0000440#endif
441
Howard Hinnant73d21a42010-09-04 23:28:19 +0000442#if !(__has_feature(cxx_variadic_templates))
443#define _LIBCPP_HAS_NO_VARIADICS
444#endif
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000445
Douglas Gregor35d2fcf2011-06-22 22:17:44 +0000446// Objective-C++ features (opt-in)
447#if __has_feature(objc_arc)
448#define _LIBCPP_HAS_OBJC_ARC
449#endif
450
451#if __has_feature(objc_arc_weak)
452#define _LIBCPP_HAS_OBJC_ARC_WEAK
453#endif
454
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000455#if !(__has_feature(cxx_relaxed_constexpr))
456#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
457#endif
458
Marshall Clow4d23cc62015-03-17 15:30:22 +0000459#if !(__has_feature(cxx_variable_templates))
460#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
461#endif
462
Eric Fiseliera3d6b122015-12-15 22:16:47 +0000463#if !(__has_feature(cxx_noexcept))
464#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnant5d37fb32011-05-11 20:19:40 +0000465#endif
466
Marshall Clow7d4d5192014-04-14 15:44:57 +0000467#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
468#define _LIBCPP_HAS_NO_ASAN
469#endif
470
Marshall Clow040a0342016-01-12 00:38:04 +0000471// Allow for build-time disabling of unsigned integer sanitization
Jonathan Roelofs90a7bf92016-01-13 23:27:08 +0000472#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
Saleem Abdulrasoolf3adaaf2016-02-09 04:05:37 +0000473#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
Logan Chien71028922018-02-24 07:57:32 +0000474#endif
Marshall Clow040a0342016-01-12 00:38:04 +0000475
Marshall Clowaa0e2362017-11-22 19:49:03 +0000476#if __has_builtin(__builtin_launder)
Marshall Clow73d6c992018-01-03 02:32:28 +0000477#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
478#endif
479
480#if !__is_identifier(__has_unique_object_representations)
481#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
Marshall Clowaa0e2362017-11-22 19:49:03 +0000482#endif
483
Louis Dionne67fff222018-07-27 12:46:03 +0000484#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
485
Marshall Clowcc5c12d2018-10-16 17:27:54 +0000486// No apple compilers support ""d and ""y at this time.
487#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
488#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
489#endif
490
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000491#elif defined(_LIBCPP_COMPILER_GCC)
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000492
Howard Hinnant08e17472011-10-17 20:05:10 +0000493#define _ALIGNAS(x) __attribute__((__aligned__(x)))
Eric Fiselier272871b2019-01-16 01:51:12 +0000494#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnant08e17472011-10-17 20:05:10 +0000495
Richard Smith0405cc42012-07-26 02:04:22 +0000496#define _LIBCPP_NORETURN __attribute__((noreturn))
Howard Hinnantc26fd802011-05-31 13:13:49 +0000497
Louis Dionnef7410f42018-08-01 13:13:14 +0000498#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000499#define _LIBCPP_NO_EXCEPTIONS
500#endif
501
Marshall Clowac042ab2015-10-20 07:37:11 +0000502// Determine if GCC supports relaxed constexpr
503#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000504#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clowac042ab2015-10-20 07:37:11 +0000505#endif
506
Richard Smithee568af2019-04-25 20:02:10 +0000507// GCC 5 supports variable templates
Eric Fiseliere39f4b92015-12-15 00:32:21 +0000508#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
Marshall Clow4d23cc62015-03-17 15:30:22 +0000509#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Eric Fiseliere39f4b92015-12-15 00:32:21 +0000510#endif
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000511
Marshall Clow7d4d5192014-04-14 15:44:57 +0000512#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
513#define _LIBCPP_HAS_NO_ASAN
514#endif
515
Marshall Clowaa0e2362017-11-22 19:49:03 +0000516#if _GNUC_VER >= 700
Marshall Clow73d6c992018-01-03 02:32:28 +0000517#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
518#endif
519
520#if _GNUC_VER >= 700
521#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
Marshall Clowaa0e2362017-11-22 19:49:03 +0000522#endif
523
Louis Dionne67fff222018-07-27 12:46:03 +0000524#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
525
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000526#elif defined(_LIBCPP_COMPILER_MSVC)
Howard Hinnant08e17472011-10-17 20:05:10 +0000527
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000528#define _LIBCPP_TOSTRING2(x) #x
529#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
530#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
531
532#if _MSC_VER < 1900
533#error "MSVC versions prior to Visual Studio 2015 are not supported"
534#endif
535
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000536#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clow4d23cc62015-03-17 15:30:22 +0000537#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnant08e17472011-10-17 20:05:10 +0000538#define __alignof__ __alignof
Richard Smith0405cc42012-07-26 02:04:22 +0000539#define _LIBCPP_NORETURN __declspec(noreturn)
Howard Hinnant08e17472011-10-17 20:05:10 +0000540#define _ALIGNAS(x) __declspec(align(x))
Eric Fiselierc0acd342018-02-07 23:50:25 +0000541#define _ALIGNAS_TYPE(x) alignas(x)
Howard Hinnant08e17472011-10-17 20:05:10 +0000542
Logan Chien71028922018-02-24 07:57:32 +0000543#define _LIBCPP_WEAK
544
Marshall Clow7d4d5192014-04-14 15:44:57 +0000545#define _LIBCPP_HAS_NO_ASAN
546
Louis Dionne67fff222018-07-27 12:46:03 +0000547#define _LIBCPP_ALWAYS_INLINE __forceinline
548
Tim Shen154f3932018-07-30 22:27:38 +0000549#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
550
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000551#elif defined(_LIBCPP_COMPILER_IBM)
Howard Hinnant7f764502013-08-14 18:00:20 +0000552
553#define _ALIGNAS(x) __attribute__((__aligned__(x)))
Eric Fiselier272871b2019-01-16 01:51:12 +0000554#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnant7f764502013-08-14 18:00:20 +0000555#define _ATTRIBUTE(x) __attribute__((x))
556#define _LIBCPP_NORETURN __attribute__((noreturn))
557
Howard Hinnant7f764502013-08-14 18:00:20 +0000558#define _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow4d23cc62015-03-17 15:30:22 +0000559#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnant7f764502013-08-14 18:00:20 +0000560
561#if defined(_AIX)
562#define __MULTILOCALE_API
563#endif
564
Marshall Clow7d4d5192014-04-14 15:44:57 +0000565#define _LIBCPP_HAS_NO_ASAN
566
Louis Dionne67fff222018-07-27 12:46:03 +0000567#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
568
Tim Shen154f3932018-07-30 22:27:38 +0000569#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
570
Eric Fiselier5170d7d2017-01-06 21:42:58 +0000571#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000572
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000573#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
Logan Chien71028922018-02-24 07:57:32 +0000574
Peter Collingbourne9c2eed82018-01-17 04:37:04 +0000575#ifdef _DLL
Logan Chien71028922018-02-24 07:57:32 +0000576# define _LIBCPP_CRT_FUNC __declspec(dllimport)
Peter Collingbourne9c2eed82018-01-17 04:37:04 +0000577#else
Logan Chien71028922018-02-24 07:57:32 +0000578# define _LIBCPP_CRT_FUNC
Peter Collingbourne9c2eed82018-01-17 04:37:04 +0000579#endif
580
Shoaib Meenaic6d8e8a2016-12-05 19:40:12 +0000581#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Logan Chien71028922018-02-24 07:57:32 +0000582# define _LIBCPP_DLL_VIS
583# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
584# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
585# define _LIBCPP_OVERRIDABLE_FUNC_VIS
Louis Dionne07f95bd2018-10-25 12:13:43 +0000586# define _LIBCPP_EXPORTED_FROM_ABI
Eric Fiselier74c98572016-09-26 22:19:41 +0000587#elif defined(_LIBCPP_BUILDING_LIBRARY)
Logan Chien71028922018-02-24 07:57:32 +0000588# define _LIBCPP_DLL_VIS __declspec(dllexport)
Martin Storsjo93c37a92019-04-25 19:46:28 +0000589# if defined(__MINGW32__)
590# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
591# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
592# else
593# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
594# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
595# endif
Logan Chien71028922018-02-24 07:57:32 +0000596# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
Louis Dionne07f95bd2018-10-25 12:13:43 +0000597# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
Eric Fiselier74c98572016-09-26 22:19:41 +0000598#else
Logan Chien71028922018-02-24 07:57:32 +0000599# define _LIBCPP_DLL_VIS __declspec(dllimport)
600# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
601# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
602# define _LIBCPP_OVERRIDABLE_FUNC_VIS
Louis Dionne07f95bd2018-10-25 12:13:43 +0000603# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
Eric Fiselier833d6442016-09-15 22:27:07 +0000604#endif
Eric Fiselier74c98572016-09-26 22:19:41 +0000605
Eric Fiselier833d6442016-09-15 22:27:07 +0000606#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
607#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
608#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
Eric Fiselier833d6442016-09-15 22:27:07 +0000609#define _LIBCPP_HIDDEN
Shoaib Meenai24e8dbd2017-03-02 03:02:50 +0000610#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
Eric Fiselierc3589a82017-01-04 23:56:00 +0000611#define _LIBCPP_TEMPLATE_VIS
Eric Fiselier833d6442016-09-15 22:27:07 +0000612#define _LIBCPP_ENUM_VIS
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000613
Saleem Abdulrasoole34f9d52017-01-03 21:53:51 +0000614#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
Eric Fiselier833d6442016-09-15 22:27:07 +0000615
616#ifndef _LIBCPP_HIDDEN
Logan Chien71028922018-02-24 07:57:32 +0000617# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
618# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
619# else
620# define _LIBCPP_HIDDEN
621# endif
Eric Fiselier833d6442016-09-15 22:27:07 +0000622#endif
623
Shoaib Meenai15da97c2017-03-09 00:18:00 +0000624#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
Logan Chien71028922018-02-24 07:57:32 +0000625# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Shoaib Meenai24e8dbd2017-03-02 03:02:50 +0000626// The inline should be removed once PR32114 is resolved
Logan Chien71028922018-02-24 07:57:32 +0000627# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
628# else
629# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
630# endif
Shoaib Meenai15da97c2017-03-09 00:18:00 +0000631#endif
Shoaib Meenai24e8dbd2017-03-02 03:02:50 +0000632
Eric Fiselier833d6442016-09-15 22:27:07 +0000633#ifndef _LIBCPP_FUNC_VIS
Logan Chien71028922018-02-24 07:57:32 +0000634# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
635# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
636# else
637# define _LIBCPP_FUNC_VIS
638# endif
Eric Fiselier833d6442016-09-15 22:27:07 +0000639#endif
640
641#ifndef _LIBCPP_TYPE_VIS
Shoaib Meenaic6d8e8a2016-12-05 19:40:12 +0000642# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Shoaib Meenai6b734922017-03-02 03:22:18 +0000643# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
Eric Fiselier833d6442016-09-15 22:27:07 +0000644# else
Shoaib Meenaic6d8e8a2016-12-05 19:40:12 +0000645# define _LIBCPP_TYPE_VIS
Eric Fiselier833d6442016-09-15 22:27:07 +0000646# endif
647#endif
648
Eric Fiselierc3589a82017-01-04 23:56:00 +0000649#ifndef _LIBCPP_TEMPLATE_VIS
Shoaib Meenai6b734922017-03-02 03:22:18 +0000650# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
651# if __has_attribute(__type_visibility__)
652# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
653# else
654# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
655# endif
656# else
657# define _LIBCPP_TEMPLATE_VIS
658# endif
Eric Fiselier833d6442016-09-15 22:27:07 +0000659#endif
660
Louis Dionne07f95bd2018-10-25 12:13:43 +0000661#ifndef _LIBCPP_EXPORTED_FROM_ABI
Thomas Andersone713cc02018-12-13 20:06:14 +0000662# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
663# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
664# else
665# define _LIBCPP_EXPORTED_FROM_ABI
666# endif
Eric Fiselierdae39602017-01-16 21:01:00 +0000667#endif
668
Shoaib Meenaie6479bc2016-11-16 22:18:10 +0000669#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
Logan Chien71028922018-02-24 07:57:32 +0000670#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
Shoaib Meenaie6479bc2016-11-16 22:18:10 +0000671#endif
672
Eric Fiselier833d6442016-09-15 22:27:07 +0000673#ifndef _LIBCPP_EXCEPTION_ABI
Logan Chien71028922018-02-24 07:57:32 +0000674# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
675# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
676# else
677# define _LIBCPP_EXCEPTION_ABI
678# endif
Eric Fiselier833d6442016-09-15 22:27:07 +0000679#endif
680
681#ifndef _LIBCPP_ENUM_VIS
Shoaib Meenaic6d8e8a2016-12-05 19:40:12 +0000682# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
Eric Fiselier833d6442016-09-15 22:27:07 +0000683# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
684# else
685# define _LIBCPP_ENUM_VIS
686# endif
687#endif
688
689#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
Shoaib Meenaic6d8e8a2016-12-05 19:40:12 +0000690# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
Shoaib Meenai24e8dbd2017-03-02 03:02:50 +0000691# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
Eric Fiselier833d6442016-09-15 22:27:07 +0000692# else
693# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
694# endif
695#endif
696
Shoaib Meenaie5cbce42016-09-19 18:29:07 +0000697#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Logan Chien71028922018-02-24 07:57:32 +0000698#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Shoaib Meenaie5cbce42016-09-19 18:29:07 +0000699#endif
700
Louis Dionne67fff222018-07-27 12:46:03 +0000701#if __has_attribute(internal_linkage)
702# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
703#else
704# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
Eric Fiselier833d6442016-09-15 22:27:07 +0000705#endif
706
Louis Dionne640fa252018-10-29 17:30:04 +0000707#if __has_attribute(exclude_from_explicit_instantiation)
708# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
709#else
710 // Try to approximate the effect of exclude_from_explicit_instantiation
711 // (which is that entities are not assumed to be provided by explicit
Louis Dionne90096252019-03-20 17:05:52 +0000712 // template instantiations in the dylib) by always inlining those entities.
Louis Dionne640fa252018-10-29 17:30:04 +0000713# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
714#endif
715
Louis Dionne61b0a002018-08-16 12:44:28 +0000716#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
717# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
718# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
719# else
720# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
721# endif
722#endif
723
Eric Fiselierbb2c95d2019-05-29 02:21:37 +0000724#ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
725# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
726# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 0
727#else
728// TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
729// And we should consider defaulting to OFF.
730# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 1
731#endif
732#endif
733
Louis Dionne67fff222018-07-27 12:46:03 +0000734#ifndef _LIBCPP_HIDE_FROM_ABI
Louis Dionne61b0a002018-08-16 12:44:28 +0000735# if _LIBCPP_HIDE_FROM_ABI_PER_TU
736# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
737# else
Louis Dionne640fa252018-10-29 17:30:04 +0000738# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
Louis Dionne61b0a002018-08-16 12:44:28 +0000739# endif
Louis Dionne67fff222018-07-27 12:46:03 +0000740#endif
741
Louis Dionne5ae92f02018-08-06 14:11:50 +0000742#ifdef _LIBCPP_BUILDING_LIBRARY
743# if _LIBCPP_ABI_VERSION > 1
744# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
Logan Chien71028922018-02-24 07:57:32 +0000745# else
Louis Dionne5ae92f02018-08-06 14:11:50 +0000746# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
Logan Chien71028922018-02-24 07:57:32 +0000747# endif
Louis Dionne5ae92f02018-08-06 14:11:50 +0000748#else
749# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
Eric Fiselier6dbed462016-09-16 00:00:48 +0000750#endif
751
Louis Dionne5ae92f02018-08-06 14:11:50 +0000752// Just so we can migrate to the new macros gradually.
753#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
Louis Dionne5ae92f02018-08-06 14:11:50 +0000754
Eric Fiselier94ce26b2018-10-30 02:02:00 +0000755// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
Eric Fiseliere6f91d82018-10-30 21:44:53 +0000756#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
Eric Fiselier94ce26b2018-10-30 02:02:00 +0000757#define _LIBCPP_END_NAMESPACE_STD } }
Eric Fiseliere6f91d82018-10-30 21:44:53 +0000758#define _VSTD std::_LIBCPP_ABI_NAMESPACE
Eric Fiselier94ce26b2018-10-30 02:02:00 +0000759_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
760
761#if _LIBCPP_STD_VER >= 17
762#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
763 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
764#else
765#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
766 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
767#endif
768
769#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
770 _LIBCPP_END_NAMESPACE_STD } }
771
772#define _VSTD_FS _VSTD::__fs::filesystem
773
Eric Fiselier833d6442016-09-15 22:27:07 +0000774#ifndef _LIBCPP_PREFERRED_OVERLOAD
775# if __has_attribute(__enable_if__)
776# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
777# endif
778#endif
779
Eric Fiseliera3d6b122015-12-15 22:16:47 +0000780#ifndef _LIBCPP_HAS_NO_NOEXCEPT
781# define _NOEXCEPT noexcept
782# define _NOEXCEPT_(x) noexcept(x)
783#else
784# define _NOEXCEPT throw()
785# define _NOEXCEPT_(x)
786#endif
787
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000788#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000789typedef unsigned short char16_t;
790typedef unsigned int char32_t;
Howard Hinnant324bb032010-08-22 00:02:43 +0000791#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000792
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +0000793#ifndef __SIZEOF_INT128__
794#define _LIBCPP_HAS_NO_INT128
795#endif
796
Eric Fiselier4e3e15a2016-09-25 03:34:28 +0000797#ifdef _LIBCPP_CXX03_LANG
Eric Fiselier1643cad2019-06-18 20:50:25 +0000798# define static_assert(...) _Static_assert(__VA_ARGS__)
799# define decltype(...) __decltype(__VA_ARGS__)
Eric Fiselier4e3e15a2016-09-25 03:34:28 +0000800#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801
Eric Fiselierbf5a8da2019-06-21 13:56:13 +0000802#ifdef _LIBCPP_CXX03_LANG
Logan Chien71028922018-02-24 07:57:32 +0000803# define _LIBCPP_CONSTEXPR
Howard Hinnant27b4fd32012-04-02 00:40:41 +0000804#else
Logan Chien71028922018-02-24 07:57:32 +0000805# define _LIBCPP_CONSTEXPR constexpr
Howard Hinnant13870382010-09-06 19:10:31 +0000806#endif
807
Eric Fiselier8c570322016-11-18 06:42:17 +0000808#ifdef _LIBCPP_CXX03_LANG
Logan Chien71028922018-02-24 07:57:32 +0000809# define _LIBCPP_DEFAULT {}
Howard Hinnant74f4da72013-05-02 20:18:43 +0000810#else
Logan Chien71028922018-02-24 07:57:32 +0000811# define _LIBCPP_DEFAULT = default;
Howard Hinnant74f4da72013-05-02 20:18:43 +0000812#endif
813
Eric Fiselier8eb066a2017-01-06 20:58:25 +0000814#ifdef _LIBCPP_CXX03_LANG
Logan Chien71028922018-02-24 07:57:32 +0000815# define _LIBCPP_EQUAL_DELETE
Eric Fiselierdb215062016-03-31 02:15:15 +0000816#else
Logan Chien71028922018-02-24 07:57:32 +0000817# define _LIBCPP_EQUAL_DELETE = delete
Eric Fiselierdb215062016-03-31 02:15:15 +0000818#endif
819
Nuno Lopes518d1502012-06-28 16:47:34 +0000820#ifdef __GNUC__
Louis Dionned772e802019-02-26 06:34:42 +0000821# define _LIBCPP_NOALIAS __attribute__((__malloc__))
Nuno Lopes518d1502012-06-28 16:47:34 +0000822#else
Louis Dionned772e802019-02-26 06:34:42 +0000823# define _LIBCPP_NOALIAS
Nuno Lopes518d1502012-06-28 16:47:34 +0000824#endif
825
Eric Fiselier1a147b72017-01-13 18:03:46 +0000826#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
Eric Fiselierbc06f262016-12-30 14:05:52 +0000827 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
Logan Chien71028922018-02-24 07:57:32 +0000828# define _LIBCPP_EXPLICIT explicit
Howard Hinnant77861882012-02-21 21:46:43 +0000829#else
Logan Chien71028922018-02-24 07:57:32 +0000830# define _LIBCPP_EXPLICIT
Howard Hinnant77861882012-02-21 21:46:43 +0000831#endif
832
Richard Smith73c1fce2014-06-04 19:54:15 +0000833#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
Logan Chien71028922018-02-24 07:57:32 +0000834#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
Richard Smith73c1fce2014-06-04 19:54:15 +0000835#endif
836
Howard Hinnantf6d875f2011-12-02 19:36:40 +0000837#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
Logan Chien71028922018-02-24 07:57:32 +0000838# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
839# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
840 __lx __v_; \
Louis Dionne54238052018-07-11 23:14:33 +0000841 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
842 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
843 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
Logan Chien71028922018-02-24 07:57:32 +0000844 };
Howard Hinnantf6d875f2011-12-02 19:36:40 +0000845#else // _LIBCPP_HAS_NO_STRONG_ENUMS
Logan Chien71028922018-02-24 07:57:32 +0000846# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
847# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
Howard Hinnantf6d875f2011-12-02 19:36:40 +0000848#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
849
Howard Hinnant5e571422013-08-23 20:10:18 +0000850#ifdef _LIBCPP_DEBUG
Logan Chien71028922018-02-24 07:57:32 +0000851# if _LIBCPP_DEBUG == 0
852# define _LIBCPP_DEBUG_LEVEL 1
853# elif _LIBCPP_DEBUG == 1
854# define _LIBCPP_DEBUG_LEVEL 2
855# else
856# error Supported values for _LIBCPP_DEBUG are 0 and 1
857# endif
858# if !defined(_LIBCPP_BUILDING_LIBRARY)
859# define _LIBCPP_EXTERN_TEMPLATE(...)
860# endif
Howard Hinnant499cea12013-08-23 17:37:05 +0000861#endif
862
Shoaib Meenaie1c9dfb2017-04-13 20:13:32 +0000863#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
864#define _LIBCPP_EXTERN_TEMPLATE(...)
865#define _LIBCPP_EXTERN_TEMPLATE2(...)
866#endif
867
Howard Hinnantff926772012-11-06 21:08:48 +0000868#ifndef _LIBCPP_EXTERN_TEMPLATE
Justin Bogner98c4e402014-08-15 17:58:56 +0000869#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
Howard Hinnantff926772012-11-06 21:08:48 +0000870#endif
871
Howard Hinnant499cea12013-08-23 17:37:05 +0000872#ifndef _LIBCPP_EXTERN_TEMPLATE2
873#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
874#endif
875
Martin Storsjo9de86592017-11-23 10:38:18 +0000876#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
Ed Schouten4c42c4e2015-03-10 09:26:38 +0000877 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
Sean Huntf3907e62011-07-15 05:40:33 +0000878#define _LIBCPP_LOCALE__L_EXTENSIONS 1
879#endif
Yaron Kerenf1ebe262013-12-20 13:19:45 +0000880
Ben Craigf8865b62016-02-10 13:47:25 +0000881#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
882// Most unix variants have catopen. These are the specific ones that don't.
Logan Chien71028922018-02-24 07:57:32 +0000883# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
884# define _LIBCPP_HAS_CATOPEN 1
885# endif
Ben Craigf8865b62016-02-10 13:47:25 +0000886#endif
Ed Schouten0251f0f2015-03-11 16:39:36 +0000887
Marshall Clow53e27632013-03-18 19:34:07 +0000888#ifdef __FreeBSD__
David Chisnall91a82722011-11-13 17:15:33 +0000889#define _DECLARE_C99_LDBL_MATH 1
890#endif
Sean Huntf3907e62011-07-15 05:40:33 +0000891
Reid Klecknerefb6d582018-04-19 22:12:10 +0000892// If we are getting operator new from the MSVC CRT, then allocation overloads
893// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
894#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
Louis Dionneae5d5c82018-12-17 22:22:44 +0000895# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
Eric Fiseliere718b5a2019-03-05 01:57:01 +0000896#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
Louis Dionne90096252019-03-20 17:05:52 +0000897 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
Thomas Andersonc79c9332019-01-30 19:08:32 +0000898 // have it unless the language feature test macro is defined.
899# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
Reid Klecknerefb6d582018-04-19 22:12:10 +0000900#endif
901
Eric Fiselierd54d9742017-01-20 01:47:26 +0000902#if defined(__APPLE__)
Logan Chien71028922018-02-24 07:57:32 +0000903# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
904 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
905# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
906# endif
Eric Fiselierd54d9742017-01-20 01:47:26 +0000907#endif // defined(__APPLE__)
908
Louis Dionne836b7e92018-08-10 13:24:56 +0000909#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
Eric Fiselier657a1302018-10-11 00:17:24 +0000910 (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
911 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
Louis Dionne836b7e92018-08-10 13:24:56 +0000912# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
913#endif
Eric Fiseliera8312872018-03-22 04:42:56 +0000914
Marshall Clow53e27632013-03-18 19:34:07 +0000915#if defined(__APPLE__) || defined(__FreeBSD__)
Howard Hinnant866569b2011-09-28 23:39:33 +0000916#define _LIBCPP_HAS_DEFAULTRUNELOCALE
Sean Hunte59f7242011-07-09 01:09:31 +0000917#endif
918
Marshall Clow53e27632013-03-18 19:34:07 +0000919#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
Sean Hunt6f0342c2011-07-09 03:40:04 +0000920#define _LIBCPP_WCTYPE_IS_MASK
921#endif
922
Marshall Clow96484472018-12-11 04:35:44 +0000923#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
924#define _LIBCPP_NO_HAS_CHAR8_T
925#endif
926
Louis Dionne13cf3b92018-09-23 18:35:00 +0000927// Deprecation macros.
Louis Dionne98076852019-03-12 20:10:06 +0000928//
929// Deprecations warnings are always enabled, except when users explicitly opt-out
930// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
931#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
Louis Dionne13cf3b92018-09-23 18:35:00 +0000932# if __has_attribute(deprecated)
933# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
934# elif _LIBCPP_STD_VER > 11
935# define _LIBCPP_DEPRECATED [[deprecated]]
936# else
937# define _LIBCPP_DEPRECATED
938# endif
Marshall Clow6db12cb2013-09-28 18:35:31 +0000939#else
Logan Chien71028922018-02-24 07:57:32 +0000940# define _LIBCPP_DEPRECATED
Marshall Clow6db12cb2013-09-28 18:35:31 +0000941#endif
942
Louis Dionne13cf3b92018-09-23 18:35:00 +0000943#if !defined(_LIBCPP_CXX03_LANG)
944# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
945#else
946# define _LIBCPP_DEPRECATED_IN_CXX11
947#endif
948
949#if _LIBCPP_STD_VER >= 14
950# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
951#else
952# define _LIBCPP_DEPRECATED_IN_CXX14
953#endif
954
955#if _LIBCPP_STD_VER >= 17
956# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
957#else
958# define _LIBCPP_DEPRECATED_IN_CXX17
959#endif
960
Marshall Clowac93d0e2013-07-15 14:57:19 +0000961#if _LIBCPP_STD_VER <= 11
Logan Chien71028922018-02-24 07:57:32 +0000962# define _LIBCPP_EXPLICIT_AFTER_CXX11
Marshall Clowac93d0e2013-07-15 14:57:19 +0000963#else
Logan Chien71028922018-02-24 07:57:32 +0000964# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
Marshall Clowac93d0e2013-07-15 14:57:19 +0000965#endif
966
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000967#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien71028922018-02-24 07:57:32 +0000968# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000969#else
Logan Chien71028922018-02-24 07:57:32 +0000970# define _LIBCPP_CONSTEXPR_AFTER_CXX11
Eric Fiselier8fcc2722014-07-17 05:16:18 +0000971#endif
972
Eric Fiselier735026e2016-03-17 03:30:56 +0000973#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien71028922018-02-24 07:57:32 +0000974# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
Eric Fiselier735026e2016-03-17 03:30:56 +0000975#else
Logan Chien71028922018-02-24 07:57:32 +0000976# define _LIBCPP_CONSTEXPR_AFTER_CXX14
Eric Fiselier735026e2016-03-17 03:30:56 +0000977#endif
978
Marshall Clowc9f5f102017-11-14 22:26:50 +0000979#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien71028922018-02-24 07:57:32 +0000980# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
Marshall Clowc9f5f102017-11-14 22:26:50 +0000981#else
Logan Chien71028922018-02-24 07:57:32 +0000982# define _LIBCPP_CONSTEXPR_AFTER_CXX17
Marshall Clowc9f5f102017-11-14 22:26:50 +0000983#endif
984
Roman Lebedevcaf40ae2018-09-22 17:54:48 +0000985// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
986// NODISCARD macros to the correct attribute.
987#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
988# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
989#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
990# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
991#else
992// We can't use GCC's [[gnu::warn_unused_result]] and
993// __attribute__((warn_unused_result)), because GCC does not silence them via
994// (void) cast.
995# define _LIBCPP_NODISCARD_ATTRIBUTE
996#endif
997
998// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
999// specified as such as an extension.
1000#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1001# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1002#else
1003# define _LIBCPP_NODISCARD_EXT
1004#endif
1005
1006#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1007 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1008# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
Marshall Clowc9f5f102017-11-14 22:26:50 +00001009#else
Logan Chien71028922018-02-24 07:57:32 +00001010# define _LIBCPP_NODISCARD_AFTER_CXX17
Marshall Clowc9f5f102017-11-14 22:26:50 +00001011#endif
1012
Marshall Clowc58e4722018-01-02 17:17:01 +00001013#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
Logan Chien71028922018-02-24 07:57:32 +00001014# define _LIBCPP_INLINE_VAR inline
Marshall Clowc58e4722018-01-02 17:17:01 +00001015#else
Logan Chien71028922018-02-24 07:57:32 +00001016# define _LIBCPP_INLINE_VAR
Eric Fiseliera93ebec2016-11-17 20:08:43 +00001017#endif
1018
Dimitry Andric89663502015-08-19 06:43:33 +00001019#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1020# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
1021#else
1022# define _LIBCPP_EXPLICIT_MOVE(x) (x)
1023#endif
1024
Marshall Clowc005c7e2018-07-13 16:35:26 +00001025#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
Marshall Clow1548d772018-07-13 17:31:36 +00001026#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Marshall Clowc005c7e2018-07-13 16:35:26 +00001027#define _LIBCPP_CONSTEXPR_IF_NODEBUG
Marshall Clowe585baf2018-07-13 17:24:59 +00001028#else
1029#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
Marshall Clowc005c7e2018-07-13 16:35:26 +00001030#endif
1031#endif
1032
Louis Dionne40056ac2019-04-17 18:20:19 +00001033#if __has_attribute(no_destroy)
1034# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1035#else
1036# define _LIBCPP_NO_DESTROY
1037#endif
1038
Marshall Clow1f50f2d2014-05-08 14:14:06 +00001039#ifndef _LIBCPP_HAS_NO_ASAN
Eric Fiselier5ac2f142016-12-23 20:03:52 +00001040_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
Marshall Clow1f50f2d2014-05-08 14:14:06 +00001041 const void *, const void *, const void *, const void *);
1042#endif
1043
Howard Hinnantf677bc42013-10-04 21:24:21 +00001044// Try to find out if RTTI is disabled.
1045// g++ and cl.exe have RTTI on by default and define a macro when it is.
1046// g++ only defines the macro in 4.3.2 and onwards.
1047#if !defined(_LIBCPP_NO_RTTI)
Logan Chien71028922018-02-24 07:57:32 +00001048# if defined(__GNUC__) && \
1049 ((__GNUC__ >= 5) || \
1050 (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \
1051 !defined(__GXX_RTTI)
Howard Hinnantf677bc42013-10-04 21:24:21 +00001052# define _LIBCPP_NO_RTTI
Eric Fiselierab2f54f2017-05-10 21:40:58 +00001053# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
Howard Hinnantf677bc42013-10-04 21:24:21 +00001054# define _LIBCPP_NO_RTTI
1055# endif
1056#endif
1057
Howard Hinnant5a8b5782013-10-04 23:56:37 +00001058#ifndef _LIBCPP_WEAK
Logan Chien71028922018-02-24 07:57:32 +00001059#define _LIBCPP_WEAK __attribute__((__weak__))
Howard Hinnant5a8b5782013-10-04 23:56:37 +00001060#endif
1061
Asiri Rathnayake35ff03b2016-05-06 14:06:29 +00001062// Thread API
Eric Fiselier1572c462017-01-06 23:15:16 +00001063#if !defined(_LIBCPP_HAS_NO_THREADS) && \
Asiri Rathnayake3f017a82017-02-27 16:10:57 +00001064 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
Eric Fiselier2df956f2017-05-10 21:34:58 +00001065 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
Asiri Rathnayake3f017a82017-02-27 16:10:57 +00001066 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
Logan Chien71028922018-02-24 07:57:32 +00001067# if defined(__FreeBSD__) || \
1068 defined(__Fuchsia__) || \
Dan Gohmand6842df2019-05-01 16:47:30 +00001069 defined(__wasi__) || \
Logan Chien71028922018-02-24 07:57:32 +00001070 defined(__NetBSD__) || \
1071 defined(__linux__) || \
Louis Dionne33f98492018-11-20 21:14:05 +00001072 defined(__GNU__) || \
Logan Chien71028922018-02-24 07:57:32 +00001073 defined(__APPLE__) || \
1074 defined(__CloudABI__) || \
1075 defined(__sun__) || \
Alexander Richardson2be41bb2018-07-24 12:40:56 +00001076 (defined(__MINGW32__) && __has_include(<pthread.h>))
Logan Chien71028922018-02-24 07:57:32 +00001077# define _LIBCPP_HAS_THREAD_API_PTHREAD
1078# elif defined(_LIBCPP_WIN32API)
1079# define _LIBCPP_HAS_THREAD_API_WIN32
1080# else
1081# error "No thread API"
1082# endif // _LIBCPP_HAS_THREAD_API
Asiri Rathnayake35ff03b2016-05-06 14:06:29 +00001083#endif // _LIBCPP_HAS_NO_THREADS
1084
Ben Craig5163e462016-05-25 17:40:09 +00001085#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
Logan Chien71028922018-02-24 07:57:32 +00001086#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1087 _LIBCPP_HAS_NO_THREADS is not defined.
Ben Craig5163e462016-05-25 17:40:09 +00001088#endif
Asiri Rathnayake35ff03b2016-05-06 14:06:29 +00001089
Asiri Rathnayake040945b2016-09-11 21:46:40 +00001090#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
Logan Chien71028922018-02-24 07:57:32 +00001091#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1092 _LIBCPP_HAS_NO_THREADS is defined.
Asiri Rathnayake040945b2016-09-11 21:46:40 +00001093#endif
1094
Eric Fiseliera245f9b2014-12-06 20:09:11 +00001095#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
Logan Chien71028922018-02-24 07:57:32 +00001096#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1097 _LIBCPP_HAS_NO_THREADS is defined.
Eric Fiseliera245f9b2014-12-06 20:09:11 +00001098#endif
1099
Eric Fiselier47e6bb82019-07-07 01:20:54 +00001100// The Apple, glibc, and Bionic implementation of pthreads implements
Eric Fiseliera3863692019-07-07 17:24:03 +00001101// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1102// mutexes have no destroy mechanism.
Eric Fiselier47e6bb82019-07-07 01:20:54 +00001103// TODO(EricWF): Enable this optimization on Apple and Bionic platforms after
1104// speaking to their respective stakeholders.
Eric Fiseliera3863692019-07-07 17:24:03 +00001105#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1106 || defined(_LIBCPP_HAS_THREAD_API_WIN32)
Eric Fiselier47e6bb82019-07-07 01:20:54 +00001107# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1108#endif
1109
Eric Fiseliera3863692019-07-07 17:24:03 +00001110// Destroying a condvar is a nop on Windows.
1111// TODO(EricWF): This is potentially true for some pthread implementations
1112// as well.
1113#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
1114# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1115#endif
1116
Ed Schoutenb33ae5b2015-03-12 15:44:39 +00001117// Systems that use capability-based security (FreeBSD with Capsicum,
1118// Nuxi CloudABI) may only provide local filesystem access (using *at()).
1119// Functions like open(), rename(), unlink() and stat() should not be
1120// used, as they attempt to access the global filesystem namespace.
1121#ifdef __CloudABI__
1122#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1123#endif
1124
Ed Schoutenabd06b42015-03-26 14:35:46 +00001125// CloudABI is intended for running networked services. Processes do not
1126// have standard input and output channels.
1127#ifdef __CloudABI__
1128#define _LIBCPP_HAS_NO_STDIN
1129#define _LIBCPP_HAS_NO_STDOUT
1130#endif
1131
Dan Albert7d7f3cc2016-09-19 18:00:45 +00001132#if defined(__BIONIC__) || defined(__CloudABI__) || \
Dan Gohmand6842df2019-05-01 16:47:30 +00001133 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
Dan Albert6272ae52015-03-11 00:51:06 +00001134#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1135#endif
1136
Ed Schouten1e17bc12016-12-30 10:44:00 +00001137// Thread-unsafe functions such as strtok() and localtime()
Ed Schouten323ade32015-06-24 08:44:38 +00001138// are not available.
1139#ifdef __CloudABI__
1140#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1141#endif
1142
Eric Fiselier50ca3242017-01-14 04:27:58 +00001143#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
Logan Chien71028922018-02-24 07:57:32 +00001144# define _LIBCPP_HAS_C_ATOMIC_IMP
Richard Smithee568af2019-04-25 20:02:10 +00001145#elif defined(_LIBCPP_COMPILER_GCC)
Logan Chien71028922018-02-24 07:57:32 +00001146# define _LIBCPP_HAS_GCC_ATOMIC_IMP
Eric Fiselier00f4a492015-08-19 17:21:46 +00001147#endif
1148
Davide Italianoa0112222019-03-05 18:40:49 +00001149#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1150 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1151 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
Eric Fiselier00f4a492015-08-19 17:21:46 +00001152 || defined(_LIBCPP_HAS_NO_THREADS)
Davide Italianoa0112222019-03-05 18:40:49 +00001153# define _LIBCPP_HAS_NO_ATOMIC_HEADER
1154#else
1155# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1156# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1157# endif
1158# ifdef _LIBCPP_FREESTANDING
1159# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1160# endif
Eric Fiselier00f4a492015-08-19 17:21:46 +00001161#endif
1162
Marshall Clow7a3731f2016-01-11 19:27:10 +00001163#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1164#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
Eric Fiselier2960ae22016-02-11 11:59:44 +00001165#endif
1166
Saleem Abdulrasool5748d2b2017-02-13 15:26:51 +00001167#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
Logan Chien71028922018-02-24 07:57:32 +00001168# if defined(__clang__) && __has_attribute(acquire_capability)
Saleem Abdulrasool5748d2b2017-02-13 15:26:51 +00001169// Work around the attribute handling in clang. When both __declspec and
1170// __attribute__ are present, the processing goes awry preventing the definition
1171// of the types.
Logan Chien71028922018-02-24 07:57:32 +00001172# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1173# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1174# endif
1175# endif
Saleem Abdulrasool5748d2b2017-02-13 15:26:51 +00001176#endif
Eric Fiseliera15e8c32016-03-16 02:30:06 +00001177
Eric Fiselier766a31a2016-09-03 00:11:33 +00001178#if __has_attribute(require_constant_initialization)
Logan Chien71028922018-02-24 07:57:32 +00001179# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
Eric Fiselier766a31a2016-09-03 00:11:33 +00001180#else
Logan Chien71028922018-02-24 07:57:32 +00001181# define _LIBCPP_SAFE_STATIC
Eric Fiselier766a31a2016-09-03 00:11:33 +00001182#endif
1183
Eric Fiselier35ce4852016-10-12 07:46:20 +00001184#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
Logan Chien71028922018-02-24 07:57:32 +00001185#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
Eric Fiselier35ce4852016-10-12 07:46:20 +00001186#endif
1187
Eric Fiselier250205c2019-04-24 17:54:25 +00001188#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
1189#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
1190#endif
1191
Shoaib Meenai3b2cf962016-10-31 15:09:10 +00001192#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
Logan Chien71028922018-02-24 07:57:32 +00001193# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1194# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1195# endif
Shoaib Meenai3b2cf962016-10-31 15:09:10 +00001196#endif
1197
Eric Fiselierebaf7da2017-01-13 22:02:08 +00001198#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
Logan Chien71028922018-02-24 07:57:32 +00001199# define _LIBCPP_DIAGNOSE_WARNING(...) \
1200 __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1201# define _LIBCPP_DIAGNOSE_ERROR(...) \
1202 __attribute__((diagnose_if(__VA_ARGS__, "error")))
Eric Fiselierebaf7da2017-01-13 22:02:08 +00001203#else
Logan Chien71028922018-02-24 07:57:32 +00001204# define _LIBCPP_DIAGNOSE_WARNING(...)
1205# define _LIBCPP_DIAGNOSE_ERROR(...)
Eric Fiselierebaf7da2017-01-13 22:02:08 +00001206#endif
1207
Eric Fiselier799d02d2017-05-05 20:32:26 +00001208// Use a function like macro to imply that it must be followed by a semicolon
Reid Kleckner6115b722018-11-01 18:24:03 +00001209#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1210# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1211#elif __has_cpp_attribute(clang::fallthrough)
1212# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1213#elif __has_attribute(fallthough) || _GNUC_VER >= 700
Logan Chien71028922018-02-24 07:57:32 +00001214# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
Eric Fiselier799d02d2017-05-05 20:32:26 +00001215#else
Logan Chien71028922018-02-24 07:57:32 +00001216# define _LIBCPP_FALLTHROUGH() ((void)0)
Eric Fiselier799d02d2017-05-05 20:32:26 +00001217#endif
1218
Eric Fiselier78822a62019-06-12 02:03:31 +00001219#if __has_attribute(__nodebug__)
1220#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
Eric Fiselier430415e2019-06-08 01:31:19 +00001221#else
1222#define _LIBCPP_NODEBUG
1223#endif
1224
Eric Fiselier78822a62019-06-12 02:03:31 +00001225#ifndef _LIBCPP_NODEBUG_TYPE
1226#if __has_attribute(__nodebug__) && \
1227 (defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 900)
1228#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1229#else
1230#define _LIBCPP_NODEBUG_TYPE
1231#endif
1232#endif // !defined(_LIBCPP_NODEBUG_TYPE)
1233
Eric Fiselier7d24e912017-01-16 21:15:08 +00001234#if defined(_LIBCPP_ABI_MICROSOFT) && \
Logan Chien71028922018-02-24 07:57:32 +00001235 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1236# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
Eric Fiselier7d24e912017-01-16 21:15:08 +00001237#else
Logan Chien71028922018-02-24 07:57:32 +00001238# define _LIBCPP_DECLSPEC_EMPTY_BASES
Eric Fiselier7d24e912017-01-16 21:15:08 +00001239#endif
1240
Eric Fiselier515ba552017-02-17 03:25:08 +00001241#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
Logan Chien71028922018-02-24 07:57:32 +00001242#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1243#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1244#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1245#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
Eric Fiselier515ba552017-02-17 03:25:08 +00001246#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1247
Marshall Clow59bcc872017-03-24 03:40:36 +00001248#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
Logan Chien71028922018-02-24 07:57:32 +00001249#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
Marshall Clow59bcc872017-03-24 03:40:36 +00001250#endif
1251
Eric Fiselier7b41c792017-04-12 23:08:46 +00001252#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
Logan Chien71028922018-02-24 07:57:32 +00001253#define _LIBCPP_HAS_NO_IS_AGGREGATE
Eric Fiselier7b41c792017-04-12 23:08:46 +00001254#endif
1255
Eric Fiselierc80ef6e2017-05-26 01:52:59 +00001256#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
Logan Chien71028922018-02-24 07:57:32 +00001257#define _LIBCPP_HAS_NO_COROUTINES
Eric Fiselierc80ef6e2017-05-26 01:52:59 +00001258#endif
1259
Eric Fiselier24258c42018-04-06 21:37:23 +00001260// FIXME: Correct this macro when either (A) a feature test macro for the
1261// spaceship operator is provided, or (B) a compiler provides a complete
1262// implementation.
1263#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1264
Mehdi Amini907c1192017-05-04 17:08:54 +00001265// Decide whether to use availability macros.
1266#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1267 !defined(_LIBCPP_DISABLE_AVAILABILITY) && \
1268 __has_feature(attribute_availability_with_strict) && \
Louis Dionne080f06d2019-03-20 21:18:14 +00001269 __has_feature(attribute_availability_in_templates) && \
1270 __has_extension(pragma_clang_attribute_external_declaration)
Logan Chien71028922018-02-24 07:57:32 +00001271# ifdef __APPLE__
1272# define _LIBCPP_USE_AVAILABILITY_APPLE
1273# endif
Mehdi Amini907c1192017-05-04 17:08:54 +00001274#endif
1275
1276// Define availability macros.
1277#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
Logan Chien71028922018-02-24 07:57:32 +00001278# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
1279 __attribute__((availability(macosx,strict,introduced=10.12))) \
1280 __attribute__((availability(ios,strict,introduced=10.0))) \
1281 __attribute__((availability(tvos,strict,introduced=10.0))) \
1282 __attribute__((availability(watchos,strict,introduced=3.0)))
Louis Dionne13b7f7b2018-11-19 15:37:04 +00001283# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
1284 __attribute__((availability(macosx,strict,introduced=10.14))) \
1285 __attribute__((availability(ios,strict,introduced=12.0))) \
1286 __attribute__((availability(tvos,strict,introduced=12.0))) \
1287 __attribute__((availability(watchos,strict,introduced=5.0)))
1288# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
1289 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Louis Dionne13b7f7b2018-11-19 15:37:04 +00001290# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
1291 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Logan Chien71028922018-02-24 07:57:32 +00001292# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
1293 __attribute__((availability(macosx,strict,introduced=10.12))) \
1294 __attribute__((availability(ios,strict,introduced=10.0))) \
1295 __attribute__((availability(tvos,strict,introduced=10.0))) \
1296 __attribute__((availability(watchos,strict,introduced=3.0)))
1297# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
1298 __attribute__((availability(macosx,strict,introduced=10.12))) \
1299 __attribute__((availability(ios,strict,introduced=10.0))) \
1300 __attribute__((availability(tvos,strict,introduced=10.0))) \
1301 __attribute__((availability(watchos,strict,introduced=3.0)))
1302# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
1303 __attribute__((availability(ios,strict,introduced=6.0)))
1304# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
1305 __attribute__((availability(macosx,strict,introduced=10.9))) \
1306 __attribute__((availability(ios,strict,introduced=7.0)))
1307# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
1308 __attribute__((availability(macosx,strict,introduced=10.9))) \
1309 __attribute__((availability(ios,strict,introduced=7.0)))
1310# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
1311 __attribute__((availability(macosx,strict,introduced=10.9))) \
1312 __attribute__((availability(ios,strict,introduced=7.0)))
Louis Dionne51ecd6c2019-03-20 14:34:00 +00001313# define _LIBCPP_AVAILABILITY_FILESYSTEM \
Louis Dionneba4d4df2019-07-03 18:29:02 +00001314 __attribute__((availability(macosx,strict,introduced=10.15))) \
1315 __attribute__((availability(ios,strict,introduced=13.0))) \
1316 __attribute__((availability(tvos,strict,introduced=13.0))) \
1317 __attribute__((availability(watchos,strict,introduced=6.0)))
Louis Dionne080f06d2019-03-20 21:18:14 +00001318# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
Louis Dionneba4d4df2019-07-03 18:29:02 +00001319 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
1320 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
1321 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
1322 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
Louis Dionne080f06d2019-03-20 21:18:14 +00001323# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
1324 _Pragma("clang attribute pop") \
1325 _Pragma("clang attribute pop") \
1326 _Pragma("clang attribute pop") \
1327 _Pragma("clang attribute pop")
Mehdi Amini907c1192017-05-04 17:08:54 +00001328#else
Logan Chien71028922018-02-24 07:57:32 +00001329# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
Louis Dionne13b7f7b2018-11-19 15:37:04 +00001330# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
Logan Chien71028922018-02-24 07:57:32 +00001331# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Logan Chien71028922018-02-24 07:57:32 +00001332# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1333# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
1334# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
1335# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
1336# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
1337# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
1338# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
Louis Dionne51ecd6c2019-03-20 14:34:00 +00001339# define _LIBCPP_AVAILABILITY_FILESYSTEM
Louis Dionne080f06d2019-03-20 21:18:14 +00001340# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
1341# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
Mehdi Amini907c1192017-05-04 17:08:54 +00001342#endif
1343
1344// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
1345#ifdef _LIBCPP_NO_EXCEPTIONS
Logan Chien71028922018-02-24 07:57:32 +00001346# define _LIBCPP_AVAILABILITY_FUTURE
1347# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
Louis Dionne13b7f7b2018-11-19 15:37:04 +00001348# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1349# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
Mehdi Amini907c1192017-05-04 17:08:54 +00001350#else
Louis Dionne7aa48782018-11-20 23:18:25 +00001351# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
1352# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1353# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1354# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
Mehdi Amini907c1192017-05-04 17:08:54 +00001355#endif
1356
Louis Dionnecaae3ec2018-12-06 00:24:58 +00001357// The stream API was dropped and re-added in the dylib shipped on macOS
1358// and iOS. We can only assume the dylib to provide these definitions for
1359// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
1360// from the headers, but not from the dylib. Explicit instantiation
1361// declarations for streams exist conditionally to this; if we provide
1362// an explicit instantiation declaration and we try to deploy to a dylib
1363// that does not provide those symbols, we'll get a load-time error.
1364#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
Mehdi Amini907c1192017-05-04 17:08:54 +00001365 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
Duncan P. N. Exon Smith2b935692017-06-18 16:50:23 +00001366 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
Mehdi Amini907c1192017-05-04 17:08:54 +00001367 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
Duncan P. N. Exon Smith2b935692017-06-18 16:50:23 +00001368 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
Louis Dionnecaae3ec2018-12-06 00:24:58 +00001369# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
Mehdi Amini907c1192017-05-04 17:08:54 +00001370#endif
1371
Eric Fiselier018a3d52017-05-31 22:07:49 +00001372#if defined(_LIBCPP_COMPILER_IBM)
1373#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1374#endif
1375
1376#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
Logan Chien71028922018-02-24 07:57:32 +00001377# define _LIBCPP_PUSH_MACROS
1378# define _LIBCPP_POP_MACROS
Eric Fiselier018a3d52017-05-31 22:07:49 +00001379#else
1380 // Don't warn about macro conflicts when we can restore them at the
1381 // end of the header.
Logan Chien71028922018-02-24 07:57:32 +00001382# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1383# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1384# endif
1385# if defined(_LIBCPP_COMPILER_MSVC)
1386# define _LIBCPP_PUSH_MACROS \
1387 __pragma(push_macro("min")) \
1388 __pragma(push_macro("max"))
1389# define _LIBCPP_POP_MACROS \
1390 __pragma(pop_macro("min")) \
1391 __pragma(pop_macro("max"))
1392# else
1393# define _LIBCPP_PUSH_MACROS \
1394 _Pragma("push_macro(\"min\")") \
1395 _Pragma("push_macro(\"max\")")
1396# define _LIBCPP_POP_MACROS \
1397 _Pragma("pop_macro(\"min\")") \
1398 _Pragma("pop_macro(\"max\")")
1399# endif
Eric Fiselier018a3d52017-05-31 22:07:49 +00001400#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1401
Peter Collingbourne1cadd882018-01-24 04:30:19 +00001402#ifndef _LIBCPP_NO_AUTO_LINK
Logan Chien71028922018-02-24 07:57:32 +00001403# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1404# if defined(_DLL)
1405# pragma comment(lib, "c++.lib")
1406# else
1407# pragma comment(lib, "libc++.lib")
1408# endif
1409# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
Peter Collingbourne1cadd882018-01-24 04:30:19 +00001410#endif // _LIBCPP_NO_AUTO_LINK
Eric Fiselier73202132017-06-16 01:57:41 +00001411
Petr Hosek7be0d092019-01-13 22:15:37 +00001412#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1413
Eric Fiselier73202132017-06-16 01:57:41 +00001414#endif // __cplusplus
1415
Eric Fiselier00f4a492015-08-19 17:21:46 +00001416#endif // _LIBCPP_CONFIG