Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- __config ---------------------------------===// |
| 3 | // |
Chandler Carruth | 7c3769d | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // 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 Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_CONFIG |
| 11 | #define _LIBCPP_CONFIG |
| 12 | |
Eric Fiselier | 38e7a30 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 13 | #if defined(_MSC_VER) && !defined(__clang__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 14 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 16 | # endif |
Saleem Abdulrasool | bc11659 | 2017-01-29 18:16:33 +0000 | [diff] [blame] | 17 | #endif |
Eric Fiselier | 38e7a30 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 18 | |
| 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 20 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 21 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | |
Eric Fiselier | 38e7a30 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | |
Howard Hinnant | 75536ba | 2012-10-03 20:48:05 +0000 | [diff] [blame] | 25 | #ifdef __GNUC__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 26 | # define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) |
Eric Fiselier | 7b41c79 | 2017-04-12 23:08:46 +0000 | [diff] [blame] | 27 | // The _GNUC_VER_NEW macro better represents the new GCC versioning scheme |
| 28 | // introduced in GCC 5.0. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 29 | # define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) |
Eric Fiselier | eeeada1 | 2015-06-13 02:18:44 +0000 | [diff] [blame] | 30 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 31 | # define _GNUC_VER 0 |
| 32 | # define _GNUC_VER_NEW 0 |
Howard Hinnant | 75536ba | 2012-10-03 20:48:05 +0000 | [diff] [blame] | 33 | #endif |
| 34 | |
Hans Wennborg | 548f2e8 | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 35 | #define _LIBCPP_VERSION 10000 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 36 | |
Eric Fiselier | de635b6 | 2019-06-26 00:05:14 +0000 | [diff] [blame] | 37 | #ifndef _LIBCPP_ABI_VERSION |
| 38 | # define _LIBCPP_ABI_VERSION 1 |
| 39 | #endif |
| 40 | |
Davide Italiano | a011222 | 2019-03-05 18:40:49 +0000 | [diff] [blame] | 41 | #ifndef __STDC_HOSTED__ |
| 42 | # define _LIBCPP_FREESTANDING |
| 43 | #endif |
| 44 | |
Eric Fiselier | a0866c5 | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 45 | #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 Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 57 | #if defined(__ELF__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 58 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 |
Shoaib Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 59 | #elif defined(__MACH__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 60 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 |
Shoaib Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 61 | #elif defined(_WIN32) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 62 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 |
Sam Clegg | 5638e7b | 2017-12-16 18:59:50 +0000 | [diff] [blame] | 63 | #elif defined(__wasm__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 64 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 |
Shoaib Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 65 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 66 | # error Unknown object file format |
Shoaib Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 67 | #endif |
| 68 | |
Eric Fiselier | de635b6 | 2019-06-26 00:05:14 +0000 | [diff] [blame] | 69 | #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 |
Shoaib Meenai | b6b8e1e | 2016-09-12 20:14:44 +0000 | [diff] [blame] | 70 | // Change short string representation so that string data starts at offset 0, |
Evgeniy Stepanov | 746572b | 2015-11-06 22:02:29 +0000 | [diff] [blame] | 71 | // improving its alignment in some cases. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 72 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
Evgeniy Stepanov | 746572b | 2015-11-06 22:02:29 +0000 | [diff] [blame] | 73 | // Fix deque iterator type in order to support incomplete types. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 74 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE |
Nico Weber | bfa81b0 | 2017-07-22 15:16:42 +0000 | [diff] [blame] | 75 | // Fix undefined behavior in how std::list stores its linked nodes. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 76 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB |
Eric Fiselier | 7310ec8 | 2016-07-19 17:56:20 +0000 | [diff] [blame] | 77 | // Fix undefined behavior in how __tree stores its end and parent nodes. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 78 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB |
Nico Weber | bfa81b0 | 2017-07-22 15:16:42 +0000 | [diff] [blame] | 79 | // Fix undefined behavior in how __hash_table stores its pointer types. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 80 | # 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 Fiselier | 7d0000f | 2016-12-28 11:09:18 +0000 | [diff] [blame] | 83 | // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr |
Eric Fiselier | 8a549ab | 2016-12-28 09:50:23 +0000 | [diff] [blame] | 84 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 86 | # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR |
Eric Fiselier | 46a0c2e | 2017-01-05 01:15:42 +0000 | [diff] [blame] | 87 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 91 | # define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE |
Shoaib Meenai | f012f26 | 2017-03-28 19:33:31 +0000 | [diff] [blame] | 92 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 95 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION |
Aditya Kumar | aa356d6 | 2017-06-14 23:17:45 +0000 | [diff] [blame] | 96 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 97 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
Eric Fiselier | e7f8cd4 | 2017-11-19 04:19:44 +0000 | [diff] [blame] | 98 | // Use the smallest possible integer type to represent the index of the variant. |
Louis Dionne | 9009625 | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 99 | // Previously libc++ used "unsigned int" exclusively. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 100 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION |
Eric Fiselier | c1935f1 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 101 | // Unstable attempt to provide a more optimized std::function |
| 102 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION |
Marshall Clow | cc07c89 | 2019-03-28 17:30:23 +0000 | [diff] [blame] | 103 | // All the regex constants must be distinct and nonzero. |
| 104 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
Eric Fiselier | c71c304 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 105 | #elif _LIBCPP_ABI_VERSION == 1 |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 106 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Eric Fiselier | a7ae303 | 2017-01-17 03:16:26 +0000 | [diff] [blame] | 107 | // Enable compiling copies of now inline methods into the dylib to support |
Shoaib Meenai | 6d5fdc1 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 108 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 112 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS |
| 113 | # endif |
Eric Fiselier | c71c304 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 114 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 115 | // are deprecated. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 116 | # if defined(__FreeBSD__) |
| 117 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR |
| 118 | # endif |
Eric Fiselier | c71c304 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 119 | #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 Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 124 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 125 | |
| 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 Fiselier | e6f91d8 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 129 | #ifndef _LIBCPP_ABI_NAMESPACE |
| 130 | # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) |
| 131 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 132 | |
Eric Fiselier | 4e3e15a | 2016-09-25 03:34:28 +0000 | [diff] [blame] | 133 | #if __cplusplus < 201103L |
| 134 | #define _LIBCPP_CXX03_LANG |
| 135 | #endif |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 136 | |
| 137 | #ifndef __has_attribute |
| 138 | #define __has_attribute(__x) 0 |
| 139 | #endif |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 140 | |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 141 | #ifndef __has_builtin |
| 142 | #define __has_builtin(__x) 0 |
| 143 | #endif |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 144 | |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 145 | #ifndef __has_extension |
| 146 | #define __has_extension(__x) 0 |
| 147 | #endif |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 148 | |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 149 | #ifndef __has_feature |
| 150 | #define __has_feature(__x) 0 |
| 151 | #endif |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 152 | |
Marshall Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 153 | #ifndef __has_cpp_attribute |
| 154 | #define __has_cpp_attribute(__x) 0 |
| 155 | #endif |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 156 | |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 157 | // '__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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 162 | |
Eric Fiselier | 7d24e91 | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 163 | #ifndef __has_declspec_attribute |
| 164 | #define __has_declspec_attribute(__x) 0 |
| 165 | #endif |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 166 | |
Eric Fiselier | 50ca324 | 2017-01-14 04:27:58 +0000 | [diff] [blame] | 167 | #define __has_keyword(__x) !(__is_identifier(__x)) |
| 168 | |
Alexander Richardson | 2be41bb | 2018-07-24 12:40:56 +0000 | [diff] [blame] | 169 | #ifndef __has_include |
| 170 | #define __has_include(...) 0 |
Eric Fiselier | 2df956f | 2017-05-10 21:34:58 +0000 | [diff] [blame] | 171 | #endif |
| 172 | |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 173 | #if defined(__clang__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 174 | # define _LIBCPP_COMPILER_CLANG |
| 175 | # ifndef __apple_build_version__ |
| 176 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) |
| 177 | # endif |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 178 | #elif defined(__GNUC__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 179 | # define _LIBCPP_COMPILER_GCC |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 180 | #elif defined(_MSC_VER) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 181 | # define _LIBCPP_COMPILER_MSVC |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 182 | #elif defined(__IBMCPP__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 183 | # define _LIBCPP_COMPILER_IBM |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 184 | #endif |
| 185 | |
Eric Fiselier | cdb5d25 | 2017-01-23 21:41:13 +0000 | [diff] [blame] | 186 | #ifndef _LIBCPP_CLANG_VER |
| 187 | #define _LIBCPP_CLANG_VER 0 |
| 188 | #endif |
| 189 | |
Eric Fiselier | f68c6d5 | 2019-06-13 00:37:25 +0000 | [diff] [blame] | 190 | #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 Fiselier | 32ff327 | 2017-01-07 02:43:58 +0000 | [diff] [blame] | 194 | // 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 Meenai | 36d0ee6 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 196 | // 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 Meenai | 7762784 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 199 | #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 200 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" |
Shoaib Meenai | 7762784 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 201 | #elif defined(_LIBCPP_ABI_FORCE_ITANIUM) |
Shoaib Meenai | 36d0ee6 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 202 | # define _LIBCPP_ABI_ITANIUM |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 203 | #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 Fiselier | 32ff327 | 2017-01-07 02:43:58 +0000 | [diff] [blame] | 211 | #endif |
| 212 | |
Eric Fiselier | e718b5a | 2019-03-05 01:57:01 +0000 | [diff] [blame] | 213 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) |
| 214 | # define _LIBCPP_ABI_VCRUNTIME |
| 215 | #endif |
| 216 | |
Dan Albert | 7d7f3cc | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 217 | // Need to detect which libc we're using if we're on Linux. |
| 218 | #if defined(__linux__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 219 | # 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 Albert | 7d7f3cc | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 225 | #endif // defined(__linux__) |
Eric Fiselier | 8f7fe5c | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 226 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 227 | #ifdef __LITTLE_ENDIAN__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 228 | # if __LITTLE_ENDIAN__ |
| 229 | # define _LIBCPP_LITTLE_ENDIAN |
| 230 | # endif // __LITTLE_ENDIAN__ |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 231 | #endif // __LITTLE_ENDIAN__ |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 232 | |
| 233 | #ifdef __BIG_ENDIAN__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 234 | # if __BIG_ENDIAN__ |
| 235 | # define _LIBCPP_BIG_ENDIAN |
| 236 | # endif // __BIG_ENDIAN__ |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 237 | #endif // __BIG_ENDIAN__ |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 238 | |
Dan Albert | 2897e78 | 2015-09-16 18:10:47 +0000 | [diff] [blame] | 239 | #ifdef __BYTE_ORDER__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 240 | # 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 Albert | 2897e78 | 2015-09-16 18:10:47 +0000 | [diff] [blame] | 245 | #endif // __BYTE_ORDER__ |
| 246 | |
David Chisnall | 3e13d4f | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 247 | #ifdef __FreeBSD__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 248 | # include <sys/endian.h> |
David Chisnall | 3e13d4f | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 249 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 250 | # 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 Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 257 | #endif // __FreeBSD__ |
David Chisnall | 3e13d4f | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 258 | |
Joerg Sonnenberger | a71a952 | 2013-05-17 21:17:34 +0000 | [diff] [blame] | 259 | #ifdef __NetBSD__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 260 | # include <sys/endian.h> |
Joerg Sonnenberger | a71a952 | 2013-05-17 21:17:34 +0000 | [diff] [blame] | 261 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 262 | # 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 Sonnenberger | a71a952 | 2013-05-17 21:17:34 +0000 | [diff] [blame] | 267 | #endif // __NetBSD__ |
| 268 | |
Saleem Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 269 | #if defined(_WIN32) |
Eric Fiselier | 7b7ac67 | 2017-05-31 22:14:05 +0000 | [diff] [blame] | 270 | # define _LIBCPP_WIN32API |
Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 271 | # define _LIBCPP_LITTLE_ENDIAN |
Saleem Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 272 | # define _LIBCPP_SHORT_WCHAR 1 |
Louis Dionne | 9009625 | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 273 | // Both MinGW and native MSVC provide a "MSVC"-like environment |
Eric Fiselier | 7b7ac67 | 2017-05-31 22:14:05 +0000 | [diff] [blame] | 274 | # define _LIBCPP_MSVCRT_LIKE |
Bruno Cardoso Lopes | da4047d | 2017-07-17 21:52:31 +0000 | [diff] [blame] | 275 | // 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 Hinnant | ef5aa93 | 2013-09-17 01:34:47 +0000 | [diff] [blame] | 278 | # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library |
| 279 | # endif |
Saleem Abdulrasool | 5c737d8 | 2017-01-04 01:53:24 +0000 | [diff] [blame] | 280 | # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) |
| 281 | # define _LIBCPP_HAS_BITSCAN64 |
| 282 | # endif |
Peter Collingbourne | f493c2f | 2018-01-23 02:07:27 +0000 | [diff] [blame] | 283 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 284 | # if defined(_LIBCPP_MSVCRT) |
| 285 | # define _LIBCPP_HAS_QUICK_EXIT |
| 286 | # endif |
Shoaib Meenai | 9a13b43 | 2017-04-06 04:47:49 +0000 | [diff] [blame] | 287 | |
| 288 | // Some CRT APIs are unavailable to store apps |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 289 | # 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 Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 297 | #endif // defined(_WIN32) |
Howard Hinnant | 11a58a6 | 2011-05-13 17:16:06 +0000 | [diff] [blame] | 298 | |
David Chisnall | 997e454 | 2012-02-29 13:05:08 +0000 | [diff] [blame] | 299 | #ifdef __sun__ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 300 | # include <sys/isa_defs.h> |
| 301 | # ifdef _LITTLE_ENDIAN |
| 302 | # define _LIBCPP_LITTLE_ENDIAN |
| 303 | # else |
| 304 | # define _LIBCPP_BIG_ENDIAN |
| 305 | # endif |
David Chisnall | 997e454 | 2012-02-29 13:05:08 +0000 | [diff] [blame] | 306 | #endif // __sun__ |
| 307 | |
Ed Schouten | 63e70b6 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 308 | #if defined(__CloudABI__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 309 | // 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 Gohman | d6842df | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 314 | #elif defined(__Fuchsia__) || defined(__wasi__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 315 | # define _LIBCPP_USING_GETENTROPY |
Ed Schouten | 63e70b6 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 316 | #elif defined(__native_client__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 317 | // 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 Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 321 | #elif defined(_LIBCPP_WIN32API) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 322 | # define _LIBCPP_USING_WIN32_RANDOM |
Ed Schouten | 63e70b6 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 323 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 324 | # define _LIBCPP_USING_DEV_RANDOM |
Ed Schouten | 63e70b6 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 325 | #endif |
JF Bastien | 2bd5ffd | 2014-12-01 19:19:55 +0000 | [diff] [blame] | 326 | |
Eric Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 327 | #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 328 | # 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 Fiselier | 5ccf043 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 336 | #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 337 | |
Eric Fiselier | 5f8e0d7 | 2017-06-15 03:50:02 +0000 | [diff] [blame] | 338 | #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 339 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) |
Evgeniy Stepanov | 45dca2c | 2016-02-10 21:53:28 +0000 | [diff] [blame] | 340 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 341 | # define _LIBCPP_NO_CFI |
Evgeniy Stepanov | 45dca2c | 2016-02-10 21:53:28 +0000 | [diff] [blame] | 342 | #endif |
| 343 | |
Louis Dionne | 51a2f0c | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 344 | #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L |
| 345 | # if defined(__FreeBSD__) |
| 346 | # define _LIBCPP_HAS_QUICK_EXIT |
| 347 | # define _LIBCPP_HAS_C11_FEATURES |
Dan Gohman | d6842df | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 348 | # elif defined(__Fuchsia__) || defined(__wasi__) |
Louis Dionne | 51a2f0c | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 349 | # define _LIBCPP_HAS_QUICK_EXIT |
Marshall Clow | 43d7c79 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 350 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 51a2f0c | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 351 | # 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 Clow | 43d7c79 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 359 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 51a2f0c | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 360 | # endif |
| 361 | # else // defined(_LIBCPP_HAS_MUSL_LIBC) |
| 362 | # define _LIBCPP_HAS_QUICK_EXIT |
Marshall Clow | 43d7c79 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 363 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 51a2f0c | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 364 | # define _LIBCPP_HAS_C11_FEATURES |
| 365 | # endif |
| 366 | # endif // __linux__ |
| 367 | #endif |
| 368 | |
Eric Fiselier | 272871b | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 369 | #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 Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 381 | #if defined(_LIBCPP_COMPILER_CLANG) |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 382 | |
Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 383 | // _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 Amini | 6dcde2c | 2017-04-06 01:10:22 +0000 | [diff] [blame] | 386 | (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \ |
Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 387 | defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) |
| 388 | #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
Tim Northover | c030063 | 2014-03-30 11:34:22 +0000 | [diff] [blame] | 389 | #endif |
| 390 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 391 | #if __has_feature(cxx_alignas) |
Howard Hinnant | cbdd089 | 2012-05-31 19:31:14 +0000 | [diff] [blame] | 392 | # define _ALIGNAS_TYPE(x) alignas(x) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 393 | # define _ALIGNAS(x) alignas(x) |
| 394 | #else |
Eric Fiselier | 272871b | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 395 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 396 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) |
| 397 | #endif |
| 398 | |
Marshall Clow | 4ffb67e | 2014-02-22 15:13:48 +0000 | [diff] [blame] | 399 | #if __cplusplus < 201103L |
Howard Hinnant | 3975ebd | 2010-09-16 23:27:26 +0000 | [diff] [blame] | 400 | typedef __char16_t char16_t; |
| 401 | typedef __char32_t char32_t; |
Howard Hinnant | 87eea6d | 2010-09-07 20:31:18 +0000 | [diff] [blame] | 402 | #endif |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 403 | |
Weiming Zhao | 994fb96 | 2016-04-21 05:28:18 +0000 | [diff] [blame] | 404 | #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 405 | #define _LIBCPP_NO_EXCEPTIONS |
| 406 | #endif |
| 407 | |
Eric Fiselier | ca57b14 | 2017-05-04 01:06:54 +0000 | [diff] [blame] | 408 | #if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI) |
Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 409 | #define _LIBCPP_NO_RTTI |
| 410 | #endif |
| 411 | |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 412 | #if !(__has_feature(cxx_strong_enums)) |
| 413 | #define _LIBCPP_HAS_NO_STRONG_ENUMS |
| 414 | #endif |
| 415 | |
Howard Hinnant | 4b7a43d | 2011-05-26 17:07:32 +0000 | [diff] [blame] | 416 | #if __has_feature(cxx_attributes) |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 417 | # define _LIBCPP_NORETURN [[noreturn]] |
Howard Hinnant | 4b7a43d | 2011-05-26 17:07:32 +0000 | [diff] [blame] | 418 | #else |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 419 | # define _LIBCPP_NORETURN __attribute__ ((noreturn)) |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 420 | #endif |
| 421 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 422 | #if !(__has_feature(cxx_lambdas)) |
| 423 | #define _LIBCPP_HAS_NO_LAMBDAS |
| 424 | #endif |
| 425 | |
| 426 | #if !(__has_feature(cxx_nullptr)) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 427 | # 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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 432 | #endif |
| 433 | |
| 434 | #if !(__has_feature(cxx_rvalue_references)) |
| 435 | #define _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 436 | #endif |
| 437 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 438 | #if !(__has_feature(cxx_auto_type)) |
| 439 | #define _LIBCPP_HAS_NO_AUTO_TYPE |
Howard Hinnant | 23369ee | 2011-07-29 21:35:53 +0000 | [diff] [blame] | 440 | #endif |
| 441 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 442 | #if !(__has_feature(cxx_variadic_templates)) |
| 443 | #define _LIBCPP_HAS_NO_VARIADICS |
| 444 | #endif |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 445 | |
Douglas Gregor | 35d2fcf | 2011-06-22 22:17:44 +0000 | [diff] [blame] | 446 | // 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 Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 455 | #if !(__has_feature(cxx_relaxed_constexpr)) |
| 456 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR |
| 457 | #endif |
| 458 | |
Marshall Clow | 4d23cc6 | 2015-03-17 15:30:22 +0000 | [diff] [blame] | 459 | #if !(__has_feature(cxx_variable_templates)) |
| 460 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES |
| 461 | #endif |
| 462 | |
Eric Fiselier | a3d6b12 | 2015-12-15 22:16:47 +0000 | [diff] [blame] | 463 | #if !(__has_feature(cxx_noexcept)) |
| 464 | #define _LIBCPP_HAS_NO_NOEXCEPT |
Howard Hinnant | 5d37fb3 | 2011-05-11 20:19:40 +0000 | [diff] [blame] | 465 | #endif |
| 466 | |
Marshall Clow | 7d4d519 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 467 | #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) |
| 468 | #define _LIBCPP_HAS_NO_ASAN |
| 469 | #endif |
| 470 | |
Marshall Clow | 040a034 | 2016-01-12 00:38:04 +0000 | [diff] [blame] | 471 | // Allow for build-time disabling of unsigned integer sanitization |
Jonathan Roelofs | 90a7bf9 | 2016-01-13 23:27:08 +0000 | [diff] [blame] | 472 | #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) |
Saleem Abdulrasool | f3adaaf | 2016-02-09 04:05:37 +0000 | [diff] [blame] | 473 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 474 | #endif |
Marshall Clow | 040a034 | 2016-01-12 00:38:04 +0000 | [diff] [blame] | 475 | |
Marshall Clow | aa0e236 | 2017-11-22 19:49:03 +0000 | [diff] [blame] | 476 | #if __has_builtin(__builtin_launder) |
Marshall Clow | 73d6c99 | 2018-01-03 02:32:28 +0000 | [diff] [blame] | 477 | #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 Clow | aa0e236 | 2017-11-22 19:49:03 +0000 | [diff] [blame] | 482 | #endif |
| 483 | |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 484 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 485 | |
Marshall Clow | cc5c12d | 2018-10-16 17:27:54 +0000 | [diff] [blame] | 486 | // 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 Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 491 | #elif defined(_LIBCPP_COMPILER_GCC) |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 492 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 493 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) |
Eric Fiselier | 272871b | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 494 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 495 | |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 496 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
Howard Hinnant | c26fd80 | 2011-05-31 13:13:49 +0000 | [diff] [blame] | 497 | |
Louis Dionne | f7410f4 | 2018-08-01 13:13:14 +0000 | [diff] [blame] | 498 | #if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 499 | #define _LIBCPP_NO_EXCEPTIONS |
| 500 | #endif |
| 501 | |
Marshall Clow | ac042ab | 2015-10-20 07:37:11 +0000 | [diff] [blame] | 502 | // Determine if GCC supports relaxed constexpr |
| 503 | #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L |
Eric Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 504 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR |
Marshall Clow | ac042ab | 2015-10-20 07:37:11 +0000 | [diff] [blame] | 505 | #endif |
| 506 | |
Richard Smith | ee568af | 2019-04-25 20:02:10 +0000 | [diff] [blame] | 507 | // GCC 5 supports variable templates |
Eric Fiselier | e39f4b9 | 2015-12-15 00:32:21 +0000 | [diff] [blame] | 508 | #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L |
Marshall Clow | 4d23cc6 | 2015-03-17 15:30:22 +0000 | [diff] [blame] | 509 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES |
Eric Fiselier | e39f4b9 | 2015-12-15 00:32:21 +0000 | [diff] [blame] | 510 | #endif |
Eric Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 511 | |
Marshall Clow | 7d4d519 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 512 | #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) |
| 513 | #define _LIBCPP_HAS_NO_ASAN |
| 514 | #endif |
| 515 | |
Marshall Clow | aa0e236 | 2017-11-22 19:49:03 +0000 | [diff] [blame] | 516 | #if _GNUC_VER >= 700 |
Marshall Clow | 73d6c99 | 2018-01-03 02:32:28 +0000 | [diff] [blame] | 517 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER |
| 518 | #endif |
| 519 | |
| 520 | #if _GNUC_VER >= 700 |
| 521 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS |
Marshall Clow | aa0e236 | 2017-11-22 19:49:03 +0000 | [diff] [blame] | 522 | #endif |
| 523 | |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 524 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 525 | |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 526 | #elif defined(_LIBCPP_COMPILER_MSVC) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 527 | |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 528 | #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 Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 536 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR |
Marshall Clow | 4d23cc6 | 2015-03-17 15:30:22 +0000 | [diff] [blame] | 537 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 538 | #define __alignof__ __alignof |
Richard Smith | 0405cc4 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 539 | #define _LIBCPP_NORETURN __declspec(noreturn) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 540 | #define _ALIGNAS(x) __declspec(align(x)) |
Eric Fiselier | c0acd34 | 2018-02-07 23:50:25 +0000 | [diff] [blame] | 541 | #define _ALIGNAS_TYPE(x) alignas(x) |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 542 | |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 543 | #define _LIBCPP_WEAK |
| 544 | |
Marshall Clow | 7d4d519 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 545 | #define _LIBCPP_HAS_NO_ASAN |
| 546 | |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 547 | #define _LIBCPP_ALWAYS_INLINE __forceinline |
| 548 | |
Tim Shen | 154f393 | 2018-07-30 22:27:38 +0000 | [diff] [blame] | 549 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION |
| 550 | |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 551 | #elif defined(_LIBCPP_COMPILER_IBM) |
Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 552 | |
| 553 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) |
Eric Fiselier | 272871b | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 554 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 555 | #define _ATTRIBUTE(x) __attribute__((x)) |
| 556 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
| 557 | |
Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 558 | #define _LIBCPP_HAS_NO_UNICODE_CHARS |
Marshall Clow | 4d23cc6 | 2015-03-17 15:30:22 +0000 | [diff] [blame] | 559 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES |
Howard Hinnant | 7f76450 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 560 | |
| 561 | #if defined(_AIX) |
| 562 | #define __MULTILOCALE_API |
| 563 | #endif |
| 564 | |
Marshall Clow | 7d4d519 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 565 | #define _LIBCPP_HAS_NO_ASAN |
| 566 | |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 567 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 568 | |
Tim Shen | 154f393 | 2018-07-30 22:27:38 +0000 | [diff] [blame] | 569 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION |
| 570 | |
Eric Fiselier | 5170d7d | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 571 | #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 572 | |
Saleem Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 573 | #if defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 574 | |
Peter Collingbourne | 9c2eed8 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 575 | #ifdef _DLL |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 576 | # define _LIBCPP_CRT_FUNC __declspec(dllimport) |
Peter Collingbourne | 9c2eed8 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 577 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 578 | # define _LIBCPP_CRT_FUNC |
Peter Collingbourne | 9c2eed8 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 579 | #endif |
| 580 | |
Shoaib Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 581 | #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 582 | # 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 Dionne | 07f95bd | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 586 | # define _LIBCPP_EXPORTED_FROM_ABI |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 587 | #elif defined(_LIBCPP_BUILDING_LIBRARY) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 588 | # define _LIBCPP_DLL_VIS __declspec(dllexport) |
Martin Storsjo | 93c37a9 | 2019-04-25 19:46:28 +0000 | [diff] [blame] | 589 | # 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 596 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS |
Louis Dionne | 07f95bd | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 597 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 598 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 599 | # 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 Dionne | 07f95bd | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 603 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 604 | #endif |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 605 | |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 606 | #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS |
| 607 | #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS |
| 608 | #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 609 | #define _LIBCPP_HIDDEN |
Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 610 | #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 611 | #define _LIBCPP_TEMPLATE_VIS |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 612 | #define _LIBCPP_ENUM_VIS |
Saleem Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 613 | |
Saleem Abdulrasool | e34f9d5 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 614 | #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 615 | |
| 616 | #ifndef _LIBCPP_HIDDEN |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 617 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 618 | # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) |
| 619 | # else |
| 620 | # define _LIBCPP_HIDDEN |
| 621 | # endif |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 622 | #endif |
| 623 | |
Shoaib Meenai | 15da97c | 2017-03-09 00:18:00 +0000 | [diff] [blame] | 624 | #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 625 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 626 | // The inline should be removed once PR32114 is resolved |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 627 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN |
| 628 | # else |
| 629 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 630 | # endif |
Shoaib Meenai | 15da97c | 2017-03-09 00:18:00 +0000 | [diff] [blame] | 631 | #endif |
Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 632 | |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 633 | #ifndef _LIBCPP_FUNC_VIS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 634 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 635 | # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) |
| 636 | # else |
| 637 | # define _LIBCPP_FUNC_VIS |
| 638 | # endif |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 639 | #endif |
| 640 | |
| 641 | #ifndef _LIBCPP_TYPE_VIS |
Shoaib Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 642 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Shoaib Meenai | 6b73492 | 2017-03-02 03:22:18 +0000 | [diff] [blame] | 643 | # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 644 | # else |
Shoaib Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 645 | # define _LIBCPP_TYPE_VIS |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 646 | # endif |
| 647 | #endif |
| 648 | |
Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 649 | #ifndef _LIBCPP_TEMPLATE_VIS |
Shoaib Meenai | 6b73492 | 2017-03-02 03:22:18 +0000 | [diff] [blame] | 650 | # 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 Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 659 | #endif |
| 660 | |
Louis Dionne | 07f95bd | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 661 | #ifndef _LIBCPP_EXPORTED_FROM_ABI |
Thomas Anderson | e713cc0 | 2018-12-13 20:06:14 +0000 | [diff] [blame] | 662 | # 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 Fiselier | dae3960 | 2017-01-16 21:01:00 +0000 | [diff] [blame] | 667 | #endif |
| 668 | |
Shoaib Meenai | e6479bc | 2016-11-16 22:18:10 +0000 | [diff] [blame] | 669 | #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 670 | #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS |
Shoaib Meenai | e6479bc | 2016-11-16 22:18:10 +0000 | [diff] [blame] | 671 | #endif |
| 672 | |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 673 | #ifndef _LIBCPP_EXCEPTION_ABI |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 674 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 675 | # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) |
| 676 | # else |
| 677 | # define _LIBCPP_EXCEPTION_ABI |
| 678 | # endif |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 679 | #endif |
| 680 | |
| 681 | #ifndef _LIBCPP_ENUM_VIS |
Shoaib Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 682 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 683 | # 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 Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 690 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) |
Shoaib Meenai | 24e8dbd | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 691 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 692 | # else |
| 693 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 694 | # endif |
| 695 | #endif |
| 696 | |
Shoaib Meenai | e5cbce4 | 2016-09-19 18:29:07 +0000 | [diff] [blame] | 697 | #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 698 | #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
Shoaib Meenai | e5cbce4 | 2016-09-19 18:29:07 +0000 | [diff] [blame] | 699 | #endif |
| 700 | |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 701 | #if __has_attribute(internal_linkage) |
| 702 | # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) |
| 703 | #else |
| 704 | # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE |
Eric Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 705 | #endif |
| 706 | |
Louis Dionne | 640fa25 | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 707 | #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 Dionne | 9009625 | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 712 | // template instantiations in the dylib) by always inlining those entities. |
Louis Dionne | 640fa25 | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 713 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE |
| 714 | #endif |
| 715 | |
Louis Dionne | 61b0a00 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 716 | #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 Fiselier | bb2c95d | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 724 | #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 Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 734 | #ifndef _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 61b0a00 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 735 | # if _LIBCPP_HIDE_FROM_ABI_PER_TU |
| 736 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE |
| 737 | # else |
Louis Dionne | 640fa25 | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 738 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION |
Louis Dionne | 61b0a00 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 739 | # endif |
Louis Dionne | 67fff22 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 740 | #endif |
| 741 | |
Louis Dionne | 5ae92f0 | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 742 | #ifdef _LIBCPP_BUILDING_LIBRARY |
| 743 | # if _LIBCPP_ABI_VERSION > 1 |
| 744 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 745 | # else |
Louis Dionne | 5ae92f0 | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 746 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 747 | # endif |
Louis Dionne | 5ae92f0 | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 748 | #else |
| 749 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
Eric Fiselier | 6dbed46 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 750 | #endif |
| 751 | |
Louis Dionne | 5ae92f0 | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 752 | // Just so we can migrate to the new macros gradually. |
| 753 | #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 5ae92f0 | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 754 | |
Eric Fiselier | 94ce26b | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 755 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. |
Eric Fiselier | e6f91d8 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 756 | #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { |
Eric Fiselier | 94ce26b | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 757 | #define _LIBCPP_END_NAMESPACE_STD } } |
Eric Fiselier | e6f91d8 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 758 | #define _VSTD std::_LIBCPP_ABI_NAMESPACE |
Eric Fiselier | 94ce26b | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 759 | _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 Fiselier | 833d644 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 774 | #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 Fiselier | a3d6b12 | 2015-12-15 22:16:47 +0000 | [diff] [blame] | 780 | #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 Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 788 | #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS |
Howard Hinnant | 60a0a8e | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 789 | typedef unsigned short char16_t; |
| 790 | typedef unsigned int char32_t; |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 791 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 792 | |
Stephan Tolksdorf | 8a71d23 | 2014-03-26 19:45:52 +0000 | [diff] [blame] | 793 | #ifndef __SIZEOF_INT128__ |
| 794 | #define _LIBCPP_HAS_NO_INT128 |
| 795 | #endif |
| 796 | |
Eric Fiselier | 4e3e15a | 2016-09-25 03:34:28 +0000 | [diff] [blame] | 797 | #ifdef _LIBCPP_CXX03_LANG |
Eric Fiselier | 1643cad | 2019-06-18 20:50:25 +0000 | [diff] [blame] | 798 | # define static_assert(...) _Static_assert(__VA_ARGS__) |
| 799 | # define decltype(...) __decltype(__VA_ARGS__) |
Eric Fiselier | 4e3e15a | 2016-09-25 03:34:28 +0000 | [diff] [blame] | 800 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 801 | |
Eric Fiselier | bf5a8da | 2019-06-21 13:56:13 +0000 | [diff] [blame] | 802 | #ifdef _LIBCPP_CXX03_LANG |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 803 | # define _LIBCPP_CONSTEXPR |
Howard Hinnant | 27b4fd3 | 2012-04-02 00:40:41 +0000 | [diff] [blame] | 804 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 805 | # define _LIBCPP_CONSTEXPR constexpr |
Howard Hinnant | 1387038 | 2010-09-06 19:10:31 +0000 | [diff] [blame] | 806 | #endif |
| 807 | |
Eric Fiselier | 8c57032 | 2016-11-18 06:42:17 +0000 | [diff] [blame] | 808 | #ifdef _LIBCPP_CXX03_LANG |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 809 | # define _LIBCPP_DEFAULT {} |
Howard Hinnant | 74f4da7 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 810 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 811 | # define _LIBCPP_DEFAULT = default; |
Howard Hinnant | 74f4da7 | 2013-05-02 20:18:43 +0000 | [diff] [blame] | 812 | #endif |
| 813 | |
Eric Fiselier | 8eb066a | 2017-01-06 20:58:25 +0000 | [diff] [blame] | 814 | #ifdef _LIBCPP_CXX03_LANG |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 815 | # define _LIBCPP_EQUAL_DELETE |
Eric Fiselier | db21506 | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 816 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 817 | # define _LIBCPP_EQUAL_DELETE = delete |
Eric Fiselier | db21506 | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 818 | #endif |
| 819 | |
Nuno Lopes | 518d150 | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 820 | #ifdef __GNUC__ |
Louis Dionne | d772e80 | 2019-02-26 06:34:42 +0000 | [diff] [blame] | 821 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) |
Nuno Lopes | 518d150 | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 822 | #else |
Louis Dionne | d772e80 | 2019-02-26 06:34:42 +0000 | [diff] [blame] | 823 | # define _LIBCPP_NOALIAS |
Nuno Lopes | 518d150 | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 824 | #endif |
| 825 | |
Eric Fiselier | 1a147b7 | 2017-01-13 18:03:46 +0000 | [diff] [blame] | 826 | #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ |
Eric Fiselier | bc06f26 | 2016-12-30 14:05:52 +0000 | [diff] [blame] | 827 | (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 828 | # define _LIBCPP_EXPLICIT explicit |
Howard Hinnant | 7786188 | 2012-02-21 21:46:43 +0000 | [diff] [blame] | 829 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 830 | # define _LIBCPP_EXPLICIT |
Howard Hinnant | 7786188 | 2012-02-21 21:46:43 +0000 | [diff] [blame] | 831 | #endif |
| 832 | |
Richard Smith | 73c1fce | 2014-06-04 19:54:15 +0000 | [diff] [blame] | 833 | #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 834 | #define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE |
Richard Smith | 73c1fce | 2014-06-04 19:54:15 +0000 | [diff] [blame] | 835 | #endif |
| 836 | |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 837 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 838 | # 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 Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 841 | _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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 844 | }; |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 845 | #else // _LIBCPP_HAS_NO_STRONG_ENUMS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 846 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x |
| 847 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 848 | #endif // _LIBCPP_HAS_NO_STRONG_ENUMS |
| 849 | |
Howard Hinnant | 5e57142 | 2013-08-23 20:10:18 +0000 | [diff] [blame] | 850 | #ifdef _LIBCPP_DEBUG |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 851 | # 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 Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 861 | #endif |
| 862 | |
Shoaib Meenai | e1c9dfb | 2017-04-13 20:13:32 +0000 | [diff] [blame] | 863 | #ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE |
| 864 | #define _LIBCPP_EXTERN_TEMPLATE(...) |
| 865 | #define _LIBCPP_EXTERN_TEMPLATE2(...) |
| 866 | #endif |
| 867 | |
Howard Hinnant | ff92677 | 2012-11-06 21:08:48 +0000 | [diff] [blame] | 868 | #ifndef _LIBCPP_EXTERN_TEMPLATE |
Justin Bogner | 98c4e40 | 2014-08-15 17:58:56 +0000 | [diff] [blame] | 869 | #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; |
Howard Hinnant | ff92677 | 2012-11-06 21:08:48 +0000 | [diff] [blame] | 870 | #endif |
| 871 | |
Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 872 | #ifndef _LIBCPP_EXTERN_TEMPLATE2 |
| 873 | #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; |
| 874 | #endif |
| 875 | |
Martin Storsjo | 9de8659 | 2017-11-23 10:38:18 +0000 | [diff] [blame] | 876 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ |
Ed Schouten | 4c42c4e | 2015-03-10 09:26:38 +0000 | [diff] [blame] | 877 | defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) |
Sean Hunt | f3907e6 | 2011-07-15 05:40:33 +0000 | [diff] [blame] | 878 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 |
| 879 | #endif |
Yaron Keren | f1ebe26 | 2013-12-20 13:19:45 +0000 | [diff] [blame] | 880 | |
Ben Craig | f8865b6 | 2016-02-10 13:47:25 +0000 | [diff] [blame] | 881 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 882 | // Most unix variants have catopen. These are the specific ones that don't. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 883 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) |
| 884 | # define _LIBCPP_HAS_CATOPEN 1 |
| 885 | # endif |
Ben Craig | f8865b6 | 2016-02-10 13:47:25 +0000 | [diff] [blame] | 886 | #endif |
Ed Schouten | 0251f0f | 2015-03-11 16:39:36 +0000 | [diff] [blame] | 887 | |
Marshall Clow | 53e2763 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 888 | #ifdef __FreeBSD__ |
David Chisnall | 91a8272 | 2011-11-13 17:15:33 +0000 | [diff] [blame] | 889 | #define _DECLARE_C99_LDBL_MATH 1 |
| 890 | #endif |
Sean Hunt | f3907e6 | 2011-07-15 05:40:33 +0000 | [diff] [blame] | 891 | |
Reid Kleckner | efb6d58 | 2018-04-19 22:12:10 +0000 | [diff] [blame] | 892 | // 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 Dionne | ae5d5c8 | 2018-12-17 22:22:44 +0000 | [diff] [blame] | 895 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
Eric Fiselier | e718b5a | 2019-03-05 01:57:01 +0000 | [diff] [blame] | 896 | #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) |
Louis Dionne | 9009625 | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 897 | // We're deferring to Microsoft's STL to provide aligned new et al. We don't |
Thomas Anderson | c79c933 | 2019-01-30 19:08:32 +0000 | [diff] [blame] | 898 | // have it unless the language feature test macro is defined. |
| 899 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
Reid Kleckner | efb6d58 | 2018-04-19 22:12:10 +0000 | [diff] [blame] | 900 | #endif |
| 901 | |
Eric Fiselier | d54d974 | 2017-01-20 01:47:26 +0000 | [diff] [blame] | 902 | #if defined(__APPLE__) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 903 | # 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 Fiselier | d54d974 | 2017-01-20 01:47:26 +0000 | [diff] [blame] | 907 | #endif // defined(__APPLE__) |
| 908 | |
Louis Dionne | 836b7e9 | 2018-08-10 13:24:56 +0000 | [diff] [blame] | 909 | #if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ |
Eric Fiselier | 657a130 | 2018-10-11 00:17:24 +0000 | [diff] [blame] | 910 | (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ |
| 911 | (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)) |
Louis Dionne | 836b7e9 | 2018-08-10 13:24:56 +0000 | [diff] [blame] | 912 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION |
| 913 | #endif |
Eric Fiselier | a831287 | 2018-03-22 04:42:56 +0000 | [diff] [blame] | 914 | |
Marshall Clow | 53e2763 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 915 | #if defined(__APPLE__) || defined(__FreeBSD__) |
Howard Hinnant | 866569b | 2011-09-28 23:39:33 +0000 | [diff] [blame] | 916 | #define _LIBCPP_HAS_DEFAULTRUNELOCALE |
Sean Hunt | e59f724 | 2011-07-09 01:09:31 +0000 | [diff] [blame] | 917 | #endif |
| 918 | |
Marshall Clow | 53e2763 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 919 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) |
Sean Hunt | 6f0342c | 2011-07-09 03:40:04 +0000 | [diff] [blame] | 920 | #define _LIBCPP_WCTYPE_IS_MASK |
| 921 | #endif |
| 922 | |
Marshall Clow | 9648447 | 2018-12-11 04:35:44 +0000 | [diff] [blame] | 923 | #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) |
| 924 | #define _LIBCPP_NO_HAS_CHAR8_T |
| 925 | #endif |
| 926 | |
Louis Dionne | 13cf3b9 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 927 | // Deprecation macros. |
Louis Dionne | 9807685 | 2019-03-12 20:10:06 +0000 | [diff] [blame] | 928 | // |
| 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 Dionne | 13cf3b9 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 932 | # 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 Clow | 6db12cb | 2013-09-28 18:35:31 +0000 | [diff] [blame] | 939 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 940 | # define _LIBCPP_DEPRECATED |
Marshall Clow | 6db12cb | 2013-09-28 18:35:31 +0000 | [diff] [blame] | 941 | #endif |
| 942 | |
Louis Dionne | 13cf3b9 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 943 | #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 Clow | ac93d0e | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 961 | #if _LIBCPP_STD_VER <= 11 |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 962 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 |
Marshall Clow | ac93d0e | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 963 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 964 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit |
Marshall Clow | ac93d0e | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 965 | #endif |
| 966 | |
Eric Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 967 | #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 968 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr |
Eric Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 969 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 970 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Eric Fiselier | 8fcc272 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 971 | #endif |
| 972 | |
Eric Fiselier | 735026e | 2016-03-17 03:30:56 +0000 | [diff] [blame] | 973 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 974 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr |
Eric Fiselier | 735026e | 2016-03-17 03:30:56 +0000 | [diff] [blame] | 975 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 976 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 |
Eric Fiselier | 735026e | 2016-03-17 03:30:56 +0000 | [diff] [blame] | 977 | #endif |
| 978 | |
Marshall Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 979 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 980 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr |
Marshall Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 981 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 982 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Marshall Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 983 | #endif |
| 984 | |
Roman Lebedev | caf40ae | 2018-09-22 17:54:48 +0000 | [diff] [blame] | 985 | // 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 Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1009 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1010 | # define _LIBCPP_NODISCARD_AFTER_CXX17 |
Marshall Clow | c9f5f10 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1011 | #endif |
| 1012 | |
Marshall Clow | c58e472 | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 1013 | #if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1014 | # define _LIBCPP_INLINE_VAR inline |
Marshall Clow | c58e472 | 2018-01-02 17:17:01 +0000 | [diff] [blame] | 1015 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1016 | # define _LIBCPP_INLINE_VAR |
Eric Fiselier | a93ebec | 2016-11-17 20:08:43 +0000 | [diff] [blame] | 1017 | #endif |
| 1018 | |
Dimitry Andric | 8966350 | 2015-08-19 06:43:33 +0000 | [diff] [blame] | 1019 | #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 Clow | c005c7e | 2018-07-13 16:35:26 +0000 | [diff] [blame] | 1025 | #ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG |
Marshall Clow | 1548d77 | 2018-07-13 17:31:36 +0000 | [diff] [blame] | 1026 | #if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) |
Marshall Clow | c005c7e | 2018-07-13 16:35:26 +0000 | [diff] [blame] | 1027 | #define _LIBCPP_CONSTEXPR_IF_NODEBUG |
Marshall Clow | e585baf | 2018-07-13 17:24:59 +0000 | [diff] [blame] | 1028 | #else |
| 1029 | #define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr |
Marshall Clow | c005c7e | 2018-07-13 16:35:26 +0000 | [diff] [blame] | 1030 | #endif |
| 1031 | #endif |
| 1032 | |
Louis Dionne | 40056ac | 2019-04-17 18:20:19 +0000 | [diff] [blame] | 1033 | #if __has_attribute(no_destroy) |
| 1034 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) |
| 1035 | #else |
| 1036 | # define _LIBCPP_NO_DESTROY |
| 1037 | #endif |
| 1038 | |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 1039 | #ifndef _LIBCPP_HAS_NO_ASAN |
Eric Fiselier | 5ac2f14 | 2016-12-23 20:03:52 +0000 | [diff] [blame] | 1040 | _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 1041 | const void *, const void *, const void *, const void *); |
| 1042 | #endif |
| 1043 | |
Howard Hinnant | f677bc4 | 2013-10-04 21:24:21 +0000 | [diff] [blame] | 1044 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1048 | # if defined(__GNUC__) && \ |
| 1049 | ((__GNUC__ >= 5) || \ |
| 1050 | (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \ |
| 1051 | !defined(__GXX_RTTI) |
Howard Hinnant | f677bc4 | 2013-10-04 21:24:21 +0000 | [diff] [blame] | 1052 | # define _LIBCPP_NO_RTTI |
Eric Fiselier | ab2f54f | 2017-05-10 21:40:58 +0000 | [diff] [blame] | 1053 | # elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) |
Howard Hinnant | f677bc4 | 2013-10-04 21:24:21 +0000 | [diff] [blame] | 1054 | # define _LIBCPP_NO_RTTI |
| 1055 | # endif |
| 1056 | #endif |
| 1057 | |
Howard Hinnant | 5a8b578 | 2013-10-04 23:56:37 +0000 | [diff] [blame] | 1058 | #ifndef _LIBCPP_WEAK |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1059 | #define _LIBCPP_WEAK __attribute__((__weak__)) |
Howard Hinnant | 5a8b578 | 2013-10-04 23:56:37 +0000 | [diff] [blame] | 1060 | #endif |
| 1061 | |
Asiri Rathnayake | 35ff03b | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1062 | // Thread API |
Eric Fiselier | 1572c46 | 2017-01-06 23:15:16 +0000 | [diff] [blame] | 1063 | #if !defined(_LIBCPP_HAS_NO_THREADS) && \ |
Asiri Rathnayake | 3f017a8 | 2017-02-27 16:10:57 +0000 | [diff] [blame] | 1064 | !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ |
Eric Fiselier | 2df956f | 2017-05-10 21:34:58 +0000 | [diff] [blame] | 1065 | !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ |
Asiri Rathnayake | 3f017a8 | 2017-02-27 16:10:57 +0000 | [diff] [blame] | 1066 | !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1067 | # if defined(__FreeBSD__) || \ |
| 1068 | defined(__Fuchsia__) || \ |
Dan Gohman | d6842df | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 1069 | defined(__wasi__) || \ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1070 | defined(__NetBSD__) || \ |
| 1071 | defined(__linux__) || \ |
Louis Dionne | 33f9849 | 2018-11-20 21:14:05 +0000 | [diff] [blame] | 1072 | defined(__GNU__) || \ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1073 | defined(__APPLE__) || \ |
| 1074 | defined(__CloudABI__) || \ |
| 1075 | defined(__sun__) || \ |
Alexander Richardson | 2be41bb | 2018-07-24 12:40:56 +0000 | [diff] [blame] | 1076 | (defined(__MINGW32__) && __has_include(<pthread.h>)) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1077 | # 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 Rathnayake | 35ff03b | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1083 | #endif // _LIBCPP_HAS_NO_THREADS |
| 1084 | |
Ben Craig | 5163e46 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 1085 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1086 | #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ |
| 1087 | _LIBCPP_HAS_NO_THREADS is not defined. |
Ben Craig | 5163e46 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 1088 | #endif |
Asiri Rathnayake | 35ff03b | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1089 | |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 1090 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1091 | #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ |
| 1092 | _LIBCPP_HAS_NO_THREADS is defined. |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 1093 | #endif |
| 1094 | |
Eric Fiselier | a245f9b | 2014-12-06 20:09:11 +0000 | [diff] [blame] | 1095 | #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1096 | #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ |
| 1097 | _LIBCPP_HAS_NO_THREADS is defined. |
Eric Fiselier | a245f9b | 2014-12-06 20:09:11 +0000 | [diff] [blame] | 1098 | #endif |
| 1099 | |
Eric Fiselier | 47e6bb8 | 2019-07-07 01:20:54 +0000 | [diff] [blame] | 1100 | // The Apple, glibc, and Bionic implementation of pthreads implements |
Eric Fiselier | a386369 | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1101 | // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 |
| 1102 | // mutexes have no destroy mechanism. |
Eric Fiselier | 47e6bb8 | 2019-07-07 01:20:54 +0000 | [diff] [blame] | 1103 | // TODO(EricWF): Enable this optimization on Apple and Bionic platforms after |
| 1104 | // speaking to their respective stakeholders. |
Eric Fiselier | a386369 | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1105 | #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ |
| 1106 | || defined(_LIBCPP_HAS_THREAD_API_WIN32) |
Eric Fiselier | 47e6bb8 | 2019-07-07 01:20:54 +0000 | [diff] [blame] | 1107 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION |
| 1108 | #endif |
| 1109 | |
Eric Fiselier | a386369 | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1110 | // 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 Schouten | b33ae5b | 2015-03-12 15:44:39 +0000 | [diff] [blame] | 1117 | // 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 Schouten | abd06b4 | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 1125 | // 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 Albert | 7d7f3cc | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 1132 | #if defined(__BIONIC__) || defined(__CloudABI__) || \ |
Dan Gohman | d6842df | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 1133 | defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) |
Dan Albert | 6272ae5 | 2015-03-11 00:51:06 +0000 | [diff] [blame] | 1134 | #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE |
| 1135 | #endif |
| 1136 | |
Ed Schouten | 1e17bc1 | 2016-12-30 10:44:00 +0000 | [diff] [blame] | 1137 | // Thread-unsafe functions such as strtok() and localtime() |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 1138 | // are not available. |
| 1139 | #ifdef __CloudABI__ |
| 1140 | #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS |
| 1141 | #endif |
| 1142 | |
Eric Fiselier | 50ca324 | 2017-01-14 04:27:58 +0000 | [diff] [blame] | 1143 | #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1144 | # define _LIBCPP_HAS_C_ATOMIC_IMP |
Richard Smith | ee568af | 2019-04-25 20:02:10 +0000 | [diff] [blame] | 1145 | #elif defined(_LIBCPP_COMPILER_GCC) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1146 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1147 | #endif |
| 1148 | |
Davide Italiano | a011222 | 2019-03-05 18:40:49 +0000 | [diff] [blame] | 1149 | #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ |
| 1150 | !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ |
| 1151 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \ |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1152 | || defined(_LIBCPP_HAS_NO_THREADS) |
Davide Italiano | a011222 | 2019-03-05 18:40:49 +0000 | [diff] [blame] | 1153 | # 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 Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1161 | #endif |
| 1162 | |
Marshall Clow | 7a3731f | 2016-01-11 19:27:10 +0000 | [diff] [blame] | 1163 | #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 1164 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame] | 1165 | #endif |
| 1166 | |
Saleem Abdulrasool | 5748d2b | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1167 | #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1168 | # if defined(__clang__) && __has_attribute(acquire_capability) |
Saleem Abdulrasool | 5748d2b | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1169 | // 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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1172 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 1173 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS |
| 1174 | # endif |
| 1175 | # endif |
Saleem Abdulrasool | 5748d2b | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1176 | #endif |
Eric Fiselier | a15e8c3 | 2016-03-16 02:30:06 +0000 | [diff] [blame] | 1177 | |
Eric Fiselier | 766a31a | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1178 | #if __has_attribute(require_constant_initialization) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1179 | # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) |
Eric Fiselier | 766a31a | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1180 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1181 | # define _LIBCPP_SAFE_STATIC |
Eric Fiselier | 766a31a | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1182 | #endif |
| 1183 | |
Eric Fiselier | 35ce485 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 1184 | #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1185 | #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF |
Eric Fiselier | 35ce485 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 1186 | #endif |
| 1187 | |
Eric Fiselier | 250205c | 2019-04-24 17:54:25 +0000 | [diff] [blame] | 1188 | #if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900 |
| 1189 | #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED |
| 1190 | #endif |
| 1191 | |
Shoaib Meenai | 3b2cf96 | 2016-10-31 15:09:10 +0000 | [diff] [blame] | 1192 | #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1193 | # if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) |
| 1194 | # define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS |
| 1195 | # endif |
Shoaib Meenai | 3b2cf96 | 2016-10-31 15:09:10 +0000 | [diff] [blame] | 1196 | #endif |
| 1197 | |
Eric Fiselier | ebaf7da | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1198 | #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1199 | # define _LIBCPP_DIAGNOSE_WARNING(...) \ |
| 1200 | __attribute__((diagnose_if(__VA_ARGS__, "warning"))) |
| 1201 | # define _LIBCPP_DIAGNOSE_ERROR(...) \ |
| 1202 | __attribute__((diagnose_if(__VA_ARGS__, "error"))) |
Eric Fiselier | ebaf7da | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1203 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1204 | # define _LIBCPP_DIAGNOSE_WARNING(...) |
| 1205 | # define _LIBCPP_DIAGNOSE_ERROR(...) |
Eric Fiselier | ebaf7da | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1206 | #endif |
| 1207 | |
Eric Fiselier | 799d02d | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1208 | // Use a function like macro to imply that it must be followed by a semicolon |
Reid Kleckner | 6115b72 | 2018-11-01 18:24:03 +0000 | [diff] [blame] | 1209 | #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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1214 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) |
Eric Fiselier | 799d02d | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1215 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1216 | # define _LIBCPP_FALLTHROUGH() ((void)0) |
Eric Fiselier | 799d02d | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1217 | #endif |
| 1218 | |
Eric Fiselier | 78822a6 | 2019-06-12 02:03:31 +0000 | [diff] [blame] | 1219 | #if __has_attribute(__nodebug__) |
| 1220 | #define _LIBCPP_NODEBUG __attribute__((__nodebug__)) |
Eric Fiselier | 430415e | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1221 | #else |
| 1222 | #define _LIBCPP_NODEBUG |
| 1223 | #endif |
| 1224 | |
Eric Fiselier | 78822a6 | 2019-06-12 02:03:31 +0000 | [diff] [blame] | 1225 | #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 Fiselier | 7d24e91 | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1234 | #if defined(_LIBCPP_ABI_MICROSOFT) && \ |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1235 | (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) |
| 1236 | # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) |
Eric Fiselier | 7d24e91 | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1237 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1238 | # define _LIBCPP_DECLSPEC_EMPTY_BASES |
Eric Fiselier | 7d24e91 | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1239 | #endif |
| 1240 | |
Eric Fiselier | 515ba55 | 2017-02-17 03:25:08 +0000 | [diff] [blame] | 1241 | #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1242 | #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 Fiselier | 515ba55 | 2017-02-17 03:25:08 +0000 | [diff] [blame] | 1246 | #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES |
| 1247 | |
Marshall Clow | 59bcc87 | 2017-03-24 03:40:36 +0000 | [diff] [blame] | 1248 | #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1249 | #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
Marshall Clow | 59bcc87 | 2017-03-24 03:40:36 +0000 | [diff] [blame] | 1250 | #endif |
| 1251 | |
Eric Fiselier | 7b41c79 | 2017-04-12 23:08:46 +0000 | [diff] [blame] | 1252 | #if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1253 | #define _LIBCPP_HAS_NO_IS_AGGREGATE |
Eric Fiselier | 7b41c79 | 2017-04-12 23:08:46 +0000 | [diff] [blame] | 1254 | #endif |
| 1255 | |
Eric Fiselier | c80ef6e | 2017-05-26 01:52:59 +0000 | [diff] [blame] | 1256 | #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1257 | #define _LIBCPP_HAS_NO_COROUTINES |
Eric Fiselier | c80ef6e | 2017-05-26 01:52:59 +0000 | [diff] [blame] | 1258 | #endif |
| 1259 | |
Eric Fiselier | 24258c4 | 2018-04-06 21:37:23 +0000 | [diff] [blame] | 1260 | // 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 Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1265 | // 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 Dionne | 080f06d | 2019-03-20 21:18:14 +0000 | [diff] [blame] | 1269 | __has_feature(attribute_availability_in_templates) && \ |
| 1270 | __has_extension(pragma_clang_attribute_external_declaration) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1271 | # ifdef __APPLE__ |
| 1272 | # define _LIBCPP_USE_AVAILABILITY_APPLE |
| 1273 | # endif |
Mehdi Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1274 | #endif |
| 1275 | |
| 1276 | // Define availability macros. |
| 1277 | #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1278 | # 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 Dionne | 13b7f7b | 2018-11-19 15:37:04 +0000 | [diff] [blame] | 1283 | # 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 Dionne | 13b7f7b | 2018-11-19 15:37:04 +0000 | [diff] [blame] | 1290 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ |
| 1291 | _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1292 | # 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 Dionne | 51ecd6c | 2019-03-20 14:34:00 +0000 | [diff] [blame] | 1313 | # define _LIBCPP_AVAILABILITY_FILESYSTEM \ |
Louis Dionne | ba4d4df | 2019-07-03 18:29:02 +0000 | [diff] [blame] | 1314 | __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 Dionne | 080f06d | 2019-03-20 21:18:14 +0000 | [diff] [blame] | 1318 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \ |
Louis Dionne | ba4d4df | 2019-07-03 18:29:02 +0000 | [diff] [blame] | 1319 | _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 Dionne | 080f06d | 2019-03-20 21:18:14 +0000 | [diff] [blame] | 1323 | # 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 Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1328 | #else |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1329 | # define _LIBCPP_AVAILABILITY_SHARED_MUTEX |
Louis Dionne | 13b7f7b | 2018-11-19 15:37:04 +0000 | [diff] [blame] | 1330 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1331 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1332 | # 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 Dionne | 51ecd6c | 2019-03-20 14:34:00 +0000 | [diff] [blame] | 1339 | # define _LIBCPP_AVAILABILITY_FILESYSTEM |
Louis Dionne | 080f06d | 2019-03-20 21:18:14 +0000 | [diff] [blame] | 1340 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH |
| 1341 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
Mehdi Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1342 | #endif |
| 1343 | |
| 1344 | // Define availability that depends on _LIBCPP_NO_EXCEPTIONS. |
| 1345 | #ifdef _LIBCPP_NO_EXCEPTIONS |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1346 | # define _LIBCPP_AVAILABILITY_FUTURE |
| 1347 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST |
Louis Dionne | 13b7f7b | 2018-11-19 15:37:04 +0000 | [diff] [blame] | 1348 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS |
| 1349 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS |
Mehdi Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1350 | #else |
Louis Dionne | 7aa4878 | 2018-11-20 23:18:25 +0000 | [diff] [blame] | 1351 | # 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 Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1355 | #endif |
| 1356 | |
Louis Dionne | caae3ec | 2018-12-06 00:24:58 +0000 | [diff] [blame] | 1357 | // 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 Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1365 | ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ |
Duncan P. N. Exon Smith | 2b93569 | 2017-06-18 16:50:23 +0000 | [diff] [blame] | 1366 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \ |
Mehdi Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1367 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ |
Duncan P. N. Exon Smith | 2b93569 | 2017-06-18 16:50:23 +0000 | [diff] [blame] | 1368 | __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)) |
Louis Dionne | caae3ec | 2018-12-06 00:24:58 +0000 | [diff] [blame] | 1369 | # define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB |
Mehdi Amini | 907c119 | 2017-05-04 17:08:54 +0000 | [diff] [blame] | 1370 | #endif |
| 1371 | |
Eric Fiselier | 018a3d5 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1372 | #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 Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1377 | # define _LIBCPP_PUSH_MACROS |
| 1378 | # define _LIBCPP_POP_MACROS |
Eric Fiselier | 018a3d5 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1379 | #else |
| 1380 | // Don't warn about macro conflicts when we can restore them at the |
| 1381 | // end of the header. |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1382 | # 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 Fiselier | 018a3d5 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1400 | #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) |
| 1401 | |
Peter Collingbourne | 1cadd88 | 2018-01-24 04:30:19 +0000 | [diff] [blame] | 1402 | #ifndef _LIBCPP_NO_AUTO_LINK |
Logan Chien | 7102892 | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1403 | # 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 Collingbourne | 1cadd88 | 2018-01-24 04:30:19 +0000 | [diff] [blame] | 1410 | #endif // _LIBCPP_NO_AUTO_LINK |
Eric Fiselier | 7320213 | 2017-06-16 01:57:41 +0000 | [diff] [blame] | 1411 | |
Petr Hosek | 7be0d09 | 2019-01-13 22:15:37 +0000 | [diff] [blame] | 1412 | #define _LIBCPP_UNUSED_VAR(x) ((void)(x)) |
| 1413 | |
Eric Fiselier | 7320213 | 2017-06-16 01:57:41 +0000 | [diff] [blame] | 1414 | #endif // __cplusplus |
| 1415 | |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1416 | #endif // _LIBCPP_CONFIG |