blob: 1ae2fdc7b8108f512ef0ab7a3bcaa9b54785c87d [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- __config ---------------------------------===//
3//
Chandler Carruthd2012102019-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 Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CONFIG
11#define _LIBCPP_CONFIG
12
Eric Fiseliera80af822015-11-06 06:30:12 +000013#if defined(_MSC_VER) && !defined(__clang__)
Logan Chien7b4845e2018-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 Abdulrasoolf154c772017-01-29 18:16:33 +000017#endif
Eric Fiseliera80af822015-11-06 06:30:12 +000018
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
Howard Hinnantc51e1022010-05-11 19:42:16 +000020#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000021#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000022
Eric Fiseliera80af822015-11-06 06:30:12 +000023#ifdef __cplusplus
24
Howard Hinnantcafe7172012-10-03 20:48:05 +000025#ifdef __GNUC__
Logan Chien7b4845e2018-02-24 07:57:32 +000026# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
Eric Fiselierc9a0e822017-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 Chien7b4845e2018-02-24 07:57:32 +000029# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
Eric Fiselier7d223172015-06-13 02:18:44 +000030#else
Logan Chien7b4845e2018-02-24 07:57:32 +000031# define _GNUC_VER 0
32# define _GNUC_VER_NEW 0
Howard Hinnantcafe7172012-10-03 20:48:05 +000033#endif
34
Hans Wennborg003a9982019-07-18 11:51:05 +000035#define _LIBCPP_VERSION 10000
Howard Hinnantc51e1022010-05-11 19:42:16 +000036
Eric Fiselierfa1f1c12019-06-26 00:05:14 +000037#ifndef _LIBCPP_ABI_VERSION
38# define _LIBCPP_ABI_VERSION 1
39#endif
40
Davide Italiano011f80a2019-03-05 18:40:49 +000041#ifndef __STDC_HOSTED__
42# define _LIBCPP_FREESTANDING
43#endif
44
Eric Fiselier02cea5e2018-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 Meenai5c2d4012017-04-12 19:56:37 +000057#if defined(__ELF__)
Logan Chien7b4845e2018-02-24 07:57:32 +000058# define _LIBCPP_OBJECT_FORMAT_ELF 1
Shoaib Meenai5c2d4012017-04-12 19:56:37 +000059#elif defined(__MACH__)
Logan Chien7b4845e2018-02-24 07:57:32 +000060# define _LIBCPP_OBJECT_FORMAT_MACHO 1
Shoaib Meenai5c2d4012017-04-12 19:56:37 +000061#elif defined(_WIN32)
Logan Chien7b4845e2018-02-24 07:57:32 +000062# define _LIBCPP_OBJECT_FORMAT_COFF 1
Sam Cleggfe39b0b2017-12-16 18:59:50 +000063#elif defined(__wasm__)
Logan Chien7b4845e2018-02-24 07:57:32 +000064# define _LIBCPP_OBJECT_FORMAT_WASM 1
Shoaib Meenai5c2d4012017-04-12 19:56:37 +000065#else
Logan Chien7b4845e2018-02-24 07:57:32 +000066# error Unknown object file format
Shoaib Meenai5c2d4012017-04-12 19:56:37 +000067#endif
68
Eric Fiselierfa1f1c12019-06-26 00:05:14 +000069#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
Shoaib Meenai4bdf4372016-09-12 20:14:44 +000070// Change short string representation so that string data starts at offset 0,
Evgeniy Stepanovc299de22015-11-06 22:02:29 +000071// improving its alignment in some cases.
Logan Chien7b4845e2018-02-24 07:57:32 +000072# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Evgeniy Stepanovc299de22015-11-06 22:02:29 +000073// Fix deque iterator type in order to support incomplete types.
Logan Chien7b4845e2018-02-24 07:57:32 +000074# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
Nico Weberd31c3ab2017-07-22 15:16:42 +000075// Fix undefined behavior in how std::list stores its linked nodes.
Logan Chien7b4845e2018-02-24 07:57:32 +000076# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
Eric Fiselier70f5f872016-07-19 17:56:20 +000077// Fix undefined behavior in how __tree stores its end and parent nodes.
Logan Chien7b4845e2018-02-24 07:57:32 +000078# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
Nico Weberd31c3ab2017-07-22 15:16:42 +000079// Fix undefined behavior in how __hash_table stores its pointer types.
Logan Chien7b4845e2018-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 Fiselierf38846d2016-12-28 11:09:18 +000083// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
Eric Fiselier83e3ee02016-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 Chien7b4845e2018-02-24 07:57:32 +000086# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
Eric Fiselierab6bb302017-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 Chien7b4845e2018-02-24 07:57:32 +000091# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
Shoaib Meenaic130eaf2017-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 Chien7b4845e2018-02-24 07:57:32 +000095# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
Aditya Kumaraa866182017-06-14 23:17:45 +000096// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
Logan Chien7b4845e2018-02-24 07:57:32 +000097# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
Eric Fiseliercaccc7b2017-11-19 04:19:44 +000098// Use the smallest possible integer type to represent the index of the variant.
Louis Dionnea8548af2019-03-20 17:05:52 +000099// Previously libc++ used "unsigned int" exclusively.
Logan Chien7b4845e2018-02-24 07:57:32 +0000100# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
Eric Fiselierf2e64362018-12-11 00:14:34 +0000101// Unstable attempt to provide a more optimized std::function
102# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
Marshall Clow88a30872019-03-28 17:30:23 +0000103// All the regex constants must be distinct and nonzero.
104# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
Eric Fiselier08f7fe82016-07-18 01:58:37 +0000105#elif _LIBCPP_ABI_VERSION == 1
Logan Chien7b4845e2018-02-24 07:57:32 +0000106# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
Eric Fiselier98848572017-01-17 03:16:26 +0000107// Enable compiling copies of now inline methods into the dylib to support
Shoaib Meenai5c2d4012017-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 Chien7b4845e2018-02-24 07:57:32 +0000112# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
113# endif
Eric Fiselier08f7fe82016-07-18 01:58:37 +0000114// Feature macros for disabling pre ABI v1 features. All of these options
115// are deprecated.
Logan Chien7b4845e2018-02-24 07:57:32 +0000116# if defined(__FreeBSD__)
117# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
118# endif
Eric Fiselier08f7fe82016-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 Stepanovda2ff7e2015-10-13 23:48:28 +0000124#endif
Howard Hinnantc51e1022010-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 Fiselierb33778a2018-10-30 21:44:53 +0000129#ifndef _LIBCPP_ABI_NAMESPACE
130# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
131#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000132
Eric Fiselierc6f17cc2016-09-25 03:34:28 +0000133#if __cplusplus < 201103L
134#define _LIBCPP_CXX03_LANG
135#endif
Eric Fiselier86fcc922015-07-10 20:26:38 +0000136
137#ifndef __has_attribute
138#define __has_attribute(__x) 0
139#endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000140
Eric Fiselier86fcc922015-07-10 20:26:38 +0000141#ifndef __has_builtin
142#define __has_builtin(__x) 0
143#endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000144
Eric Fiselier8020b6c2015-08-19 17:21:46 +0000145#ifndef __has_extension
146#define __has_extension(__x) 0
147#endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000148
Eric Fiselier86fcc922015-07-10 20:26:38 +0000149#ifndef __has_feature
150#define __has_feature(__x) 0
151#endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000152
Marshall Clow2a5c4212017-11-14 22:26:50 +0000153#ifndef __has_cpp_attribute
154#define __has_cpp_attribute(__x) 0
155#endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000156
Eric Fiselier86fcc922015-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 Chien7b4845e2018-02-24 07:57:32 +0000162
Eric Fiseliere3cec5f2017-01-16 21:15:08 +0000163#ifndef __has_declspec_attribute
164#define __has_declspec_attribute(__x) 0
165#endif
Eric Fiselier86fcc922015-07-10 20:26:38 +0000166
Eric Fiselierba725072017-01-14 04:27:58 +0000167#define __has_keyword(__x) !(__is_identifier(__x))
168
Alexander Richardsonba1b59e2018-07-24 12:40:56 +0000169#ifndef __has_include
170#define __has_include(...) 0
Eric Fiselierd8a6c892017-05-10 21:34:58 +0000171#endif
172
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000173#if defined(__clang__)
Logan Chien7b4845e2018-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 Fiselier8fbccea2017-01-06 21:42:58 +0000178#elif defined(__GNUC__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000179# define _LIBCPP_COMPILER_GCC
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000180#elif defined(_MSC_VER)
Logan Chien7b4845e2018-02-24 07:57:32 +0000181# define _LIBCPP_COMPILER_MSVC
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000182#elif defined(__IBMCPP__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000183# define _LIBCPP_COMPILER_IBM
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000184#endif
185
Eric Fiselier75c05562019-06-13 00:37:25 +0000186#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
187#error "libc++ does not support using GCC with C++03. Please enable C++11"
188#endif
189
Eric Fiseliera6d96342017-01-07 02:43:58 +0000190// FIXME: ABI detection should be done via compiler builtin macros. This
191// is just a placeholder until Clang implements such macros. For now assume
Shoaib Meenai69cebe72017-10-04 23:44:38 +0000192// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
193// and allow the user to explicitly specify the ABI to handle cases where this
194// heuristic falls short.
Shoaib Meenai56943f82017-10-05 02:18:08 +0000195#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
Logan Chien7b4845e2018-02-24 07:57:32 +0000196# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
Shoaib Meenai56943f82017-10-05 02:18:08 +0000197#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
Shoaib Meenai69cebe72017-10-04 23:44:38 +0000198# define _LIBCPP_ABI_ITANIUM
Logan Chien7b4845e2018-02-24 07:57:32 +0000199#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
200# define _LIBCPP_ABI_MICROSOFT
201#else
202# if defined(_WIN32) && defined(_MSC_VER)
203# define _LIBCPP_ABI_MICROSOFT
204# else
205# define _LIBCPP_ABI_ITANIUM
206# endif
Eric Fiseliera6d96342017-01-07 02:43:58 +0000207#endif
208
Eric Fiselier85f66332019-03-05 01:57:01 +0000209#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
210# define _LIBCPP_ABI_VCRUNTIME
211#endif
212
Dan Albert21800dc2016-09-19 18:00:45 +0000213// Need to detect which libc we're using if we're on Linux.
214#if defined(__linux__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000215# include <features.h>
216# if defined(__GLIBC_PREREQ)
217# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
218# else
219# define _LIBCPP_GLIBC_PREREQ(a, b) 0
220# endif // defined(__GLIBC_PREREQ)
Dan Albert21800dc2016-09-19 18:00:45 +0000221#endif // defined(__linux__)
Eric Fiselier86fcc922015-07-10 20:26:38 +0000222
Howard Hinnantc51e1022010-05-11 19:42:16 +0000223#ifdef __LITTLE_ENDIAN__
Logan Chien7b4845e2018-02-24 07:57:32 +0000224# if __LITTLE_ENDIAN__
225# define _LIBCPP_LITTLE_ENDIAN
226# endif // __LITTLE_ENDIAN__
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000227#endif // __LITTLE_ENDIAN__
Howard Hinnantc51e1022010-05-11 19:42:16 +0000228
229#ifdef __BIG_ENDIAN__
Logan Chien7b4845e2018-02-24 07:57:32 +0000230# if __BIG_ENDIAN__
231# define _LIBCPP_BIG_ENDIAN
232# endif // __BIG_ENDIAN__
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000233#endif // __BIG_ENDIAN__
Howard Hinnantc51e1022010-05-11 19:42:16 +0000234
Dan Albert98d97792015-09-16 18:10:47 +0000235#ifdef __BYTE_ORDER__
Logan Chien7b4845e2018-02-24 07:57:32 +0000236# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
237# define _LIBCPP_LITTLE_ENDIAN
238# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
239# define _LIBCPP_BIG_ENDIAN
240# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
Dan Albert98d97792015-09-16 18:10:47 +0000241#endif // __BYTE_ORDER__
242
David Chisnall93008f02010-08-11 16:27:20 +0000243#ifdef __FreeBSD__
Logan Chien7b4845e2018-02-24 07:57:32 +0000244# include <sys/endian.h>
David Chisnall93008f02010-08-11 16:27:20 +0000245# if _BYTE_ORDER == _LITTLE_ENDIAN
Logan Chien7b4845e2018-02-24 07:57:32 +0000246# define _LIBCPP_LITTLE_ENDIAN
247# else // _BYTE_ORDER == _LITTLE_ENDIAN
248# define _LIBCPP_BIG_ENDIAN
249# endif // _BYTE_ORDER == _LITTLE_ENDIAN
250# ifndef __LONG_LONG_SUPPORTED
251# define _LIBCPP_HAS_NO_LONG_LONG
252# endif // __LONG_LONG_SUPPORTED
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000253#endif // __FreeBSD__
David Chisnall93008f02010-08-11 16:27:20 +0000254
Joerg Sonnenberger153e4162013-05-17 21:17:34 +0000255#ifdef __NetBSD__
Logan Chien7b4845e2018-02-24 07:57:32 +0000256# include <sys/endian.h>
Joerg Sonnenberger153e4162013-05-17 21:17:34 +0000257# if _BYTE_ORDER == _LITTLE_ENDIAN
Logan Chien7b4845e2018-02-24 07:57:32 +0000258# define _LIBCPP_LITTLE_ENDIAN
259# else // _BYTE_ORDER == _LITTLE_ENDIAN
260# define _LIBCPP_BIG_ENDIAN
261# endif // _BYTE_ORDER == _LITTLE_ENDIAN
262# define _LIBCPP_HAS_QUICK_EXIT
Joerg Sonnenberger153e4162013-05-17 21:17:34 +0000263#endif // __NetBSD__
264
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000265#if defined(_WIN32)
Eric Fiselierbb999f92017-05-31 22:14:05 +0000266# define _LIBCPP_WIN32API
Eric Fiseliere9cc5922017-10-17 13:16:01 +0000267# define _LIBCPP_LITTLE_ENDIAN
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000268# define _LIBCPP_SHORT_WCHAR 1
Louis Dionnea8548af2019-03-20 17:05:52 +0000269// Both MinGW and native MSVC provide a "MSVC"-like environment
Eric Fiselierbb999f92017-05-31 22:14:05 +0000270# define _LIBCPP_MSVCRT_LIKE
Bruno Cardoso Lopes91572682017-07-17 21:52:31 +0000271// If mingw not explicitly detected, assume using MS C runtime only if
272// a MS compatibility version is specified.
273# if defined(_MSC_VER) && !defined(__MINGW32__)
Howard Hinnant8ad70912013-09-17 01:34:47 +0000274# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
275# endif
Saleem Abdulrasool32300ca2017-01-04 01:53:24 +0000276# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
277# define _LIBCPP_HAS_BITSCAN64
278# endif
Peter Collingbourne63ebbd72018-01-23 02:07:27 +0000279# define _LIBCPP_HAS_OPEN_WITH_WCHAR
Logan Chien7b4845e2018-02-24 07:57:32 +0000280# if defined(_LIBCPP_MSVCRT)
281# define _LIBCPP_HAS_QUICK_EXIT
282# endif
Shoaib Meenaie2ce3602017-04-06 04:47:49 +0000283
284// Some CRT APIs are unavailable to store apps
Logan Chien7b4845e2018-02-24 07:57:32 +0000285# if defined(WINAPI_FAMILY)
286# include <winapifamily.h>
287# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
288 (!defined(WINAPI_PARTITION_SYSTEM) || \
289 !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
290# define _LIBCPP_WINDOWS_STORE_APP
291# endif
292# endif
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000293#endif // defined(_WIN32)
Howard Hinnant34bad2a2011-05-13 17:16:06 +0000294
David Chisnall8074c342012-02-29 13:05:08 +0000295#ifdef __sun__
Logan Chien7b4845e2018-02-24 07:57:32 +0000296# include <sys/isa_defs.h>
297# ifdef _LITTLE_ENDIAN
298# define _LIBCPP_LITTLE_ENDIAN
299# else
300# define _LIBCPP_BIG_ENDIAN
301# endif
David Chisnall8074c342012-02-29 13:05:08 +0000302#endif // __sun__
303
Ed Schoutendcf37402015-03-10 07:46:06 +0000304#if defined(__CloudABI__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000305 // Certain architectures provide arc4random(). Prefer using
306 // arc4random() over /dev/{u,}random to make it possible to obtain
307 // random data even when using sandboxing mechanisms such as chroots,
308 // Capsicum, etc.
309# define _LIBCPP_USING_ARC4_RANDOM
Dan Gohman280fd6b2019-05-01 16:47:30 +0000310#elif defined(__Fuchsia__) || defined(__wasi__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000311# define _LIBCPP_USING_GETENTROPY
Ed Schoutendcf37402015-03-10 07:46:06 +0000312#elif defined(__native_client__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000313 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
314 // including accesses to the special files under /dev. C++11's
315 // std::random_device is instead exposed through a NaCl syscall.
316# define _LIBCPP_USING_NACL_RANDOM
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000317#elif defined(_LIBCPP_WIN32API)
Logan Chien7b4845e2018-02-24 07:57:32 +0000318# define _LIBCPP_USING_WIN32_RANDOM
Ed Schoutendcf37402015-03-10 07:46:06 +0000319#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000320# define _LIBCPP_USING_DEV_RANDOM
Ed Schoutendcf37402015-03-10 07:46:06 +0000321#endif
JF Bastiend4832032014-12-01 19:19:55 +0000322
Eric Fiseliere9cc5922017-10-17 13:16:01 +0000323#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
Logan Chien7b4845e2018-02-24 07:57:32 +0000324# include <endian.h>
325# if __BYTE_ORDER == __LITTLE_ENDIAN
326# define _LIBCPP_LITTLE_ENDIAN
327# elif __BYTE_ORDER == __BIG_ENDIAN
328# define _LIBCPP_BIG_ENDIAN
329# else // __BYTE_ORDER == __BIG_ENDIAN
330# error unable to determine endian
331# endif
Eric Fiseliere9cc5922017-10-17 13:16:01 +0000332#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000333
Eric Fiselier02cba002017-06-15 03:50:02 +0000334#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
Logan Chien7b4845e2018-02-24 07:57:32 +0000335# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
Evgeniy Stepanov076b2372016-02-10 21:53:28 +0000336#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000337# define _LIBCPP_NO_CFI
Evgeniy Stepanov076b2372016-02-10 21:53:28 +0000338#endif
339
Louis Dionne234dd432018-08-15 00:16:41 +0000340#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
341# if defined(__FreeBSD__)
342# define _LIBCPP_HAS_QUICK_EXIT
343# define _LIBCPP_HAS_C11_FEATURES
Dan Gohman280fd6b2019-05-01 16:47:30 +0000344# elif defined(__Fuchsia__) || defined(__wasi__)
Louis Dionne234dd432018-08-15 00:16:41 +0000345# define _LIBCPP_HAS_QUICK_EXIT
Marshall Clowa6a55a82018-08-15 21:19:08 +0000346# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne234dd432018-08-15 00:16:41 +0000347# define _LIBCPP_HAS_C11_FEATURES
348# elif defined(__linux__)
349# if !defined(_LIBCPP_HAS_MUSL_LIBC)
350# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
351# define _LIBCPP_HAS_QUICK_EXIT
352# endif
353# if _LIBCPP_GLIBC_PREREQ(2, 17)
354# define _LIBCPP_HAS_C11_FEATURES
Marshall Clowa6a55a82018-08-15 21:19:08 +0000355# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne234dd432018-08-15 00:16:41 +0000356# endif
357# else // defined(_LIBCPP_HAS_MUSL_LIBC)
358# define _LIBCPP_HAS_QUICK_EXIT
Marshall Clowa6a55a82018-08-15 21:19:08 +0000359# define _LIBCPP_HAS_TIMESPEC_GET
Louis Dionne234dd432018-08-15 00:16:41 +0000360# define _LIBCPP_HAS_C11_FEATURES
361# endif
362# endif // __linux__
363#endif
364
Eric Fiselier0f0ed9d2019-01-16 01:51:12 +0000365#ifndef _LIBCPP_CXX03_LANG
366# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
367#elif defined(_LIBCPP_COMPILER_CLANG)
368# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
369#else
370// This definition is potentially buggy, but it's only taken with GCC in C++03,
371// which we barely support anyway. See llvm.org/PR39713
372# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp)
373#endif
374
375#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
376
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000377#if defined(_LIBCPP_COMPILER_CLANG)
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000378
Evgeniy Stepanovda2ff7e2015-10-13 23:48:28 +0000379// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
380// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
381#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
Mehdi Aminia807b112017-04-06 01:10:22 +0000382 (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \
Evgeniy Stepanovda2ff7e2015-10-13 23:48:28 +0000383 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
384#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Tim Northoverffc95932014-03-30 11:34:22 +0000385#endif
386
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000387#if __has_feature(cxx_alignas)
Howard Hinnant62cad692012-05-31 19:31:14 +0000388# define _ALIGNAS_TYPE(x) alignas(x)
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000389# define _ALIGNAS(x) alignas(x)
390#else
Eric Fiselier0f0ed9d2019-01-16 01:51:12 +0000391# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000392# define _ALIGNAS(x) __attribute__((__aligned__(x)))
393#endif
394
Marshall Clow2b12c312014-02-22 15:13:48 +0000395#if __cplusplus < 201103L
Howard Hinnant31cd14f2010-09-16 23:27:26 +0000396typedef __char16_t char16_t;
397typedef __char32_t char32_t;
Howard Hinnant8e6a3982010-09-07 20:31:18 +0000398#endif
Howard Hinnant74279a52010-09-04 23:28:19 +0000399
Weiming Zhao9fe43d52016-04-21 05:28:18 +0000400#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000401#define _LIBCPP_NO_EXCEPTIONS
402#endif
403
Eric Fiseliered2099d2017-05-04 01:06:54 +0000404#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
Howard Hinnant72f73582010-08-11 17:04:31 +0000405#define _LIBCPP_NO_RTTI
406#endif
407
Howard Hinnant09bc0c92011-12-02 19:36:40 +0000408#if !(__has_feature(cxx_strong_enums))
409#define _LIBCPP_HAS_NO_STRONG_ENUMS
410#endif
411
Howard Hinnant8df96292011-05-26 17:07:32 +0000412#if __has_feature(cxx_attributes)
Richard Smithcabd3922012-07-26 02:04:22 +0000413# define _LIBCPP_NORETURN [[noreturn]]
Howard Hinnant8df96292011-05-26 17:07:32 +0000414#else
Richard Smithcabd3922012-07-26 02:04:22 +0000415# define _LIBCPP_NORETURN __attribute__ ((noreturn))
Howard Hinnant74279a52010-09-04 23:28:19 +0000416#endif
417
Howard Hinnant74279a52010-09-04 23:28:19 +0000418#if !(__has_feature(cxx_lambdas))
419#define _LIBCPP_HAS_NO_LAMBDAS
420#endif
421
422#if !(__has_feature(cxx_nullptr))
Logan Chien7b4845e2018-02-24 07:57:32 +0000423# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
424# define nullptr __nullptr
425# else
426# define _LIBCPP_HAS_NO_NULLPTR
427# endif
Howard Hinnant74279a52010-09-04 23:28:19 +0000428#endif
429
430#if !(__has_feature(cxx_rvalue_references))
431#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
432#endif
433
Howard Hinnant74279a52010-09-04 23:28:19 +0000434#if !(__has_feature(cxx_auto_type))
435#define _LIBCPP_HAS_NO_AUTO_TYPE
Howard Hinnant986832c2011-07-29 21:35:53 +0000436#endif
437
Howard Hinnant74279a52010-09-04 23:28:19 +0000438#if !(__has_feature(cxx_variadic_templates))
439#define _LIBCPP_HAS_NO_VARIADICS
440#endif
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000441
Douglas Gregor13034442011-06-22 22:17:44 +0000442// Objective-C++ features (opt-in)
443#if __has_feature(objc_arc)
444#define _LIBCPP_HAS_OBJC_ARC
445#endif
446
447#if __has_feature(objc_arc_weak)
448#define _LIBCPP_HAS_OBJC_ARC_WEAK
449#endif
450
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000451#if !(__has_feature(cxx_relaxed_constexpr))
452#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
453#endif
454
Marshall Clowfaae6982015-03-17 15:30:22 +0000455#if !(__has_feature(cxx_variable_templates))
456#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
457#endif
458
Eric Fiselier1af87ca2015-12-15 22:16:47 +0000459#if !(__has_feature(cxx_noexcept))
460#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnant68d13392011-05-11 20:19:40 +0000461#endif
462
Marshall Clow90fc0472014-04-14 15:44:57 +0000463#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
464#define _LIBCPP_HAS_NO_ASAN
465#endif
466
Marshall Clow55b23d22016-01-12 00:38:04 +0000467// Allow for build-time disabling of unsigned integer sanitization
Jonathan Roelofs25463502016-01-13 23:27:08 +0000468#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
Saleem Abdulrasool38acb642016-02-09 04:05:37 +0000469#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
Logan Chien7b4845e2018-02-24 07:57:32 +0000470#endif
Marshall Clow55b23d22016-01-12 00:38:04 +0000471
Marshall Clowdf5a11f2017-11-22 19:49:03 +0000472#if __has_builtin(__builtin_launder)
Marshall Clow77342692018-01-03 02:32:28 +0000473#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
474#endif
475
476#if !__is_identifier(__has_unique_object_representations)
477#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
Marshall Clowdf5a11f2017-11-22 19:49:03 +0000478#endif
479
Louis Dionne3a197992018-07-27 12:46:03 +0000480#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
481
Louis Dionne0b9caa42019-08-14 17:04:31 +0000482// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
483#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
484 (defined(__apple_build_version__) && __apple_build_version__ < 10010000)
485#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
Marshall Clow26058352018-10-16 17:27:54 +0000486#endif
487
Louis Dionnefaa17452019-09-04 12:44:19 +0000488#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
489
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000490#elif defined(_LIBCPP_COMPILER_GCC)
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000491
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000492#define _ALIGNAS(x) __attribute__((__aligned__(x)))
Eric Fiselier0f0ed9d2019-01-16 01:51:12 +0000493#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000494
Richard Smithcabd3922012-07-26 02:04:22 +0000495#define _LIBCPP_NORETURN __attribute__((noreturn))
Howard Hinnant1e570a32011-05-31 13:13:49 +0000496
Louis Dionne9c9853b2018-08-01 13:13:14 +0000497#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000498#define _LIBCPP_NO_EXCEPTIONS
499#endif
500
Marshall Clowe2be6332015-10-20 07:37:11 +0000501// Determine if GCC supports relaxed constexpr
502#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000503#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clowe2be6332015-10-20 07:37:11 +0000504#endif
505
Richard Smithca47d0f2019-04-25 20:02:10 +0000506// GCC 5 supports variable templates
Eric Fiselier88f07122015-12-15 00:32:21 +0000507#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
Marshall Clowfaae6982015-03-17 15:30:22 +0000508#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Eric Fiselier88f07122015-12-15 00:32:21 +0000509#endif
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000510
Marshall Clow90fc0472014-04-14 15:44:57 +0000511#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
512#define _LIBCPP_HAS_NO_ASAN
513#endif
514
Marshall Clowdf5a11f2017-11-22 19:49:03 +0000515#if _GNUC_VER >= 700
Marshall Clow77342692018-01-03 02:32:28 +0000516#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
517#endif
518
519#if _GNUC_VER >= 700
520#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
Marshall Clowdf5a11f2017-11-22 19:49:03 +0000521#endif
522
Louis Dionne3a197992018-07-27 12:46:03 +0000523#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
524
Louis Dionnefaa17452019-09-04 12:44:19 +0000525#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
526
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000527#elif defined(_LIBCPP_COMPILER_MSVC)
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000528
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000529#define _LIBCPP_TOSTRING2(x) #x
530#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
531#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
532
533#if _MSC_VER < 1900
534#error "MSVC versions prior to Visual Studio 2015 are not supported"
535#endif
536
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000537#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clowfaae6982015-03-17 15:30:22 +0000538#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000539#define __alignof__ __alignof
Richard Smithcabd3922012-07-26 02:04:22 +0000540#define _LIBCPP_NORETURN __declspec(noreturn)
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000541#define _ALIGNAS(x) __declspec(align(x))
Eric Fiselier6a537582018-02-07 23:50:25 +0000542#define _ALIGNAS_TYPE(x) alignas(x)
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000543
Logan Chien7b4845e2018-02-24 07:57:32 +0000544#define _LIBCPP_WEAK
545
Marshall Clow90fc0472014-04-14 15:44:57 +0000546#define _LIBCPP_HAS_NO_ASAN
547
Louis Dionne3a197992018-07-27 12:46:03 +0000548#define _LIBCPP_ALWAYS_INLINE __forceinline
549
Tim Shend87ea292018-07-30 22:27:38 +0000550#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
551
Louis Dionnefaa17452019-09-04 12:44:19 +0000552#define _LIBCPP_DISABLE_EXTENSION_WARNING
553
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000554#elif defined(_LIBCPP_COMPILER_IBM)
Howard Hinnantea382952013-08-14 18:00:20 +0000555
556#define _ALIGNAS(x) __attribute__((__aligned__(x)))
Eric Fiselier0f0ed9d2019-01-16 01:51:12 +0000557#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
Howard Hinnantea382952013-08-14 18:00:20 +0000558#define _ATTRIBUTE(x) __attribute__((x))
559#define _LIBCPP_NORETURN __attribute__((noreturn))
560
Howard Hinnantea382952013-08-14 18:00:20 +0000561#define _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clowfaae6982015-03-17 15:30:22 +0000562#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnantea382952013-08-14 18:00:20 +0000563
564#if defined(_AIX)
565#define __MULTILOCALE_API
566#endif
567
Marshall Clow90fc0472014-04-14 15:44:57 +0000568#define _LIBCPP_HAS_NO_ASAN
569
Louis Dionne3a197992018-07-27 12:46:03 +0000570#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
571
Tim Shend87ea292018-07-30 22:27:38 +0000572#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
573
Louis Dionnefaa17452019-09-04 12:44:19 +0000574#define _LIBCPP_DISABLE_EXTENSION_WARNING
575
Eric Fiselier8fbccea2017-01-06 21:42:58 +0000576#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
Howard Hinnantc51e1022010-05-11 19:42:16 +0000577
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000578#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
Logan Chien7b4845e2018-02-24 07:57:32 +0000579
Peter Collingbourne725de942018-01-17 04:37:04 +0000580#ifdef _DLL
Logan Chien7b4845e2018-02-24 07:57:32 +0000581# define _LIBCPP_CRT_FUNC __declspec(dllimport)
Peter Collingbourne725de942018-01-17 04:37:04 +0000582#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000583# define _LIBCPP_CRT_FUNC
Peter Collingbourne725de942018-01-17 04:37:04 +0000584#endif
585
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000586#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Logan Chien7b4845e2018-02-24 07:57:32 +0000587# define _LIBCPP_DLL_VIS
588# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
589# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
590# define _LIBCPP_OVERRIDABLE_FUNC_VIS
Louis Dionne5254b372018-10-25 12:13:43 +0000591# define _LIBCPP_EXPORTED_FROM_ABI
Eric Fiselier51e8d2f2016-09-26 22:19:41 +0000592#elif defined(_LIBCPP_BUILDING_LIBRARY)
Logan Chien7b4845e2018-02-24 07:57:32 +0000593# define _LIBCPP_DLL_VIS __declspec(dllexport)
Martin Storsjobd254492019-04-25 19:46:28 +0000594# if defined(__MINGW32__)
595# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
596# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
597# else
598# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
599# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
600# endif
Logan Chien7b4845e2018-02-24 07:57:32 +0000601# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
Louis Dionne5254b372018-10-25 12:13:43 +0000602# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
Eric Fiselier51e8d2f2016-09-26 22:19:41 +0000603#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000604# define _LIBCPP_DLL_VIS __declspec(dllimport)
605# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
606# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
607# define _LIBCPP_OVERRIDABLE_FUNC_VIS
Louis Dionne5254b372018-10-25 12:13:43 +0000608# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000609#endif
Eric Fiselier51e8d2f2016-09-26 22:19:41 +0000610
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000611#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
612#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
613#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000614#define _LIBCPP_HIDDEN
Shoaib Meenai69c57412017-03-02 03:02:50 +0000615#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000616#define _LIBCPP_TEMPLATE_VIS
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000617#define _LIBCPP_ENUM_VIS
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000618
Saleem Abdulrasoolee302e42017-01-03 21:53:51 +0000619#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000620
621#ifndef _LIBCPP_HIDDEN
Logan Chien7b4845e2018-02-24 07:57:32 +0000622# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
623# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
624# else
625# define _LIBCPP_HIDDEN
626# endif
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000627#endif
628
Shoaib Meenai5331f492017-03-09 00:18:00 +0000629#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
Logan Chien7b4845e2018-02-24 07:57:32 +0000630# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Shoaib Meenai69c57412017-03-02 03:02:50 +0000631// The inline should be removed once PR32114 is resolved
Logan Chien7b4845e2018-02-24 07:57:32 +0000632# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
633# else
634# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
635# endif
Shoaib Meenai5331f492017-03-09 00:18:00 +0000636#endif
Shoaib Meenai69c57412017-03-02 03:02:50 +0000637
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000638#ifndef _LIBCPP_FUNC_VIS
Logan Chien7b4845e2018-02-24 07:57:32 +0000639# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
640# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
641# else
642# define _LIBCPP_FUNC_VIS
643# endif
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000644#endif
645
646#ifndef _LIBCPP_TYPE_VIS
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000647# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Shoaib Meenai55f3a462017-03-02 03:22:18 +0000648# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000649# else
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000650# define _LIBCPP_TYPE_VIS
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000651# endif
652#endif
653
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000654#ifndef _LIBCPP_TEMPLATE_VIS
Shoaib Meenai55f3a462017-03-02 03:22:18 +0000655# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
656# if __has_attribute(__type_visibility__)
657# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
658# else
659# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
660# endif
661# else
662# define _LIBCPP_TEMPLATE_VIS
663# endif
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000664#endif
665
Louis Dionne5254b372018-10-25 12:13:43 +0000666#ifndef _LIBCPP_EXPORTED_FROM_ABI
Thomas Andersone13df2b2018-12-13 20:06:14 +0000667# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
668# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
669# else
670# define _LIBCPP_EXPORTED_FROM_ABI
671# endif
Eric Fiselier99505072017-01-16 21:01:00 +0000672#endif
673
Shoaib Meenai2d71db42016-11-16 22:18:10 +0000674#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
Logan Chien7b4845e2018-02-24 07:57:32 +0000675#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
Shoaib Meenai2d71db42016-11-16 22:18:10 +0000676#endif
677
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000678#ifndef _LIBCPP_EXCEPTION_ABI
Logan Chien7b4845e2018-02-24 07:57:32 +0000679# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
680# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
681# else
682# define _LIBCPP_EXCEPTION_ABI
683# endif
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000684#endif
685
686#ifndef _LIBCPP_ENUM_VIS
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000687# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000688# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
689# else
690# define _LIBCPP_ENUM_VIS
691# endif
692#endif
693
694#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000695# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
Shoaib Meenai69c57412017-03-02 03:02:50 +0000696# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000697# else
698# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
699# endif
700#endif
701
Shoaib Meenai5ac10672016-09-19 18:29:07 +0000702#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Logan Chien7b4845e2018-02-24 07:57:32 +0000703#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Shoaib Meenai5ac10672016-09-19 18:29:07 +0000704#endif
705
Louis Dionne3a197992018-07-27 12:46:03 +0000706#if __has_attribute(internal_linkage)
707# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
708#else
709# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000710#endif
711
Louis Dionne3b8a03f2018-10-29 17:30:04 +0000712#if __has_attribute(exclude_from_explicit_instantiation)
713# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
714#else
715 // Try to approximate the effect of exclude_from_explicit_instantiation
716 // (which is that entities are not assumed to be provided by explicit
Louis Dionnea8548af2019-03-20 17:05:52 +0000717 // template instantiations in the dylib) by always inlining those entities.
Louis Dionne3b8a03f2018-10-29 17:30:04 +0000718# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
719#endif
720
Louis Dionne1821de42018-08-16 12:44:28 +0000721#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
722# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
723# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
724# else
725# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
726# endif
727#endif
728
Eric Fiselierf3566292019-05-29 02:21:37 +0000729#ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
730# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
731# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 0
732#else
733// TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
734// And we should consider defaulting to OFF.
735# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 1
736#endif
737#endif
738
Louis Dionne3a197992018-07-27 12:46:03 +0000739#ifndef _LIBCPP_HIDE_FROM_ABI
Louis Dionne1821de42018-08-16 12:44:28 +0000740# if _LIBCPP_HIDE_FROM_ABI_PER_TU
741# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
742# else
Louis Dionne3b8a03f2018-10-29 17:30:04 +0000743# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
Louis Dionne1821de42018-08-16 12:44:28 +0000744# endif
Louis Dionne3a197992018-07-27 12:46:03 +0000745#endif
746
Louis Dionned797b8d2018-08-06 14:11:50 +0000747#ifdef _LIBCPP_BUILDING_LIBRARY
748# if _LIBCPP_ABI_VERSION > 1
749# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
Logan Chien7b4845e2018-02-24 07:57:32 +0000750# else
Louis Dionned797b8d2018-08-06 14:11:50 +0000751# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
Logan Chien7b4845e2018-02-24 07:57:32 +0000752# endif
Louis Dionned797b8d2018-08-06 14:11:50 +0000753#else
754# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
Eric Fiselier815ed732016-09-16 00:00:48 +0000755#endif
756
Louis Dionned797b8d2018-08-06 14:11:50 +0000757// Just so we can migrate to the new macros gradually.
758#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
Louis Dionned797b8d2018-08-06 14:11:50 +0000759
Eric Fiselierb9d04dc2018-10-30 02:02:00 +0000760// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
Eric Fiselierb33778a2018-10-30 21:44:53 +0000761#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
Eric Fiselierb9d04dc2018-10-30 02:02:00 +0000762#define _LIBCPP_END_NAMESPACE_STD } }
Eric Fiselierb33778a2018-10-30 21:44:53 +0000763#define _VSTD std::_LIBCPP_ABI_NAMESPACE
Eric Fiselierb9d04dc2018-10-30 02:02:00 +0000764_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
765
766#if _LIBCPP_STD_VER >= 17
767#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
768 _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
769#else
770#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
771 _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
772#endif
773
774#define _LIBCPP_END_NAMESPACE_FILESYSTEM \
775 _LIBCPP_END_NAMESPACE_STD } }
776
777#define _VSTD_FS _VSTD::__fs::filesystem
778
Eric Fiselier1b57fa82016-09-15 22:27:07 +0000779#ifndef _LIBCPP_PREFERRED_OVERLOAD
780# if __has_attribute(__enable_if__)
781# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
782# endif
783#endif
784
Eric Fiselier1af87ca2015-12-15 22:16:47 +0000785#ifndef _LIBCPP_HAS_NO_NOEXCEPT
786# define _NOEXCEPT noexcept
787# define _NOEXCEPT_(x) noexcept(x)
788#else
789# define _NOEXCEPT throw()
790# define _NOEXCEPT_(x)
791#endif
792
Howard Hinnantc51e1022010-05-11 19:42:16 +0000793#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnantaa87c0f2010-08-10 20:48:29 +0000794typedef unsigned short char16_t;
795typedef unsigned int char32_t;
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000796#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnantc51e1022010-05-11 19:42:16 +0000797
Stephan Tolksdorf0efeb6c2014-03-26 19:45:52 +0000798#ifndef __SIZEOF_INT128__
799#define _LIBCPP_HAS_NO_INT128
800#endif
801
Eric Fiselierc6f17cc2016-09-25 03:34:28 +0000802#ifdef _LIBCPP_CXX03_LANG
Eric Fiselier2f05ab92019-06-18 20:50:25 +0000803# define static_assert(...) _Static_assert(__VA_ARGS__)
804# define decltype(...) __decltype(__VA_ARGS__)
Eric Fiselierc6f17cc2016-09-25 03:34:28 +0000805#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000806
Eric Fiselier605af612019-06-21 13:56:13 +0000807#ifdef _LIBCPP_CXX03_LANG
Logan Chien7b4845e2018-02-24 07:57:32 +0000808# define _LIBCPP_CONSTEXPR
Howard Hinnant664183b2012-04-02 00:40:41 +0000809#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000810# define _LIBCPP_CONSTEXPR constexpr
Howard Hinnant62c8c0b2010-09-06 19:10:31 +0000811#endif
812
Eric Fiselier07b2b552016-11-18 06:42:17 +0000813#ifdef _LIBCPP_CXX03_LANG
Logan Chien7b4845e2018-02-24 07:57:32 +0000814# define _LIBCPP_DEFAULT {}
Howard Hinnant3d284222013-05-02 20:18:43 +0000815#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000816# define _LIBCPP_DEFAULT = default;
Howard Hinnant3d284222013-05-02 20:18:43 +0000817#endif
818
Eric Fiselier2d8515f2017-01-06 20:58:25 +0000819#ifdef _LIBCPP_CXX03_LANG
Logan Chien7b4845e2018-02-24 07:57:32 +0000820# define _LIBCPP_EQUAL_DELETE
Eric Fiselierd06276b2016-03-31 02:15:15 +0000821#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000822# define _LIBCPP_EQUAL_DELETE = delete
Eric Fiselierd06276b2016-03-31 02:15:15 +0000823#endif
824
Nuno Lopes22df2dc2012-06-28 16:47:34 +0000825#ifdef __GNUC__
Louis Dionnee147b352019-02-26 06:34:42 +0000826# define _LIBCPP_NOALIAS __attribute__((__malloc__))
Nuno Lopes22df2dc2012-06-28 16:47:34 +0000827#else
Louis Dionnee147b352019-02-26 06:34:42 +0000828# define _LIBCPP_NOALIAS
Nuno Lopes22df2dc2012-06-28 16:47:34 +0000829#endif
830
Eric Fiselier70d0df32017-01-13 18:03:46 +0000831#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
Eric Fiselier6a5f6f92016-12-30 14:05:52 +0000832 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
Logan Chien7b4845e2018-02-24 07:57:32 +0000833# define _LIBCPP_EXPLICIT explicit
Howard Hinnant86a291f2012-02-21 21:46:43 +0000834#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000835# define _LIBCPP_EXPLICIT
Howard Hinnant86a291f2012-02-21 21:46:43 +0000836#endif
837
Richard Smith1f1c1472014-06-04 19:54:15 +0000838#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
Logan Chien7b4845e2018-02-24 07:57:32 +0000839#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
Richard Smith1f1c1472014-06-04 19:54:15 +0000840#endif
841
Howard Hinnant09bc0c92011-12-02 19:36:40 +0000842#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
Logan Chien7b4845e2018-02-24 07:57:32 +0000843# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
844# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
845 __lx __v_; \
Louis Dionne16fe2952018-07-11 23:14:33 +0000846 _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
847 _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
848 _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
Logan Chien7b4845e2018-02-24 07:57:32 +0000849 };
Howard Hinnant09bc0c92011-12-02 19:36:40 +0000850#else // _LIBCPP_HAS_NO_STRONG_ENUMS
Logan Chien7b4845e2018-02-24 07:57:32 +0000851# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
852# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
Howard Hinnant09bc0c92011-12-02 19:36:40 +0000853#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
854
Howard Hinnant6148a9b2013-08-23 20:10:18 +0000855#ifdef _LIBCPP_DEBUG
Logan Chien7b4845e2018-02-24 07:57:32 +0000856# if _LIBCPP_DEBUG == 0
857# define _LIBCPP_DEBUG_LEVEL 1
858# elif _LIBCPP_DEBUG == 1
859# define _LIBCPP_DEBUG_LEVEL 2
860# else
861# error Supported values for _LIBCPP_DEBUG are 0 and 1
862# endif
863# if !defined(_LIBCPP_BUILDING_LIBRARY)
864# define _LIBCPP_EXTERN_TEMPLATE(...)
865# endif
Howard Hinnant8ea98242013-08-23 17:37:05 +0000866#endif
867
Shoaib Meenai2ba461c2017-04-13 20:13:32 +0000868#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
869#define _LIBCPP_EXTERN_TEMPLATE(...)
870#define _LIBCPP_EXTERN_TEMPLATE2(...)
871#endif
872
Howard Hinnant862ca992012-11-06 21:08:48 +0000873#ifndef _LIBCPP_EXTERN_TEMPLATE
Justin Bogner67105aa2014-08-15 17:58:56 +0000874#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
Howard Hinnant862ca992012-11-06 21:08:48 +0000875#endif
876
Howard Hinnant8ea98242013-08-23 17:37:05 +0000877#ifndef _LIBCPP_EXTERN_TEMPLATE2
878#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
879#endif
880
Martin Storsjo5482ac62017-11-23 10:38:18 +0000881#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
Ed Schouten13eb7dc2015-03-10 09:26:38 +0000882 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
Alexis Hunt1adf2aa2011-07-15 05:40:33 +0000883#define _LIBCPP_LOCALE__L_EXTENSIONS 1
884#endif
Yaron Keren804da952013-12-20 13:19:45 +0000885
Ben Craig133f4c12016-02-10 13:47:25 +0000886#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
887// Most unix variants have catopen. These are the specific ones that don't.
Logan Chien7b4845e2018-02-24 07:57:32 +0000888# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
889# define _LIBCPP_HAS_CATOPEN 1
890# endif
Ben Craig133f4c12016-02-10 13:47:25 +0000891#endif
Ed Schouten118b6032015-03-11 16:39:36 +0000892
Marshall Clow82378c02013-03-18 19:34:07 +0000893#ifdef __FreeBSD__
David Chisnall6ae8f352011-11-13 17:15:33 +0000894#define _DECLARE_C99_LDBL_MATH 1
895#endif
Alexis Hunt1adf2aa2011-07-15 05:40:33 +0000896
Reid Kleckner85c65e62018-04-19 22:12:10 +0000897// If we are getting operator new from the MSVC CRT, then allocation overloads
898// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
899#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
Louis Dionne2e206ca2018-12-17 22:22:44 +0000900# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
Eric Fiselier85f66332019-03-05 01:57:01 +0000901#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
Louis Dionnea8548af2019-03-20 17:05:52 +0000902 // We're deferring to Microsoft's STL to provide aligned new et al. We don't
Thomas Andersone0439182019-01-30 19:08:32 +0000903 // have it unless the language feature test macro is defined.
904# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
Reid Kleckner85c65e62018-04-19 22:12:10 +0000905#endif
906
Eric Fiselier44832fb2017-01-20 01:47:26 +0000907#if defined(__APPLE__)
Logan Chien7b4845e2018-02-24 07:57:32 +0000908# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
909 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
910# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
911# endif
Eric Fiselier44832fb2017-01-20 01:47:26 +0000912#endif // defined(__APPLE__)
913
Louis Dionnee5aafbf2018-08-10 13:24:56 +0000914#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
Eric Fiselierff4c8a22018-10-11 00:17:24 +0000915 (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
916 (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
Louis Dionnee5aafbf2018-08-10 13:24:56 +0000917# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
918#endif
Eric Fiselier06548ab2018-03-22 04:42:56 +0000919
Marshall Clow82378c02013-03-18 19:34:07 +0000920#if defined(__APPLE__) || defined(__FreeBSD__)
Howard Hinnantf312e3e2011-09-28 23:39:33 +0000921#define _LIBCPP_HAS_DEFAULTRUNELOCALE
Alexis Hunt5a4dd562011-07-09 01:09:31 +0000922#endif
923
Marshall Clow82378c02013-03-18 19:34:07 +0000924#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
Alexis Huntc2017f12011-07-09 03:40:04 +0000925#define _LIBCPP_WCTYPE_IS_MASK
926#endif
927
Marshall Clow8732fed2018-12-11 04:35:44 +0000928#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
929#define _LIBCPP_NO_HAS_CHAR8_T
930#endif
931
Louis Dionne481a2662018-09-23 18:35:00 +0000932// Deprecation macros.
Louis Dionneded5b772019-03-12 20:10:06 +0000933//
934// Deprecations warnings are always enabled, except when users explicitly opt-out
935// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
936#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
Louis Dionne481a2662018-09-23 18:35:00 +0000937# if __has_attribute(deprecated)
938# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
939# elif _LIBCPP_STD_VER > 11
940# define _LIBCPP_DEPRECATED [[deprecated]]
941# else
942# define _LIBCPP_DEPRECATED
943# endif
Marshall Clowa2cbe0d2013-09-28 18:35:31 +0000944#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000945# define _LIBCPP_DEPRECATED
Marshall Clowa2cbe0d2013-09-28 18:35:31 +0000946#endif
947
Louis Dionne481a2662018-09-23 18:35:00 +0000948#if !defined(_LIBCPP_CXX03_LANG)
949# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
950#else
951# define _LIBCPP_DEPRECATED_IN_CXX11
952#endif
953
954#if _LIBCPP_STD_VER >= 14
955# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
956#else
957# define _LIBCPP_DEPRECATED_IN_CXX14
958#endif
959
960#if _LIBCPP_STD_VER >= 17
961# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
962#else
963# define _LIBCPP_DEPRECATED_IN_CXX17
964#endif
965
Richard Smithbfc256b2019-10-19 00:06:00 +0000966// Macros to enter and leave a state where deprecation warnings are suppressed.
967#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
968 (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
969# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
970 _Pragma("GCC diagnostic push") \
971 _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
972# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
973 _Pragma("GCC diagnostic pop")
974#endif
975#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
976# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
977# define _LIBCPP_SUPPRESS_DEPRECATED_POP
978#endif
979
Marshall Clow1045cee2013-07-15 14:57:19 +0000980#if _LIBCPP_STD_VER <= 11
Logan Chien7b4845e2018-02-24 07:57:32 +0000981# define _LIBCPP_EXPLICIT_AFTER_CXX11
Marshall Clow1045cee2013-07-15 14:57:19 +0000982#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000983# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
Marshall Clow1045cee2013-07-15 14:57:19 +0000984#endif
985
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000986#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien7b4845e2018-02-24 07:57:32 +0000987# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000988#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000989# define _LIBCPP_CONSTEXPR_AFTER_CXX11
Eric Fiselierb4c0c662014-07-17 05:16:18 +0000990#endif
991
Eric Fiselier0b3bfbe2016-03-17 03:30:56 +0000992#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien7b4845e2018-02-24 07:57:32 +0000993# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
Eric Fiselier0b3bfbe2016-03-17 03:30:56 +0000994#else
Logan Chien7b4845e2018-02-24 07:57:32 +0000995# define _LIBCPP_CONSTEXPR_AFTER_CXX14
Eric Fiselier0b3bfbe2016-03-17 03:30:56 +0000996#endif
997
Marshall Clow2a5c4212017-11-14 22:26:50 +0000998#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Logan Chien7b4845e2018-02-24 07:57:32 +0000999# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
Marshall Clow2a5c4212017-11-14 22:26:50 +00001000#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001001# define _LIBCPP_CONSTEXPR_AFTER_CXX17
Marshall Clow2a5c4212017-11-14 22:26:50 +00001002#endif
1003
Roman Lebedevb5959fa2018-09-22 17:54:48 +00001004// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
1005// NODISCARD macros to the correct attribute.
1006#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
1007# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
1008#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
1009# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
1010#else
1011// We can't use GCC's [[gnu::warn_unused_result]] and
1012// __attribute__((warn_unused_result)), because GCC does not silence them via
1013// (void) cast.
1014# define _LIBCPP_NODISCARD_ATTRIBUTE
1015#endif
1016
1017// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1018// specified as such as an extension.
1019#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1020# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE
1021#else
1022# define _LIBCPP_NODISCARD_EXT
1023#endif
1024
1025#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
1026 (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
1027# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE
Marshall Clow2a5c4212017-11-14 22:26:50 +00001028#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001029# define _LIBCPP_NODISCARD_AFTER_CXX17
Marshall Clow2a5c4212017-11-14 22:26:50 +00001030#endif
1031
Marshall Clowf1bf62f2018-01-02 17:17:01 +00001032#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
Logan Chien7b4845e2018-02-24 07:57:32 +00001033# define _LIBCPP_INLINE_VAR inline
Marshall Clowf1bf62f2018-01-02 17:17:01 +00001034#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001035# define _LIBCPP_INLINE_VAR
Eric Fiseliere4837422016-11-17 20:08:43 +00001036#endif
1037
Dimitry Andric830fb602015-08-19 06:43:33 +00001038#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1039# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
1040#else
1041# define _LIBCPP_EXPLICIT_MOVE(x) (x)
1042#endif
1043
Marshall Clowae4f8312018-07-13 16:35:26 +00001044#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
Marshall Clow82eec242018-07-13 17:31:36 +00001045#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
Marshall Clowae4f8312018-07-13 16:35:26 +00001046#define _LIBCPP_CONSTEXPR_IF_NODEBUG
Marshall Clowdb0b7a02018-07-13 17:24:59 +00001047#else
1048#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
Marshall Clowae4f8312018-07-13 16:35:26 +00001049#endif
1050#endif
1051
Louis Dionnea39f1ef2019-04-17 18:20:19 +00001052#if __has_attribute(no_destroy)
1053# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1054#else
1055# define _LIBCPP_NO_DESTROY
1056#endif
1057
Marshall Clow2cd9d372014-05-08 14:14:06 +00001058#ifndef _LIBCPP_HAS_NO_ASAN
Eric Fiselier6a213162016-12-23 20:03:52 +00001059_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
Marshall Clow2cd9d372014-05-08 14:14:06 +00001060 const void *, const void *, const void *, const void *);
1061#endif
1062
Howard Hinnant13087882013-10-04 21:24:21 +00001063// Try to find out if RTTI is disabled.
1064// g++ and cl.exe have RTTI on by default and define a macro when it is.
1065// g++ only defines the macro in 4.3.2 and onwards.
1066#if !defined(_LIBCPP_NO_RTTI)
Logan Chien7b4845e2018-02-24 07:57:32 +00001067# if defined(__GNUC__) && \
1068 ((__GNUC__ >= 5) || \
1069 (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \
1070 !defined(__GXX_RTTI)
Howard Hinnant13087882013-10-04 21:24:21 +00001071# define _LIBCPP_NO_RTTI
Eric Fiselier1e29ffc2017-05-10 21:40:58 +00001072# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
Howard Hinnant13087882013-10-04 21:24:21 +00001073# define _LIBCPP_NO_RTTI
1074# endif
1075#endif
1076
Howard Hinnant33f04722013-10-04 23:56:37 +00001077#ifndef _LIBCPP_WEAK
Logan Chien7b4845e2018-02-24 07:57:32 +00001078#define _LIBCPP_WEAK __attribute__((__weak__))
Howard Hinnant33f04722013-10-04 23:56:37 +00001079#endif
1080
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +00001081// Thread API
Eric Fiselierbfd45532017-01-06 23:15:16 +00001082#if !defined(_LIBCPP_HAS_NO_THREADS) && \
Asiri Rathnayakec07f0be2017-02-27 16:10:57 +00001083 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
Eric Fiselierd8a6c892017-05-10 21:34:58 +00001084 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
Asiri Rathnayakec07f0be2017-02-27 16:10:57 +00001085 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
Logan Chien7b4845e2018-02-24 07:57:32 +00001086# if defined(__FreeBSD__) || \
1087 defined(__Fuchsia__) || \
Dan Gohman280fd6b2019-05-01 16:47:30 +00001088 defined(__wasi__) || \
Logan Chien7b4845e2018-02-24 07:57:32 +00001089 defined(__NetBSD__) || \
1090 defined(__linux__) || \
Louis Dionne3cfcaeb2018-11-20 21:14:05 +00001091 defined(__GNU__) || \
Logan Chien7b4845e2018-02-24 07:57:32 +00001092 defined(__APPLE__) || \
1093 defined(__CloudABI__) || \
1094 defined(__sun__) || \
Alexander Richardsonba1b59e2018-07-24 12:40:56 +00001095 (defined(__MINGW32__) && __has_include(<pthread.h>))
Logan Chien7b4845e2018-02-24 07:57:32 +00001096# define _LIBCPP_HAS_THREAD_API_PTHREAD
1097# elif defined(_LIBCPP_WIN32API)
1098# define _LIBCPP_HAS_THREAD_API_WIN32
1099# else
1100# error "No thread API"
1101# endif // _LIBCPP_HAS_THREAD_API
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +00001102#endif // _LIBCPP_HAS_NO_THREADS
1103
Dan Albertad293012019-09-18 18:13:32 +00001104#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
1105#if defined(__ANDROID__) && __ANDROID_API__ >= 30
1106#define _LIBCPP_HAS_COND_CLOCKWAIT
1107#elif defined(_LIBCPP_GLIBC_PREREQ)
1108#if _LIBCPP_GLIBC_PREREQ(2, 30)
1109#define _LIBCPP_HAS_COND_CLOCKWAIT
1110#endif
1111#endif
1112#endif
1113
Ben Craig5593c4f2016-05-25 17:40:09 +00001114#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
Logan Chien7b4845e2018-02-24 07:57:32 +00001115#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
1116 _LIBCPP_HAS_NO_THREADS is not defined.
Ben Craig5593c4f2016-05-25 17:40:09 +00001117#endif
Asiri Rathnayakefa2e2032016-05-06 14:06:29 +00001118
Asiri Rathnayake94340d22016-09-11 21:46:40 +00001119#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
Logan Chien7b4845e2018-02-24 07:57:32 +00001120#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
1121 _LIBCPP_HAS_NO_THREADS is defined.
Asiri Rathnayake94340d22016-09-11 21:46:40 +00001122#endif
1123
Eric Fiselier715b4162014-12-06 20:09:11 +00001124#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
Logan Chien7b4845e2018-02-24 07:57:32 +00001125#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
1126 _LIBCPP_HAS_NO_THREADS is defined.
Eric Fiselier715b4162014-12-06 20:09:11 +00001127#endif
1128
Nico Weber6b58e1d2019-07-30 14:32:47 +00001129#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS)
1130#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
1131#endif
1132
1133#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
1134#define __STDCPP_THREADS__ 1
1135#endif
1136
Louis Dionne66c58fd2019-07-25 20:29:20 +00001137// The glibc and Bionic implementation of pthreads implements
Eric Fiselier256466e2019-07-07 17:24:03 +00001138// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
1139// mutexes have no destroy mechanism.
Louis Dionne66c58fd2019-07-25 20:29:20 +00001140//
1141// This optimization can't be performed on Apple platforms, where
1142// pthread_mutex_destroy can allow the kernel to release resources.
1143// See https://llvm.org/D64298 for details.
1144//
1145// TODO(EricWF): Enable this optimization on Bionic after speaking to their
1146// respective stakeholders.
Eric Fiselier256466e2019-07-07 17:24:03 +00001147#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
1148 || defined(_LIBCPP_HAS_THREAD_API_WIN32)
Eric Fiselierf6dac862019-07-07 01:20:54 +00001149# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
1150#endif
1151
Eric Fiselier256466e2019-07-07 17:24:03 +00001152// Destroying a condvar is a nop on Windows.
Louis Dionne66c58fd2019-07-25 20:29:20 +00001153//
1154// This optimization can't be performed on Apple platforms, where
1155// pthread_cond_destroy can allow the kernel to release resources.
1156// See https://llvm.org/D64298 for details.
1157//
Eric Fiselier256466e2019-07-07 17:24:03 +00001158// TODO(EricWF): This is potentially true for some pthread implementations
1159// as well.
1160#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
1161# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
1162#endif
1163
Ed Schouten7009f4e2015-03-12 15:44:39 +00001164// Systems that use capability-based security (FreeBSD with Capsicum,
1165// Nuxi CloudABI) may only provide local filesystem access (using *at()).
1166// Functions like open(), rename(), unlink() and stat() should not be
1167// used, as they attempt to access the global filesystem namespace.
1168#ifdef __CloudABI__
1169#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
1170#endif
1171
Ed Schouten3a75c0b2015-03-26 14:35:46 +00001172// CloudABI is intended for running networked services. Processes do not
1173// have standard input and output channels.
1174#ifdef __CloudABI__
1175#define _LIBCPP_HAS_NO_STDIN
1176#define _LIBCPP_HAS_NO_STDOUT
1177#endif
1178
Dimitry Andric2e72c802019-09-07 22:18:20 +00001179// Some systems do not provide gets() in their C library, for security reasons.
1180#ifndef _LIBCPP_C_HAS_NO_GETS
1181# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD__) && __FreeBSD__ >= 13)
1182# define _LIBCPP_C_HAS_NO_GETS
1183# endif
1184#endif
1185
Dan Albert21800dc2016-09-19 18:00:45 +00001186#if defined(__BIONIC__) || defined(__CloudABI__) || \
Dan Gohman280fd6b2019-05-01 16:47:30 +00001187 defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
Dan Albertebdf28b2015-03-11 00:51:06 +00001188#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
1189#endif
1190
Ed Schoutena810d5e2016-12-30 10:44:00 +00001191// Thread-unsafe functions such as strtok() and localtime()
Ed Schouten137c8632015-06-24 08:44:38 +00001192// are not available.
1193#ifdef __CloudABI__
1194#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
1195#endif
1196
Eric Fiselierba725072017-01-14 04:27:58 +00001197#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
Logan Chien7b4845e2018-02-24 07:57:32 +00001198# define _LIBCPP_HAS_C_ATOMIC_IMP
Richard Smithca47d0f2019-04-25 20:02:10 +00001199#elif defined(_LIBCPP_COMPILER_GCC)
Logan Chien7b4845e2018-02-24 07:57:32 +00001200# define _LIBCPP_HAS_GCC_ATOMIC_IMP
Eric Fiselier8020b6c2015-08-19 17:21:46 +00001201#endif
1202
Davide Italiano011f80a2019-03-05 18:40:49 +00001203#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
1204 !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
1205 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
Eric Fiselier8020b6c2015-08-19 17:21:46 +00001206 || defined(_LIBCPP_HAS_NO_THREADS)
Davide Italiano011f80a2019-03-05 18:40:49 +00001207# define _LIBCPP_HAS_NO_ATOMIC_HEADER
1208#else
1209# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1210# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1211# endif
1212# ifdef _LIBCPP_FREESTANDING
1213# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1214# endif
Eric Fiselier8020b6c2015-08-19 17:21:46 +00001215#endif
1216
Marshall Clow91c7f642016-01-11 19:27:10 +00001217#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1218#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
Eric Fiselier100e24b2016-02-11 11:59:44 +00001219#endif
1220
Saleem Abdulrasoolb82f9602017-02-13 15:26:51 +00001221#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
Logan Chien7b4845e2018-02-24 07:57:32 +00001222# if defined(__clang__) && __has_attribute(acquire_capability)
Saleem Abdulrasoolb82f9602017-02-13 15:26:51 +00001223// Work around the attribute handling in clang. When both __declspec and
1224// __attribute__ are present, the processing goes awry preventing the definition
1225// of the types.
Logan Chien7b4845e2018-02-24 07:57:32 +00001226# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
1227# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
1228# endif
1229# endif
Saleem Abdulrasoolb82f9602017-02-13 15:26:51 +00001230#endif
Eric Fiselierc0c6c982016-03-16 02:30:06 +00001231
Eric Fiselier0d3da632016-09-03 00:11:33 +00001232#if __has_attribute(require_constant_initialization)
Logan Chien7b4845e2018-02-24 07:57:32 +00001233# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
Eric Fiselier0d3da632016-09-03 00:11:33 +00001234#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001235# define _LIBCPP_SAFE_STATIC
Eric Fiselier0d3da632016-09-03 00:11:33 +00001236#endif
1237
Eric Fiselierd4ec6352016-10-12 07:46:20 +00001238#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
Logan Chien7b4845e2018-02-24 07:57:32 +00001239#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
Eric Fiselierd4ec6352016-10-12 07:46:20 +00001240#endif
1241
Eric Fiselier5afe0992019-04-24 17:54:25 +00001242#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
1243#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
1244#endif
1245
Shoaib Meenai3879c9b2016-10-31 15:09:10 +00001246#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
Logan Chien7b4845e2018-02-24 07:57:32 +00001247# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
1248# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
1249# endif
Shoaib Meenai3879c9b2016-10-31 15:09:10 +00001250#endif
1251
Eric Fiseliera7a14ed2017-01-13 22:02:08 +00001252#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
Logan Chien7b4845e2018-02-24 07:57:32 +00001253# define _LIBCPP_DIAGNOSE_WARNING(...) \
1254 __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1255# define _LIBCPP_DIAGNOSE_ERROR(...) \
1256 __attribute__((diagnose_if(__VA_ARGS__, "error")))
Eric Fiseliera7a14ed2017-01-13 22:02:08 +00001257#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001258# define _LIBCPP_DIAGNOSE_WARNING(...)
1259# define _LIBCPP_DIAGNOSE_ERROR(...)
Eric Fiseliera7a14ed2017-01-13 22:02:08 +00001260#endif
1261
Eric Fiselier4db80032017-05-05 20:32:26 +00001262// Use a function like macro to imply that it must be followed by a semicolon
Reid Kleckner75d4e002018-11-01 18:24:03 +00001263#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
1264# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1265#elif __has_cpp_attribute(clang::fallthrough)
1266# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
1267#elif __has_attribute(fallthough) || _GNUC_VER >= 700
Logan Chien7b4845e2018-02-24 07:57:32 +00001268# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
Eric Fiselier4db80032017-05-05 20:32:26 +00001269#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001270# define _LIBCPP_FALLTHROUGH() ((void)0)
Eric Fiselier4db80032017-05-05 20:32:26 +00001271#endif
1272
Eric Fiselier4fc82a22019-06-12 02:03:31 +00001273#if __has_attribute(__nodebug__)
1274#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
Eric Fiselier74ebee62019-06-08 01:31:19 +00001275#else
1276#define _LIBCPP_NODEBUG
1277#endif
1278
Eric Fiselier4fc82a22019-06-12 02:03:31 +00001279#ifndef _LIBCPP_NODEBUG_TYPE
1280#if __has_attribute(__nodebug__) && \
Louis Dionne8bf4c792019-08-14 17:01:08 +00001281 (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
Eric Fiselier4fc82a22019-06-12 02:03:31 +00001282#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
1283#else
1284#define _LIBCPP_NODEBUG_TYPE
1285#endif
1286#endif // !defined(_LIBCPP_NODEBUG_TYPE)
1287
Eric Fiseliere3cec5f2017-01-16 21:15:08 +00001288#if defined(_LIBCPP_ABI_MICROSOFT) && \
Logan Chien7b4845e2018-02-24 07:57:32 +00001289 (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1290# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
Eric Fiseliere3cec5f2017-01-16 21:15:08 +00001291#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001292# define _LIBCPP_DECLSPEC_EMPTY_BASES
Eric Fiseliere3cec5f2017-01-16 21:15:08 +00001293#endif
1294
Eric Fiselierddd77792017-02-17 03:25:08 +00001295#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
Logan Chien7b4845e2018-02-24 07:57:32 +00001296#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1297#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1298#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1299#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
Eric Fiselierddd77792017-02-17 03:25:08 +00001300#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1301
Marshall Clow580b6e62017-03-24 03:40:36 +00001302#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
Logan Chien7b4845e2018-02-24 07:57:32 +00001303#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
Marshall Clow580b6e62017-03-24 03:40:36 +00001304#endif
1305
Eric Fiselierc9a0e822017-04-12 23:08:46 +00001306#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
Logan Chien7b4845e2018-02-24 07:57:32 +00001307#define _LIBCPP_HAS_NO_IS_AGGREGATE
Eric Fiselierc9a0e822017-04-12 23:08:46 +00001308#endif
1309
Eric Fiselier40b66222017-05-26 01:52:59 +00001310#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
Logan Chien7b4845e2018-02-24 07:57:32 +00001311#define _LIBCPP_HAS_NO_COROUTINES
Eric Fiselier40b66222017-05-26 01:52:59 +00001312#endif
1313
Eric Fiseliere0074fc2018-04-06 21:37:23 +00001314// FIXME: Correct this macro when either (A) a feature test macro for the
1315// spaceship operator is provided, or (B) a compiler provides a complete
1316// implementation.
1317#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
1318
Mehdi Amini228053d2017-05-04 17:08:54 +00001319// Decide whether to use availability macros.
1320#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
1321 !defined(_LIBCPP_DISABLE_AVAILABILITY) && \
1322 __has_feature(attribute_availability_with_strict) && \
Louis Dionnef6bf76a2019-03-20 21:18:14 +00001323 __has_feature(attribute_availability_in_templates) && \
1324 __has_extension(pragma_clang_attribute_external_declaration)
Logan Chien7b4845e2018-02-24 07:57:32 +00001325# ifdef __APPLE__
1326# define _LIBCPP_USE_AVAILABILITY_APPLE
1327# endif
Mehdi Amini228053d2017-05-04 17:08:54 +00001328#endif
1329
1330// Define availability macros.
1331#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
Logan Chien7b4845e2018-02-24 07:57:32 +00001332# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
1333 __attribute__((availability(macosx,strict,introduced=10.12))) \
1334 __attribute__((availability(ios,strict,introduced=10.0))) \
1335 __attribute__((availability(tvos,strict,introduced=10.0))) \
1336 __attribute__((availability(watchos,strict,introduced=3.0)))
Louis Dionnecef92e62018-11-19 15:37:04 +00001337# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \
1338 __attribute__((availability(macosx,strict,introduced=10.14))) \
1339 __attribute__((availability(ios,strict,introduced=12.0))) \
1340 __attribute__((availability(tvos,strict,introduced=12.0))) \
1341 __attribute__((availability(watchos,strict,introduced=5.0)))
1342# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \
1343 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Louis Dionnecef92e62018-11-19 15:37:04 +00001344# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \
1345 _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Logan Chien7b4845e2018-02-24 07:57:32 +00001346# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
1347 __attribute__((availability(macosx,strict,introduced=10.12))) \
1348 __attribute__((availability(ios,strict,introduced=10.0))) \
1349 __attribute__((availability(tvos,strict,introduced=10.0))) \
1350 __attribute__((availability(watchos,strict,introduced=3.0)))
1351# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \
1352 __attribute__((availability(macosx,strict,introduced=10.12))) \
1353 __attribute__((availability(ios,strict,introduced=10.0))) \
1354 __attribute__((availability(tvos,strict,introduced=10.0))) \
1355 __attribute__((availability(watchos,strict,introduced=3.0)))
1356# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \
1357 __attribute__((availability(ios,strict,introduced=6.0)))
1358# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \
1359 __attribute__((availability(macosx,strict,introduced=10.9))) \
1360 __attribute__((availability(ios,strict,introduced=7.0)))
1361# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \
1362 __attribute__((availability(macosx,strict,introduced=10.9))) \
1363 __attribute__((availability(ios,strict,introduced=7.0)))
1364# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
1365 __attribute__((availability(macosx,strict,introduced=10.9))) \
1366 __attribute__((availability(ios,strict,introduced=7.0)))
Louis Dionnef5ba8aa2019-03-20 14:34:00 +00001367# define _LIBCPP_AVAILABILITY_FILESYSTEM \
Louis Dionne0f2ff0c2019-07-03 18:29:02 +00001368 __attribute__((availability(macosx,strict,introduced=10.15))) \
1369 __attribute__((availability(ios,strict,introduced=13.0))) \
1370 __attribute__((availability(tvos,strict,introduced=13.0))) \
1371 __attribute__((availability(watchos,strict,introduced=6.0)))
Louis Dionnef6bf76a2019-03-20 21:18:14 +00001372# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
Louis Dionne0f2ff0c2019-07-03 18:29:02 +00001373 _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
1374 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
1375 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
1376 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
Louis Dionnef6bf76a2019-03-20 21:18:14 +00001377# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
1378 _Pragma("clang attribute pop") \
1379 _Pragma("clang attribute pop") \
1380 _Pragma("clang attribute pop") \
1381 _Pragma("clang attribute pop")
Mehdi Amini228053d2017-05-04 17:08:54 +00001382#else
Logan Chien7b4845e2018-02-24 07:57:32 +00001383# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
Louis Dionnecef92e62018-11-19 15:37:04 +00001384# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
Logan Chien7b4845e2018-02-24 07:57:32 +00001385# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
Logan Chien7b4845e2018-02-24 07:57:32 +00001386# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1387# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
1388# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
1389# define _LIBCPP_AVAILABILITY_FUTURE_ERROR
1390# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
1391# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
1392# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
Louis Dionnef5ba8aa2019-03-20 14:34:00 +00001393# define _LIBCPP_AVAILABILITY_FILESYSTEM
Louis Dionnef6bf76a2019-03-20 21:18:14 +00001394# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
1395# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
Mehdi Amini228053d2017-05-04 17:08:54 +00001396#endif
1397
1398// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
1399#ifdef _LIBCPP_NO_EXCEPTIONS
Logan Chien7b4845e2018-02-24 07:57:32 +00001400# define _LIBCPP_AVAILABILITY_FUTURE
1401# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
Louis Dionnecef92e62018-11-19 15:37:04 +00001402# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
1403# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
Mehdi Amini228053d2017-05-04 17:08:54 +00001404#else
Louis Dionnea0078f42018-11-20 23:18:25 +00001405# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
1406# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
1407# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
1408# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
Mehdi Amini228053d2017-05-04 17:08:54 +00001409#endif
1410
Louis Dionne207a9102018-12-06 00:24:58 +00001411// The stream API was dropped and re-added in the dylib shipped on macOS
1412// and iOS. We can only assume the dylib to provide these definitions for
1413// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
1414// from the headers, but not from the dylib. Explicit instantiation
1415// declarations for streams exist conditionally to this; if we provide
1416// an explicit instantiation declaration and we try to deploy to a dylib
1417// that does not provide those symbols, we'll get a load-time error.
1418#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
Mehdi Amini228053d2017-05-04 17:08:54 +00001419 ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
Duncan P. N. Exon Smithb28fea72017-06-18 16:50:23 +00001420 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
Mehdi Amini228053d2017-05-04 17:08:54 +00001421 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
Duncan P. N. Exon Smithb28fea72017-06-18 16:50:23 +00001422 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
Louis Dionne207a9102018-12-06 00:24:58 +00001423# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
Mehdi Amini228053d2017-05-04 17:08:54 +00001424#endif
1425
Eric Fiselierf4433a32017-05-31 22:07:49 +00001426#if defined(_LIBCPP_COMPILER_IBM)
1427#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
1428#endif
1429
1430#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
Logan Chien7b4845e2018-02-24 07:57:32 +00001431# define _LIBCPP_PUSH_MACROS
1432# define _LIBCPP_POP_MACROS
Eric Fiselierf4433a32017-05-31 22:07:49 +00001433#else
1434 // Don't warn about macro conflicts when we can restore them at the
1435 // end of the header.
Logan Chien7b4845e2018-02-24 07:57:32 +00001436# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1437# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
1438# endif
1439# if defined(_LIBCPP_COMPILER_MSVC)
1440# define _LIBCPP_PUSH_MACROS \
1441 __pragma(push_macro("min")) \
1442 __pragma(push_macro("max"))
1443# define _LIBCPP_POP_MACROS \
1444 __pragma(pop_macro("min")) \
1445 __pragma(pop_macro("max"))
1446# else
1447# define _LIBCPP_PUSH_MACROS \
1448 _Pragma("push_macro(\"min\")") \
1449 _Pragma("push_macro(\"max\")")
1450# define _LIBCPP_POP_MACROS \
1451 _Pragma("pop_macro(\"min\")") \
1452 _Pragma("pop_macro(\"max\")")
1453# endif
Eric Fiselierf4433a32017-05-31 22:07:49 +00001454#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
1455
Peter Collingbourne1aa99c52018-01-24 04:30:19 +00001456#ifndef _LIBCPP_NO_AUTO_LINK
Logan Chien7b4845e2018-02-24 07:57:32 +00001457# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
1458# if defined(_DLL)
1459# pragma comment(lib, "c++.lib")
1460# else
1461# pragma comment(lib, "libc++.lib")
1462# endif
1463# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
Peter Collingbourne1aa99c52018-01-24 04:30:19 +00001464#endif // _LIBCPP_NO_AUTO_LINK
Eric Fiselier911dcad2017-06-16 01:57:41 +00001465
Petr Hosek399c5112019-01-13 22:15:37 +00001466#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
1467
Dan Albert9550df62019-09-16 19:26:41 +00001468// Configures the fopen close-on-exec mode character, if any. This string will
1469// be appended to any mode string used by fstream for fopen/fdopen.
1470//
1471// Not all platforms support this, but it helps avoid fd-leaks on platforms that
1472// do.
1473#if defined(__BIONIC__)
1474# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
1475#else
1476# define _LIBCPP_FOPEN_CLOEXEC_MODE
1477#endif
1478
Eric Fiselier911dcad2017-06-16 01:57:41 +00001479#endif // __cplusplus
1480
Eric Fiselier8020b6c2015-08-19 17:21:46 +00001481#endif // _LIBCPP_CONFIG