Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 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 | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_CONFIG |
| 11 | #define _LIBCPP_CONFIG |
| 12 | |
Louis Dionne | 94870d8 | 2020-06-26 12:08:59 -0400 | [diff] [blame] | 13 | #include <__config_site> |
| 14 | |
Eric Fiselier | a80af82 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 15 | #if defined(_MSC_VER) && !defined(__clang__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 16 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 18 | # endif |
Saleem Abdulrasool | f154c77 | 2017-01-29 18:16:33 +0000 | [diff] [blame] | 19 | #endif |
Eric Fiselier | a80af82 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 20 | |
| 21 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 23 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | |
Eric Fiselier | a80af82 | 2015-11-06 06:30:12 +0000 | [diff] [blame] | 25 | #ifdef __cplusplus |
| 26 | |
Tom Stellard | ce41e66 | 2021-07-27 21:51:07 -0700 | [diff] [blame] | 27 | #define _LIBCPP_VERSION 14000 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 28 | |
Eric Fiselier | fa1f1c1 | 2019-06-26 00:05:14 +0000 | [diff] [blame] | 29 | #ifndef _LIBCPP_ABI_VERSION |
| 30 | # define _LIBCPP_ABI_VERSION 1 |
| 31 | #endif |
| 32 | |
hyd-dev | b987b45 | 2020-09-02 12:22:29 -0400 | [diff] [blame] | 33 | #if __STDC_HOSTED__ == 0 |
Davide Italiano | 011f80a | 2019-03-05 18:40:49 +0000 | [diff] [blame] | 34 | # define _LIBCPP_FREESTANDING |
| 35 | #endif |
| 36 | |
Eric Fiselier | 02cea5e | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 37 | #ifndef _LIBCPP_STD_VER |
| 38 | # if __cplusplus <= 201103L |
| 39 | # define _LIBCPP_STD_VER 11 |
| 40 | # elif __cplusplus <= 201402L |
| 41 | # define _LIBCPP_STD_VER 14 |
| 42 | # elif __cplusplus <= 201703L |
| 43 | # define _LIBCPP_STD_VER 17 |
Marek Kurdej | 24b4c51 | 2021-01-07 12:29:04 +0100 | [diff] [blame] | 44 | # elif __cplusplus <= 202002L |
| 45 | # define _LIBCPP_STD_VER 20 |
Eric Fiselier | 02cea5e | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 46 | # else |
Marek Kurdej | 24b4c51 | 2021-01-07 12:29:04 +0100 | [diff] [blame] | 47 | # define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification |
Eric Fiselier | 02cea5e | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 48 | # endif |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 49 | #endif // _LIBCPP_STD_VER |
Eric Fiselier | 02cea5e | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 50 | |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 51 | #if defined(__ELF__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 52 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 53 | #elif defined(__MACH__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 54 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 55 | #elif defined(_WIN32) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 56 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 |
Sam Clegg | fe39b0b | 2017-12-16 18:59:50 +0000 | [diff] [blame] | 57 | #elif defined(__wasm__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 58 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 59 | #else |
Louis Dionne | 64dcd86 | 2020-11-17 13:17:40 -0500 | [diff] [blame] | 60 | // ... add new file formats here ... |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 61 | #endif |
| 62 | |
Eric Fiselier | fa1f1c1 | 2019-06-26 00:05:14 +0000 | [diff] [blame] | 63 | #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 |
Shoaib Meenai | 4bdf437 | 2016-09-12 20:14:44 +0000 | [diff] [blame] | 64 | // Change short string representation so that string data starts at offset 0, |
Evgeniy Stepanov | c299de2 | 2015-11-06 22:02:29 +0000 | [diff] [blame] | 65 | // improving its alignment in some cases. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 66 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
Evgeniy Stepanov | c299de2 | 2015-11-06 22:02:29 +0000 | [diff] [blame] | 67 | // Fix deque iterator type in order to support incomplete types. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 68 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE |
Nico Weber | d31c3ab | 2017-07-22 15:16:42 +0000 | [diff] [blame] | 69 | // Fix undefined behavior in how std::list stores its linked nodes. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 70 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB |
Eric Fiselier | 70f5f87 | 2016-07-19 17:56:20 +0000 | [diff] [blame] | 71 | // Fix undefined behavior in how __tree stores its end and parent nodes. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 72 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB |
Nico Weber | d31c3ab | 2017-07-22 15:16:42 +0000 | [diff] [blame] | 73 | // Fix undefined behavior in how __hash_table stores its pointer types. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 74 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB |
| 75 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB |
| 76 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE |
Shoaib Meenai | c130eaf | 2017-03-28 19:33:31 +0000 | [diff] [blame] | 77 | // Define a key function for `bad_function_call` in the library, to centralize |
| 78 | // its vtable and typeinfo to libc++ rather than having all other libraries |
| 79 | // using that class define their own copies. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 80 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION |
Konstantin Varlamov | d96c2d2 | 2021-11-15 12:40:55 -0800 | [diff] [blame] | 81 | // Override the default return value of exception::what() for |
| 82 | // bad_function_call::what() with a string that is specific to |
| 83 | // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break |
| 84 | // because it changes the vtable layout of bad_function_call. |
| 85 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE |
Aditya Kumar | aa86618 | 2017-06-14 23:17:45 +0000 | [diff] [blame] | 86 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 87 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 88 | // In C++20 and later, don't derive std::plus from std::binary_function, |
| 89 | // nor std::negate from std::unary_function. |
| 90 | # define _LIBCPP_ABI_NO_BINDER_BASES |
Louis Dionne | 8762e2b | 2021-05-25 18:15:58 -0400 | [diff] [blame] | 91 | // Give reverse_iterator<T> one data member of type T, not two. |
| 92 | // Also, in C++17 and later, don't derive iterator types from std::iterator. |
| 93 | # define _LIBCPP_ABI_NO_ITERATOR_BASES |
Eric Fiselier | caccc7b | 2017-11-19 04:19:44 +0000 | [diff] [blame] | 94 | // Use the smallest possible integer type to represent the index of the variant. |
Louis Dionne | a8548af | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 95 | // Previously libc++ used "unsigned int" exclusively. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 96 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION |
Eric Fiselier | f2e6436 | 2018-12-11 00:14:34 +0000 | [diff] [blame] | 97 | // Unstable attempt to provide a more optimized std::function |
| 98 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION |
Marshall Clow | 88a3087 | 2019-03-28 17:30:23 +0000 | [diff] [blame] | 99 | // All the regex constants must be distinct and nonzero. |
| 100 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
Arthur O'Dwyer | 0a5557f | 2021-04-20 22:08:00 -0400 | [diff] [blame] | 101 | // Use raw pointers, not wrapped ones, for std::span's iterator type. |
| 102 | # define _LIBCPP_ABI_SPAN_POINTER_ITERATORS |
Martijn Vels | b17d580 | 2020-03-02 10:11:35 -0500 | [diff] [blame] | 103 | // Re-worked external template instantiations for std::string with a focus on |
| 104 | // performance and fast-path inlining. |
| 105 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
Vy Nguyen | e369bd9 | 2020-07-13 12:34:37 -0400 | [diff] [blame] | 106 | // Enable clang::trivial_abi on std::unique_ptr. |
| 107 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI |
| 108 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr |
| 109 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI |
Eric Fiselier | 08f7fe8 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 110 | #elif _LIBCPP_ABI_VERSION == 1 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 111 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Eric Fiselier | 9884857 | 2017-01-17 03:16:26 +0000 | [diff] [blame] | 112 | // Enable compiling copies of now inline methods into the dylib to support |
Shoaib Meenai | 5c2d401 | 2017-04-12 19:56:37 +0000 | [diff] [blame] | 113 | // applications compiled against older libraries. This is unnecessary with |
| 114 | // COFF dllexport semantics, since dllexport forces a non-inline definition |
| 115 | // of inline functions to be emitted anyway. Our own non-inline copy would |
| 116 | // conflict with the dllexport-emitted copy, so we disable it. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 117 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS |
| 118 | # endif |
Eric Fiselier | 08f7fe8 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 119 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 120 | // are deprecated. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 121 | # if defined(__FreeBSD__) |
| 122 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR |
| 123 | # endif |
Eric Fiselier | 08f7fe8 | 2016-07-18 01:58:37 +0000 | [diff] [blame] | 124 | #endif |
| 125 | |
Louis Dionne | 495e9ad | 2021-11-29 16:20:48 -0500 | [diff] [blame] | 126 | // By default, don't use a nullptr_t emulation type in C++03. |
| 127 | // |
| 128 | // This is technically an ABI break from previous releases, however it is |
| 129 | // very unlikely to impact anyone. If a user is impacted by this break, |
| 130 | // they can return to using the C++03 nullptr emulation by defining |
| 131 | // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. |
| 132 | // |
| 133 | // This switch will be removed entirely in favour of never providing a |
| 134 | // C++03 emulation after one release. |
| 135 | // |
| 136 | // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE |
| 137 | // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN |
| 138 | // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. |
| 139 | #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION |
| 140 | # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR |
| 141 | #endif |
| 142 | |
Louis Dionne | 8a79be6 | 2020-10-21 11:11:45 -0400 | [diff] [blame] | 143 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 |
| 144 | // Enable additional explicit instantiations of iostreams components. This |
| 145 | // reduces the number of weak definitions generated in programs that use |
| 146 | // iostreams by providing a single strong definition in the shared library. |
| 147 | # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 |
Konstantin Varlamov | d96c2d2 | 2021-11-15 12:40:55 -0800 | [diff] [blame] | 148 | |
| 149 | // Define a key function for `bad_function_call` in the library, to centralize |
| 150 | // its vtable and typeinfo to libc++ rather than having all other libraries |
| 151 | // using that class define their own copies. |
| 152 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION |
Louis Dionne | 8a79be6 | 2020-10-21 11:11:45 -0400 | [diff] [blame] | 153 | #endif |
| 154 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y |
| 156 | #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) |
| 157 | |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 158 | #ifndef _LIBCPP_ABI_NAMESPACE |
| 159 | # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) |
| 160 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 161 | |
Eric Fiselier | c6f17cc | 2016-09-25 03:34:28 +0000 | [diff] [blame] | 162 | #if __cplusplus < 201103L |
| 163 | #define _LIBCPP_CXX03_LANG |
| 164 | #endif |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 165 | |
| 166 | #ifndef __has_attribute |
| 167 | #define __has_attribute(__x) 0 |
| 168 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 169 | |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 170 | #ifndef __has_builtin |
| 171 | #define __has_builtin(__x) 0 |
| 172 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 173 | |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 174 | #ifndef __has_extension |
| 175 | #define __has_extension(__x) 0 |
| 176 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 177 | |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 178 | #ifndef __has_feature |
| 179 | #define __has_feature(__x) 0 |
| 180 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 181 | |
Marshall Clow | 2a5c421 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 182 | #ifndef __has_cpp_attribute |
| 183 | #define __has_cpp_attribute(__x) 0 |
| 184 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 185 | |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 186 | // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by |
| 187 | // the compiler and '1' otherwise. |
| 188 | #ifndef __is_identifier |
| 189 | #define __is_identifier(__x) 1 |
| 190 | #endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 191 | |
Eric Fiselier | e3cec5f | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 192 | #ifndef __has_declspec_attribute |
| 193 | #define __has_declspec_attribute(__x) 0 |
| 194 | #endif |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 195 | |
Eric Fiselier | ba72507 | 2017-01-14 04:27:58 +0000 | [diff] [blame] | 196 | #define __has_keyword(__x) !(__is_identifier(__x)) |
| 197 | |
Alexander Richardson | ba1b59e | 2018-07-24 12:40:56 +0000 | [diff] [blame] | 198 | #ifndef __has_include |
| 199 | #define __has_include(...) 0 |
Eric Fiselier | d8a6c89 | 2017-05-10 21:34:58 +0000 | [diff] [blame] | 200 | #endif |
| 201 | |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 202 | #if defined(__apple_build_version__) |
| 203 | # define _LIBCPP_COMPILER_CLANG_BASED |
| 204 | # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) |
| 205 | #elif defined(__clang__) |
| 206 | # define _LIBCPP_COMPILER_CLANG_BASED |
| 207 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 208 | #elif defined(__GNUC__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 209 | # define _LIBCPP_COMPILER_GCC |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 210 | #elif defined(_MSC_VER) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 211 | # define _LIBCPP_COMPILER_MSVC |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 212 | #elif defined(__IBMCPP__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 213 | # define _LIBCPP_COMPILER_IBM |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 214 | #endif |
| 215 | |
Eric Fiselier | 75c0556 | 2019-06-13 00:37:25 +0000 | [diff] [blame] | 216 | #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L |
| 217 | #error "libc++ does not support using GCC with C++03. Please enable C++11" |
| 218 | #endif |
| 219 | |
Eric Fiselier | a6d9634 | 2017-01-07 02:43:58 +0000 | [diff] [blame] | 220 | // FIXME: ABI detection should be done via compiler builtin macros. This |
| 221 | // is just a placeholder until Clang implements such macros. For now assume |
Shoaib Meenai | 69cebe7 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 222 | // that Windows compilers pretending to be MSVC++ target the Microsoft ABI, |
| 223 | // and allow the user to explicitly specify the ABI to handle cases where this |
| 224 | // heuristic falls short. |
Shoaib Meenai | 56943f8 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 225 | #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 226 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" |
Shoaib Meenai | 56943f8 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 227 | #elif defined(_LIBCPP_ABI_FORCE_ITANIUM) |
Shoaib Meenai | 69cebe7 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 228 | # define _LIBCPP_ABI_ITANIUM |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 229 | #elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) |
| 230 | # define _LIBCPP_ABI_MICROSOFT |
| 231 | #else |
| 232 | # if defined(_WIN32) && defined(_MSC_VER) |
| 233 | # define _LIBCPP_ABI_MICROSOFT |
| 234 | # else |
| 235 | # define _LIBCPP_ABI_ITANIUM |
| 236 | # endif |
Eric Fiselier | a6d9634 | 2017-01-07 02:43:58 +0000 | [diff] [blame] | 237 | #endif |
| 238 | |
Eric Fiselier | 85f6633 | 2019-03-05 01:57:01 +0000 | [diff] [blame] | 239 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) |
| 240 | # define _LIBCPP_ABI_VCRUNTIME |
| 241 | #endif |
| 242 | |
Dan Albert | 21800dc | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 243 | // Need to detect which libc we're using if we're on Linux. |
| 244 | #if defined(__linux__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 245 | # include <features.h> |
| 246 | # if defined(__GLIBC_PREREQ) |
| 247 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) |
| 248 | # else |
| 249 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 |
| 250 | # endif // defined(__GLIBC_PREREQ) |
Dan Albert | 21800dc | 2016-09-19 18:00:45 +0000 | [diff] [blame] | 251 | #endif // defined(__linux__) |
Eric Fiselier | 86fcc92 | 2015-07-10 20:26:38 +0000 | [diff] [blame] | 252 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 253 | #ifdef __LITTLE_ENDIAN__ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 254 | # if __LITTLE_ENDIAN__ |
| 255 | # define _LIBCPP_LITTLE_ENDIAN |
| 256 | # endif // __LITTLE_ENDIAN__ |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 257 | #endif // __LITTLE_ENDIAN__ |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 258 | |
| 259 | #ifdef __BIG_ENDIAN__ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 260 | # if __BIG_ENDIAN__ |
| 261 | # define _LIBCPP_BIG_ENDIAN |
| 262 | # endif // __BIG_ENDIAN__ |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 263 | #endif // __BIG_ENDIAN__ |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 264 | |
Dan Albert | 98d9779 | 2015-09-16 18:10:47 +0000 | [diff] [blame] | 265 | #ifdef __BYTE_ORDER__ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 266 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 267 | # define _LIBCPP_LITTLE_ENDIAN |
| 268 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 269 | # define _LIBCPP_BIG_ENDIAN |
| 270 | # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
Dan Albert | 98d9779 | 2015-09-16 18:10:47 +0000 | [diff] [blame] | 271 | #endif // __BYTE_ORDER__ |
| 272 | |
David Chisnall | 93008f0 | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 273 | #ifdef __FreeBSD__ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 274 | # include <sys/endian.h> |
Dimitry Andric | 5600c9b | 2019-10-19 10:59:23 +0000 | [diff] [blame] | 275 | # include <osreldate.h> |
David Chisnall | 93008f0 | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 276 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 277 | # define _LIBCPP_LITTLE_ENDIAN |
| 278 | # else // _BYTE_ORDER == _LITTLE_ENDIAN |
| 279 | # define _LIBCPP_BIG_ENDIAN |
| 280 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 281 | #endif // __FreeBSD__ |
David Chisnall | 93008f0 | 2010-08-11 16:27:20 +0000 | [diff] [blame] | 282 | |
Brad Smith | f6f5509 | 2021-01-12 14:16:15 -0500 | [diff] [blame] | 283 | #if defined(__NetBSD__) || defined(__OpenBSD__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 284 | # include <sys/endian.h> |
Joerg Sonnenberger | 153e416 | 2013-05-17 21:17:34 +0000 | [diff] [blame] | 285 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 286 | # define _LIBCPP_LITTLE_ENDIAN |
| 287 | # else // _BYTE_ORDER == _LITTLE_ENDIAN |
| 288 | # define _LIBCPP_BIG_ENDIAN |
| 289 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 290 | #endif // defined(__NetBSD__) || defined(__OpenBSD__) |
Joerg Sonnenberger | 153e416 | 2013-05-17 21:17:34 +0000 | [diff] [blame] | 291 | |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 292 | #if defined(_WIN32) |
Eric Fiselier | bb999f9 | 2017-05-31 22:14:05 +0000 | [diff] [blame] | 293 | # define _LIBCPP_WIN32API |
Eric Fiselier | e9cc592 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 294 | # define _LIBCPP_LITTLE_ENDIAN |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 295 | # define _LIBCPP_SHORT_WCHAR 1 |
Louis Dionne | a8548af | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 296 | // Both MinGW and native MSVC provide a "MSVC"-like environment |
Eric Fiselier | bb999f9 | 2017-05-31 22:14:05 +0000 | [diff] [blame] | 297 | # define _LIBCPP_MSVCRT_LIKE |
Bruno Cardoso Lopes | 9157268 | 2017-07-17 21:52:31 +0000 | [diff] [blame] | 298 | // If mingw not explicitly detected, assume using MS C runtime only if |
| 299 | // a MS compatibility version is specified. |
| 300 | # if defined(_MSC_VER) && !defined(__MINGW32__) |
Howard Hinnant | 8ad7091 | 2013-09-17 01:34:47 +0000 | [diff] [blame] | 301 | # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library |
| 302 | # endif |
Saleem Abdulrasool | 32300ca | 2017-01-04 01:53:24 +0000 | [diff] [blame] | 303 | # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) |
| 304 | # define _LIBCPP_HAS_BITSCAN64 |
| 305 | # endif |
Peter Collingbourne | 63ebbd7 | 2018-01-23 02:07:27 +0000 | [diff] [blame] | 306 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 307 | # if defined(_LIBCPP_MSVCRT) |
| 308 | # define _LIBCPP_HAS_QUICK_EXIT |
| 309 | # endif |
Shoaib Meenai | e2ce360 | 2017-04-06 04:47:49 +0000 | [diff] [blame] | 310 | |
| 311 | // Some CRT APIs are unavailable to store apps |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 312 | # if defined(WINAPI_FAMILY) |
| 313 | # include <winapifamily.h> |
| 314 | # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ |
| 315 | (!defined(WINAPI_PARTITION_SYSTEM) || \ |
| 316 | !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) |
| 317 | # define _LIBCPP_WINDOWS_STORE_APP |
| 318 | # endif |
| 319 | # endif |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 320 | #endif // defined(_WIN32) |
Howard Hinnant | 34bad2a | 2011-05-13 17:16:06 +0000 | [diff] [blame] | 321 | |
David Chisnall | 8074c34 | 2012-02-29 13:05:08 +0000 | [diff] [blame] | 322 | #ifdef __sun__ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 323 | # include <sys/isa_defs.h> |
| 324 | # ifdef _LITTLE_ENDIAN |
| 325 | # define _LIBCPP_LITTLE_ENDIAN |
| 326 | # else |
| 327 | # define _LIBCPP_BIG_ENDIAN |
| 328 | # endif |
David Chisnall | 8074c34 | 2012-02-29 13:05:08 +0000 | [diff] [blame] | 329 | #endif // __sun__ |
| 330 | |
Xing Xue | 50b0eb4 | 2021-09-09 16:20:36 -0400 | [diff] [blame] | 331 | #if defined(_AIX) && !defined(__64BIT__) |
| 332 | // The size of wchar is 2 byte on 32-bit mode on AIX. |
| 333 | # define _LIBCPP_SHORT_WCHAR 1 |
| 334 | #endif |
| 335 | |
Louis Dionne | 59426ee | 2021-08-24 11:40:05 -0400 | [diff] [blame] | 336 | #if defined(__OpenBSD__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 337 | // Certain architectures provide arc4random(). Prefer using |
| 338 | // arc4random() over /dev/{u,}random to make it possible to obtain |
| 339 | // random data even when using sandboxing mechanisms such as chroots, |
| 340 | // Capsicum, etc. |
| 341 | # define _LIBCPP_USING_ARC4_RANDOM |
Dan Gohman | 280fd6b | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 342 | #elif defined(__Fuchsia__) || defined(__wasi__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 343 | # define _LIBCPP_USING_GETENTROPY |
Ed Schouten | dcf3740 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 344 | #elif defined(__native_client__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 345 | // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, |
| 346 | // including accesses to the special files under /dev. C++11's |
| 347 | // std::random_device is instead exposed through a NaCl syscall. |
| 348 | # define _LIBCPP_USING_NACL_RANDOM |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 349 | #elif defined(_LIBCPP_WIN32API) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 350 | # define _LIBCPP_USING_WIN32_RANDOM |
Ed Schouten | dcf3740 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 351 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 352 | # define _LIBCPP_USING_DEV_RANDOM |
Ed Schouten | dcf3740 | 2015-03-10 07:46:06 +0000 | [diff] [blame] | 353 | #endif |
JF Bastien | d483203 | 2014-12-01 19:19:55 +0000 | [diff] [blame] | 354 | |
Eric Fiselier | e9cc592 | 2017-10-17 13:16:01 +0000 | [diff] [blame] | 355 | #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 356 | # include <endian.h> |
| 357 | # if __BYTE_ORDER == __LITTLE_ENDIAN |
| 358 | # define _LIBCPP_LITTLE_ENDIAN |
| 359 | # elif __BYTE_ORDER == __BIG_ENDIAN |
| 360 | # define _LIBCPP_BIG_ENDIAN |
| 361 | # else // __BYTE_ORDER == __BIG_ENDIAN |
| 362 | # error unable to determine endian |
| 363 | # endif |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 364 | #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 365 | |
Eric Fiselier | 02cba00 | 2017-06-15 03:50:02 +0000 | [diff] [blame] | 366 | #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 367 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) |
Evgeniy Stepanov | 076b237 | 2016-02-10 21:53:28 +0000 | [diff] [blame] | 368 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 369 | # define _LIBCPP_NO_CFI |
Evgeniy Stepanov | 076b237 | 2016-02-10 21:53:28 +0000 | [diff] [blame] | 370 | #endif |
| 371 | |
Louis Dionne | 29c6d37 | 2021-08-17 11:23:48 -0400 | [diff] [blame] | 372 | // If the compiler supports using_if_exists, pretend we have those functions and they'll |
| 373 | // be picked up if the C library provides them. |
| 374 | // |
| 375 | // TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists |
| 376 | // for platforms that don't have a conforming C11 library, so we can drop this whole thing. |
| 377 | #if __has_attribute(using_if_exists) |
| 378 | # define _LIBCPP_HAS_TIMESPEC_GET |
| 379 | # define _LIBCPP_HAS_QUICK_EXIT |
| 380 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
| 381 | #else |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 382 | #if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 383 | # if defined(__FreeBSD__) |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 384 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 385 | # define _LIBCPP_HAS_QUICK_EXIT |
Dimitry Andric | e022a03 | 2020-01-30 08:00:28 +0100 | [diff] [blame] | 386 | # if __FreeBSD_version >= 1300064 || \ |
| 387 | (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) |
| 388 | # define _LIBCPP_HAS_TIMESPEC_GET |
| 389 | # endif |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 390 | # elif defined(__BIONIC__) |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 391 | # if __ANDROID_API__ >= 21 |
| 392 | # define _LIBCPP_HAS_QUICK_EXIT |
| 393 | # endif |
| 394 | # if __ANDROID_API__ >= 28 |
| 395 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
| 396 | # endif |
| 397 | # if __ANDROID_API__ >= 29 |
| 398 | # define _LIBCPP_HAS_TIMESPEC_GET |
| 399 | # endif |
Michał Górny | f042625 | 2019-12-14 14:17:19 +0100 | [diff] [blame] | 400 | # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 401 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 402 | # define _LIBCPP_HAS_QUICK_EXIT |
Marshall Clow | a6a55a8 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 403 | # define _LIBCPP_HAS_TIMESPEC_GET |
Brad Smith | f6f5509 | 2021-01-12 14:16:15 -0500 | [diff] [blame] | 404 | # elif defined(__OpenBSD__) |
| 405 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
| 406 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 407 | # elif defined(__linux__) |
| 408 | # if !defined(_LIBCPP_HAS_MUSL_LIBC) |
| 409 | # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) |
| 410 | # define _LIBCPP_HAS_QUICK_EXIT |
| 411 | # endif |
| 412 | # if _LIBCPP_GLIBC_PREREQ(2, 17) |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 413 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
Marshall Clow | a6a55a8 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 414 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 415 | # endif |
| 416 | # else // defined(_LIBCPP_HAS_MUSL_LIBC) |
Dan Albert | 1d3cfad | 2019-11-18 12:16:45 -0800 | [diff] [blame] | 417 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 418 | # define _LIBCPP_HAS_QUICK_EXIT |
Marshall Clow | a6a55a8 | 2018-08-15 21:19:08 +0000 | [diff] [blame] | 419 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 420 | # endif |
Martin Storsjö | 8a174e7 | 2021-05-31 09:32:51 +0000 | [diff] [blame] | 421 | # elif defined(_LIBCPP_MSVCRT) |
| 422 | // Using Microsoft's C Runtime library, not MinGW |
| 423 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 5b74729 | 2020-07-27 14:25:03 -0400 | [diff] [blame] | 424 | # elif defined(__APPLE__) |
| 425 | // timespec_get and aligned_alloc were introduced in macOS 10.15 and |
| 426 | // aligned releases |
Marek Kurdej | 126213e | 2021-04-02 10:31:18 +0200 | [diff] [blame] | 427 | # if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \ |
| 428 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ |
| 429 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ |
| 430 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)) |
Louis Dionne | 5b74729 | 2020-07-27 14:25:03 -0400 | [diff] [blame] | 431 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
Raphael Isemann | 46c3ac5 | 2020-09-02 09:25:31 +0200 | [diff] [blame] | 432 | # define _LIBCPP_HAS_TIMESPEC_GET |
Louis Dionne | 5b74729 | 2020-07-27 14:25:03 -0400 | [diff] [blame] | 433 | # endif |
| 434 | # endif // __APPLE__ |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 435 | #endif |
Louis Dionne | 29c6d37 | 2021-08-17 11:23:48 -0400 | [diff] [blame] | 436 | #endif // __has_attribute(using_if_exists) |
Louis Dionne | 234dd43 | 2018-08-15 00:16:41 +0000 | [diff] [blame] | 437 | |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 438 | #ifndef _LIBCPP_CXX03_LANG |
| 439 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 440 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 441 | # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) |
| 442 | #else |
Louis Dionne | 72707bf | 2020-09-02 12:29:42 -0400 | [diff] [blame] | 443 | # error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 444 | #endif |
| 445 | |
| 446 | #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) |
| 447 | |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 448 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) |
Howard Hinnant | aa87c0f | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 449 | |
Louis Dionne | 3f34693 | 2020-06-25 16:31:14 -0400 | [diff] [blame] | 450 | #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) |
| 451 | # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead |
| 452 | #endif |
| 453 | #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ |
| 454 | (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) |
| 455 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
Tim Northover | ffc9593 | 2014-03-30 11:34:22 +0000 | [diff] [blame] | 456 | #endif |
| 457 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 458 | #if __has_feature(cxx_alignas) |
Howard Hinnant | 62cad69 | 2012-05-31 19:31:14 +0000 | [diff] [blame] | 459 | # define _ALIGNAS_TYPE(x) alignas(x) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 460 | # define _ALIGNAS(x) alignas(x) |
| 461 | #else |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 462 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 463 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) |
| 464 | #endif |
| 465 | |
Marshall Clow | 2b12c31 | 2014-02-22 15:13:48 +0000 | [diff] [blame] | 466 | #if __cplusplus < 201103L |
Howard Hinnant | 31cd14f | 2010-09-16 23:27:26 +0000 | [diff] [blame] | 467 | typedef __char16_t char16_t; |
| 468 | typedef __char32_t char32_t; |
Howard Hinnant | 8e6a398 | 2010-09-07 20:31:18 +0000 | [diff] [blame] | 469 | #endif |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 470 | |
Louis Dionne | 94c6eda | 2020-07-03 13:46:41 -0400 | [diff] [blame] | 471 | #if !__has_feature(cxx_exceptions) |
| 472 | # define _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | aa87c0f | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 473 | #endif |
| 474 | |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 475 | #if !(__has_feature(cxx_strong_enums)) |
| 476 | #define _LIBCPP_HAS_NO_STRONG_ENUMS |
| 477 | #endif |
| 478 | |
Howard Hinnant | 8df9629 | 2011-05-26 17:07:32 +0000 | [diff] [blame] | 479 | #if __has_feature(cxx_attributes) |
Richard Smith | cabd392 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 480 | # define _LIBCPP_NORETURN [[noreturn]] |
Howard Hinnant | 8df9629 | 2011-05-26 17:07:32 +0000 | [diff] [blame] | 481 | #else |
Richard Smith | cabd392 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 482 | # define _LIBCPP_NORETURN __attribute__ ((noreturn)) |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 483 | #endif |
| 484 | |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 485 | #if !(__has_feature(cxx_nullptr)) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 486 | # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) |
| 487 | # define nullptr __nullptr |
| 488 | # else |
| 489 | # define _LIBCPP_HAS_NO_NULLPTR |
| 490 | # endif |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 491 | #endif |
| 492 | |
Douglas Gregor | 1303444 | 2011-06-22 22:17:44 +0000 | [diff] [blame] | 493 | // Objective-C++ features (opt-in) |
| 494 | #if __has_feature(objc_arc) |
| 495 | #define _LIBCPP_HAS_OBJC_ARC |
| 496 | #endif |
| 497 | |
| 498 | #if __has_feature(objc_arc_weak) |
| 499 | #define _LIBCPP_HAS_OBJC_ARC_WEAK |
| 500 | #endif |
| 501 | |
Louis Dionne | 2c35828 | 2020-01-21 12:39:43 -0800 | [diff] [blame] | 502 | #if __has_extension(blocks) |
| 503 | # define _LIBCPP_HAS_EXTENSION_BLOCKS |
| 504 | #endif |
| 505 | |
Louis Dionne | 3a63292 | 2020-04-23 16:47:52 -0400 | [diff] [blame] | 506 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) |
| 507 | # define _LIBCPP_HAS_BLOCKS_RUNTIME |
| 508 | #endif |
| 509 | |
Eric Fiselier | 1af87ca | 2015-12-15 22:16:47 +0000 | [diff] [blame] | 510 | #if !(__has_feature(cxx_noexcept)) |
| 511 | #define _LIBCPP_HAS_NO_NOEXCEPT |
Howard Hinnant | 68d1339 | 2011-05-11 20:19:40 +0000 | [diff] [blame] | 512 | #endif |
| 513 | |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 514 | #if !__has_feature(address_sanitizer) |
Marshall Clow | 90fc047 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 515 | #define _LIBCPP_HAS_NO_ASAN |
| 516 | #endif |
| 517 | |
Marshall Clow | 55b23d2 | 2016-01-12 00:38:04 +0000 | [diff] [blame] | 518 | // Allow for build-time disabling of unsigned integer sanitization |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 519 | #if __has_attribute(no_sanitize) |
Saleem Abdulrasool | 38acb64 | 2016-02-09 04:05:37 +0000 | [diff] [blame] | 520 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 521 | #endif |
Marshall Clow | 55b23d2 | 2016-01-12 00:38:04 +0000 | [diff] [blame] | 522 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 523 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 524 | |
Louis Dionne | faa1745 | 2019-09-04 12:44:19 +0000 | [diff] [blame] | 525 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ |
| 526 | |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 527 | #elif defined(_LIBCPP_COMPILER_GCC) |
Howard Hinnant | aa87c0f | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 528 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 529 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 530 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 531 | |
Richard Smith | cabd392 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 532 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
Howard Hinnant | 1e570a3 | 2011-05-31 13:13:49 +0000 | [diff] [blame] | 533 | |
Louis Dionne | af6be62 | 2021-07-27 17:30:47 -0400 | [diff] [blame] | 534 | #if !defined(__EXCEPTIONS) |
Louis Dionne | 94c6eda | 2020-07-03 13:46:41 -0400 | [diff] [blame] | 535 | # define _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | aa87c0f | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 536 | #endif |
| 537 | |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 538 | #if !defined(__SANITIZE_ADDRESS__) |
Marshall Clow | 90fc047 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 539 | #define _LIBCPP_HAS_NO_ASAN |
| 540 | #endif |
| 541 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 542 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 543 | |
Louis Dionne | faa1745 | 2019-09-04 12:44:19 +0000 | [diff] [blame] | 544 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ |
| 545 | |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 546 | #elif defined(_LIBCPP_COMPILER_MSVC) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 547 | |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 548 | #define _LIBCPP_TOSTRING2(x) #x |
| 549 | #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) |
| 550 | #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) |
| 551 | |
| 552 | #if _MSC_VER < 1900 |
| 553 | #error "MSVC versions prior to Visual Studio 2015 are not supported" |
| 554 | #endif |
| 555 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 556 | #define __alignof__ __alignof |
Richard Smith | cabd392 | 2012-07-26 02:04:22 +0000 | [diff] [blame] | 557 | #define _LIBCPP_NORETURN __declspec(noreturn) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 558 | #define _ALIGNAS(x) __declspec(align(x)) |
Eric Fiselier | 6a53758 | 2018-02-07 23:50:25 +0000 | [diff] [blame] | 559 | #define _ALIGNAS_TYPE(x) alignas(x) |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 560 | |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 561 | #define _LIBCPP_WEAK |
| 562 | |
Marshall Clow | 90fc047 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 563 | #define _LIBCPP_HAS_NO_ASAN |
| 564 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 565 | #define _LIBCPP_ALWAYS_INLINE __forceinline |
| 566 | |
Tim Shen | d87ea29 | 2018-07-30 22:27:38 +0000 | [diff] [blame] | 567 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION |
| 568 | |
Louis Dionne | faa1745 | 2019-09-04 12:44:19 +0000 | [diff] [blame] | 569 | #define _LIBCPP_DISABLE_EXTENSION_WARNING |
| 570 | |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 571 | #elif defined(_LIBCPP_COMPILER_IBM) |
Howard Hinnant | ea38295 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 572 | |
| 573 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) |
Eric Fiselier | 0f0ed9d | 2019-01-16 01:51:12 +0000 | [diff] [blame] | 574 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
Howard Hinnant | ea38295 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 575 | #define _ATTRIBUTE(x) __attribute__((x)) |
| 576 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
| 577 | |
Howard Hinnant | ea38295 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 578 | #define _LIBCPP_HAS_NO_UNICODE_CHARS |
Howard Hinnant | ea38295 | 2013-08-14 18:00:20 +0000 | [diff] [blame] | 579 | |
| 580 | #if defined(_AIX) |
| 581 | #define __MULTILOCALE_API |
| 582 | #endif |
| 583 | |
Marshall Clow | 90fc047 | 2014-04-14 15:44:57 +0000 | [diff] [blame] | 584 | #define _LIBCPP_HAS_NO_ASAN |
| 585 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 586 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 587 | |
Tim Shen | d87ea29 | 2018-07-30 22:27:38 +0000 | [diff] [blame] | 588 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION |
| 589 | |
Louis Dionne | faa1745 | 2019-09-04 12:44:19 +0000 | [diff] [blame] | 590 | #define _LIBCPP_DISABLE_EXTENSION_WARNING |
| 591 | |
Eric Fiselier | 8fbccea | 2017-01-06 21:42:58 +0000 | [diff] [blame] | 592 | #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 593 | |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 594 | #if defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 595 | |
Peter Collingbourne | 725de94 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 596 | #ifdef _DLL |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 597 | # define _LIBCPP_CRT_FUNC __declspec(dllimport) |
Peter Collingbourne | 725de94 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 598 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 599 | # define _LIBCPP_CRT_FUNC |
Peter Collingbourne | 725de94 | 2018-01-17 04:37:04 +0000 | [diff] [blame] | 600 | #endif |
| 601 | |
Shoaib Meenai | f36e988 | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 602 | #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 603 | # define _LIBCPP_DLL_VIS |
| 604 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 605 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 606 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS |
Louis Dionne | 5254b37 | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 607 | # define _LIBCPP_EXPORTED_FROM_ABI |
Eric Fiselier | 51e8d2f | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 608 | #elif defined(_LIBCPP_BUILDING_LIBRARY) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 609 | # define _LIBCPP_DLL_VIS __declspec(dllexport) |
Martin Storsjo | bd25449 | 2019-04-25 19:46:28 +0000 | [diff] [blame] | 610 | # if defined(__MINGW32__) |
| 611 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS |
| 612 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 613 | # else |
| 614 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 615 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS |
| 616 | # endif |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 617 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS |
Louis Dionne | 5254b37 | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 618 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) |
Eric Fiselier | 51e8d2f | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 619 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 620 | # define _LIBCPP_DLL_VIS __declspec(dllimport) |
| 621 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS |
| 622 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 623 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS |
Louis Dionne | 5254b37 | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 624 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 625 | #endif |
Eric Fiselier | 51e8d2f | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 626 | |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 627 | #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS |
| 628 | #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS |
| 629 | #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 630 | #define _LIBCPP_HIDDEN |
Shoaib Meenai | 69c5741 | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 631 | #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 632 | #define _LIBCPP_TEMPLATE_VIS |
Martin Storsjö | 88890c2 | 2021-02-22 01:13:13 +0200 | [diff] [blame] | 633 | #define _LIBCPP_TEMPLATE_DATA_VIS |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 634 | #define _LIBCPP_ENUM_VIS |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 635 | |
Saleem Abdulrasool | ee302e4 | 2017-01-03 21:53:51 +0000 | [diff] [blame] | 636 | #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 637 | |
| 638 | #ifndef _LIBCPP_HIDDEN |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 639 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 640 | # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) |
| 641 | # else |
| 642 | # define _LIBCPP_HIDDEN |
| 643 | # endif |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 644 | #endif |
| 645 | |
Shoaib Meenai | 5331f49 | 2017-03-09 00:18:00 +0000 | [diff] [blame] | 646 | #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 647 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Shoaib Meenai | 69c5741 | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 648 | // The inline should be removed once PR32114 is resolved |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 649 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN |
| 650 | # else |
| 651 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 652 | # endif |
Shoaib Meenai | 5331f49 | 2017-03-09 00:18:00 +0000 | [diff] [blame] | 653 | #endif |
Shoaib Meenai | 69c5741 | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 654 | |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 655 | #ifndef _LIBCPP_FUNC_VIS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 656 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 657 | # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) |
| 658 | # else |
| 659 | # define _LIBCPP_FUNC_VIS |
| 660 | # endif |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 661 | #endif |
| 662 | |
| 663 | #ifndef _LIBCPP_TYPE_VIS |
Shoaib Meenai | f36e988 | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 664 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Shoaib Meenai | 55f3a46 | 2017-03-02 03:22:18 +0000 | [diff] [blame] | 665 | # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 666 | # else |
Shoaib Meenai | f36e988 | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 667 | # define _LIBCPP_TYPE_VIS |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 668 | # endif |
| 669 | #endif |
| 670 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 671 | #ifndef _LIBCPP_TEMPLATE_VIS |
Shoaib Meenai | 55f3a46 | 2017-03-02 03:22:18 +0000 | [diff] [blame] | 672 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 673 | # if __has_attribute(__type_visibility__) |
| 674 | # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) |
| 675 | # else |
| 676 | # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) |
| 677 | # endif |
| 678 | # else |
| 679 | # define _LIBCPP_TEMPLATE_VIS |
| 680 | # endif |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 681 | #endif |
| 682 | |
Martin Storsjö | 88890c2 | 2021-02-22 01:13:13 +0200 | [diff] [blame] | 683 | #ifndef _LIBCPP_TEMPLATE_DATA_VIS |
| 684 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 685 | # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default"))) |
| 686 | # else |
| 687 | # define _LIBCPP_TEMPLATE_DATA_VIS |
| 688 | # endif |
| 689 | #endif |
| 690 | |
Louis Dionne | 5254b37 | 2018-10-25 12:13:43 +0000 | [diff] [blame] | 691 | #ifndef _LIBCPP_EXPORTED_FROM_ABI |
Thomas Anderson | e13df2b | 2018-12-13 20:06:14 +0000 | [diff] [blame] | 692 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 693 | # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) |
| 694 | # else |
| 695 | # define _LIBCPP_EXPORTED_FROM_ABI |
| 696 | # endif |
Eric Fiselier | 9950507 | 2017-01-16 21:01:00 +0000 | [diff] [blame] | 697 | #endif |
| 698 | |
Shoaib Meenai | 2d71db4 | 2016-11-16 22:18:10 +0000 | [diff] [blame] | 699 | #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 700 | #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS |
Shoaib Meenai | 2d71db4 | 2016-11-16 22:18:10 +0000 | [diff] [blame] | 701 | #endif |
| 702 | |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 703 | #ifndef _LIBCPP_EXCEPTION_ABI |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 704 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
| 705 | # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) |
| 706 | # else |
| 707 | # define _LIBCPP_EXCEPTION_ABI |
| 708 | # endif |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 709 | #endif |
| 710 | |
| 711 | #ifndef _LIBCPP_ENUM_VIS |
Shoaib Meenai | f36e988 | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 712 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 713 | # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) |
| 714 | # else |
| 715 | # define _LIBCPP_ENUM_VIS |
| 716 | # endif |
| 717 | #endif |
| 718 | |
| 719 | #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
Shoaib Meenai | 491802e | 2021-01-12 10:29:03 -0800 | [diff] [blame] | 720 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Shoaib Meenai | 69c5741 | 2017-03-02 03:02:50 +0000 | [diff] [blame] | 721 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 722 | # else |
| 723 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 724 | # endif |
| 725 | #endif |
| 726 | |
Shoaib Meenai | 5ac1067 | 2016-09-19 18:29:07 +0000 | [diff] [blame] | 727 | #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 728 | #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
Shoaib Meenai | 5ac1067 | 2016-09-19 18:29:07 +0000 | [diff] [blame] | 729 | #endif |
| 730 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 731 | #if __has_attribute(internal_linkage) |
| 732 | # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) |
| 733 | #else |
| 734 | # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 735 | #endif |
| 736 | |
Louis Dionne | 3b8a03f | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 737 | #if __has_attribute(exclude_from_explicit_instantiation) |
| 738 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) |
| 739 | #else |
| 740 | // Try to approximate the effect of exclude_from_explicit_instantiation |
| 741 | // (which is that entities are not assumed to be provided by explicit |
Louis Dionne | a8548af | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 742 | // template instantiations in the dylib) by always inlining those entities. |
Louis Dionne | 3b8a03f | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 743 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE |
| 744 | #endif |
| 745 | |
Louis Dionne | 1821de4 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 746 | #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU |
| 747 | # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT |
| 748 | # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 |
| 749 | # else |
| 750 | # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 |
| 751 | # endif |
| 752 | #endif |
| 753 | |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 754 | #ifndef _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | 1821de4 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 755 | # if _LIBCPP_HIDE_FROM_ABI_PER_TU |
| 756 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE |
| 757 | # else |
Louis Dionne | 3b8a03f | 2018-10-29 17:30:04 +0000 | [diff] [blame] | 758 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION |
Louis Dionne | 1821de4 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 759 | # endif |
Louis Dionne | 3a19799 | 2018-07-27 12:46:03 +0000 | [diff] [blame] | 760 | #endif |
| 761 | |
Louis Dionne | d797b8d | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 762 | #ifdef _LIBCPP_BUILDING_LIBRARY |
| 763 | # if _LIBCPP_ABI_VERSION > 1 |
| 764 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 765 | # else |
Louis Dionne | d797b8d | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 766 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 767 | # endif |
Louis Dionne | d797b8d | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 768 | #else |
| 769 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 770 | #endif |
| 771 | |
Louis Dionne | d797b8d | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 772 | // Just so we can migrate to the new macros gradually. |
| 773 | #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI |
Louis Dionne | d797b8d | 2018-08-06 14:11:50 +0000 | [diff] [blame] | 774 | |
Eric Fiselier | b9d04dc | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 775 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 776 | #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { |
Eric Fiselier | b9d04dc | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 777 | #define _LIBCPP_END_NAMESPACE_STD } } |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 778 | #define _VSTD std::_LIBCPP_ABI_NAMESPACE |
Eric Fiselier | b9d04dc | 2018-10-30 02:02:00 +0000 | [diff] [blame] | 779 | _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD |
| 780 | |
| 781 | #if _LIBCPP_STD_VER >= 17 |
| 782 | #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ |
| 783 | _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { |
| 784 | #else |
| 785 | #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ |
| 786 | _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { |
| 787 | #endif |
| 788 | |
| 789 | #define _LIBCPP_END_NAMESPACE_FILESYSTEM \ |
| 790 | _LIBCPP_END_NAMESPACE_STD } } |
| 791 | |
| 792 | #define _VSTD_FS _VSTD::__fs::filesystem |
| 793 | |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 794 | #if __has_attribute(__enable_if__) |
| 795 | # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) |
Eric Fiselier | 1b57fa8 | 2016-09-15 22:27:07 +0000 | [diff] [blame] | 796 | #endif |
| 797 | |
Eric Fiselier | 1af87ca | 2015-12-15 22:16:47 +0000 | [diff] [blame] | 798 | #ifndef _LIBCPP_HAS_NO_NOEXCEPT |
| 799 | # define _NOEXCEPT noexcept |
| 800 | # define _NOEXCEPT_(x) noexcept(x) |
| 801 | #else |
| 802 | # define _NOEXCEPT throw() |
| 803 | # define _NOEXCEPT_(x) |
| 804 | #endif |
| 805 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 806 | #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS |
Howard Hinnant | aa87c0f | 2010-08-10 20:48:29 +0000 | [diff] [blame] | 807 | typedef unsigned short char16_t; |
| 808 | typedef unsigned int char32_t; |
Louis Dionne | 96fc5f5 | 2021-09-09 11:25:10 -0400 | [diff] [blame] | 809 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 810 | |
Stephan Tolksdorf | 0efeb6c | 2014-03-26 19:45:52 +0000 | [diff] [blame] | 811 | #ifndef __SIZEOF_INT128__ |
| 812 | #define _LIBCPP_HAS_NO_INT128 |
| 813 | #endif |
| 814 | |
Eric Fiselier | c6f17cc | 2016-09-25 03:34:28 +0000 | [diff] [blame] | 815 | #ifdef _LIBCPP_CXX03_LANG |
Eric Fiselier | 2f05ab9 | 2019-06-18 20:50:25 +0000 | [diff] [blame] | 816 | # define static_assert(...) _Static_assert(__VA_ARGS__) |
| 817 | # define decltype(...) __decltype(__VA_ARGS__) |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 818 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 819 | |
Eric Fiselier | 605af61 | 2019-06-21 13:56:13 +0000 | [diff] [blame] | 820 | #ifdef _LIBCPP_CXX03_LANG |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 821 | # define _LIBCPP_CONSTEXPR |
Howard Hinnant | 664183b | 2012-04-02 00:40:41 +0000 | [diff] [blame] | 822 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 823 | # define _LIBCPP_CONSTEXPR constexpr |
Howard Hinnant | 62c8c0b | 2010-09-06 19:10:31 +0000 | [diff] [blame] | 824 | #endif |
| 825 | |
Richard Smith | 55a75c8 | 2020-07-31 15:03:21 -0700 | [diff] [blame] | 826 | #ifndef __cpp_consteval |
| 827 | # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR |
| 828 | #else |
| 829 | # define _LIBCPP_CONSTEVAL consteval |
| 830 | #endif |
| 831 | |
Mark de Wever | 1d4140e | 2021-02-20 09:13:16 +0100 | [diff] [blame] | 832 | #if !defined(__cpp_concepts) || __cpp_concepts < 201907L |
| 833 | #define _LIBCPP_HAS_NO_CONCEPTS |
| 834 | #endif |
| 835 | |
Martin Storsjö | 4f646c0 | 2021-04-30 13:57:37 +0300 | [diff] [blame] | 836 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS) |
Christopher Di Bella | 490fe40 | 2021-03-23 03:55:52 +0000 | [diff] [blame] | 837 | #define _LIBCPP_HAS_NO_RANGES |
| 838 | #endif |
| 839 | |
Nuno Lopes | 22df2dc | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 840 | #ifdef __GNUC__ |
Louis Dionne | e147b35 | 2019-02-26 06:34:42 +0000 | [diff] [blame] | 841 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) |
Nuno Lopes | 22df2dc | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 842 | #else |
Louis Dionne | e147b35 | 2019-02-26 06:34:42 +0000 | [diff] [blame] | 843 | # define _LIBCPP_NOALIAS |
Nuno Lopes | 22df2dc | 2012-06-28 16:47:34 +0000 | [diff] [blame] | 844 | #endif |
| 845 | |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame] | 846 | #if __has_attribute(using_if_exists) |
| 847 | # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) |
| 848 | #else |
| 849 | # define _LIBCPP_USING_IF_EXISTS |
| 850 | #endif |
| 851 | |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 852 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 853 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx |
| 854 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ |
| 855 | __lx __v_; \ |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 856 | _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ |
| 857 | _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ |
| 858 | _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 859 | }; |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 860 | #else // _LIBCPP_HAS_NO_STRONG_ENUMS |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 861 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x |
| 862 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 863 | #endif // _LIBCPP_HAS_NO_STRONG_ENUMS |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 864 | |
Louis Dionne | ba40078 | 2020-10-02 15:02:52 -0400 | [diff] [blame] | 865 | // _LIBCPP_DEBUG potential values: |
| 866 | // - undefined: No assertions. This is the default. |
| 867 | // - 0: Basic assertions |
Danila Kutenin | a9cbea1 | 2021-11-16 15:48:59 -0500 | [diff] [blame] | 868 | // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization. |
| 869 | # if !defined(_LIBCPP_DEBUG) |
| 870 | # define _LIBCPP_DEBUG_LEVEL 0 |
| 871 | # elif _LIBCPP_DEBUG == 0 |
| 872 | # define _LIBCPP_DEBUG_LEVEL 1 |
| 873 | # elif _LIBCPP_DEBUG == 1 |
| 874 | # define _LIBCPP_DEBUG_LEVEL 2 |
| 875 | # else |
| 876 | # error Supported values for _LIBCPP_DEBUG are 0 and 1 |
| 877 | # endif |
| 878 | |
| 879 | # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG) |
| 880 | # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY |
| 881 | # endif |
| 882 | |
| 883 | # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) |
| 884 | # if defined(_LIBCPP_CXX03_LANG) |
| 885 | # error Support for unspecified stability is only for C++11 and higher |
| 886 | # endif |
| 887 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ |
| 888 | do { \ |
| 889 | if (!__builtin_is_constant_evaluated()) \ |
| 890 | _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \ |
| 891 | } while (false) |
| 892 | # else |
| 893 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ |
| 894 | do { \ |
| 895 | } while (false) |
| 896 | # endif |
Howard Hinnant | 8ea9824 | 2013-08-23 17:37:05 +0000 | [diff] [blame] | 897 | |
Louis Dionne | 732192e | 2021-06-09 09:41:27 -0400 | [diff] [blame] | 898 | // Libc++ allows disabling extern template instantiation declarations by |
| 899 | // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE. |
| 900 | // |
| 901 | // Furthermore, when the Debug mode is enabled, we disable extern declarations |
| 902 | // when building user code because we don't want to use the functions compiled |
| 903 | // in the library, which might not have had the debug mode enabled when built. |
| 904 | // However, some extern declarations need to be used, because code correctness |
| 905 | // depends on it (several instances in <locale>). Those special declarations |
| 906 | // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled |
| 907 | // even when the debug mode is enabled. |
| 908 | #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) |
| 909 | # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ |
| 910 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */ |
| 911 | #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY) |
| 912 | # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ |
| 913 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; |
| 914 | #else |
| 915 | # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; |
| 916 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; |
Eric Fiselier | 510690e | 2019-12-13 15:42:07 -0500 | [diff] [blame] | 917 | #endif |
| 918 | |
Martin Storsjo | 5482ac6 | 2017-11-23 10:38:18 +0000 | [diff] [blame] | 919 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ |
Louis Dionne | 59426ee | 2021-08-24 11:40:05 -0400 | [diff] [blame] | 920 | defined(__sun__) || defined(__NetBSD__) |
Alexis Hunt | 1adf2aa | 2011-07-15 05:40:33 +0000 | [diff] [blame] | 921 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 |
| 922 | #endif |
Yaron Keren | 804da95 | 2013-12-20 13:19:45 +0000 | [diff] [blame] | 923 | |
Marshall Clow | 82378c0 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 924 | #ifdef __FreeBSD__ |
David Chisnall | 6ae8f35 | 2011-11-13 17:15:33 +0000 | [diff] [blame] | 925 | #define _DECLARE_C99_LDBL_MATH 1 |
| 926 | #endif |
Alexis Hunt | 1adf2aa | 2011-07-15 05:40:33 +0000 | [diff] [blame] | 927 | |
Reid Kleckner | 85c65e6 | 2018-04-19 22:12:10 +0000 | [diff] [blame] | 928 | // If we are getting operator new from the MSVC CRT, then allocation overloads |
| 929 | // for align_val_t were added in 19.12, aka VS 2017 version 15.3. |
| 930 | #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 |
Louis Dionne | 2e206ca | 2018-12-17 22:22:44 +0000 | [diff] [blame] | 931 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
Eric Fiselier | 85f6633 | 2019-03-05 01:57:01 +0000 | [diff] [blame] | 932 | #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) |
Louis Dionne | a8548af | 2019-03-20 17:05:52 +0000 | [diff] [blame] | 933 | // We're deferring to Microsoft's STL to provide aligned new et al. We don't |
Thomas Anderson | e043918 | 2019-01-30 19:08:32 +0000 | [diff] [blame] | 934 | // have it unless the language feature test macro is defined. |
| 935 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
Zbigniew Sarbinowski | 001f5d0 | 2020-11-12 14:40:35 -0500 | [diff] [blame] | 936 | #elif defined(__MVS__) |
| 937 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
Reid Kleckner | 85c65e6 | 2018-04-19 22:12:10 +0000 | [diff] [blame] | 938 | #endif |
| 939 | |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 940 | #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ |
| 941 | (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) |
Louis Dionne | e5aafbf | 2018-08-10 13:24:56 +0000 | [diff] [blame] | 942 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION |
| 943 | #endif |
Eric Fiselier | 06548ab | 2018-03-22 04:42:56 +0000 | [diff] [blame] | 944 | |
Marshall Clow | 82378c0 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 945 | #if defined(__APPLE__) || defined(__FreeBSD__) |
Howard Hinnant | f312e3e | 2011-09-28 23:39:33 +0000 | [diff] [blame] | 946 | #define _LIBCPP_HAS_DEFAULTRUNELOCALE |
Alexis Hunt | 5a4dd56 | 2011-07-09 01:09:31 +0000 | [diff] [blame] | 947 | #endif |
| 948 | |
Marshall Clow | 82378c0 | 2013-03-18 19:34:07 +0000 | [diff] [blame] | 949 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) |
Alexis Hunt | c2017f1 | 2011-07-09 03:40:04 +0000 | [diff] [blame] | 950 | #define _LIBCPP_WCTYPE_IS_MASK |
| 951 | #endif |
| 952 | |
Marshall Clow | 8732fed | 2018-12-11 04:35:44 +0000 | [diff] [blame] | 953 | #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) |
Arthur O'Dwyer | afa5d5f | 2021-04-18 21:47:08 -0400 | [diff] [blame] | 954 | #define _LIBCPP_HAS_NO_CHAR8_T |
Marshall Clow | 8732fed | 2018-12-11 04:35:44 +0000 | [diff] [blame] | 955 | #endif |
| 956 | |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 957 | // Deprecation macros. |
Louis Dionne | ded5b77 | 2019-03-12 20:10:06 +0000 | [diff] [blame] | 958 | // |
| 959 | // Deprecations warnings are always enabled, except when users explicitly opt-out |
| 960 | // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. |
| 961 | #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 962 | # if __has_attribute(deprecated) |
| 963 | # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) |
| 964 | # elif _LIBCPP_STD_VER > 11 |
| 965 | # define _LIBCPP_DEPRECATED [[deprecated]] |
| 966 | # else |
| 967 | # define _LIBCPP_DEPRECATED |
| 968 | # endif |
Marshall Clow | a2cbe0d | 2013-09-28 18:35:31 +0000 | [diff] [blame] | 969 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 970 | # define _LIBCPP_DEPRECATED |
Marshall Clow | a2cbe0d | 2013-09-28 18:35:31 +0000 | [diff] [blame] | 971 | #endif |
| 972 | |
Louis Dionne | 481a266 | 2018-09-23 18:35:00 +0000 | [diff] [blame] | 973 | #if !defined(_LIBCPP_CXX03_LANG) |
| 974 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED |
| 975 | #else |
| 976 | # define _LIBCPP_DEPRECATED_IN_CXX11 |
| 977 | #endif |
| 978 | |
| 979 | #if _LIBCPP_STD_VER >= 14 |
| 980 | # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED |
| 981 | #else |
| 982 | # define _LIBCPP_DEPRECATED_IN_CXX14 |
| 983 | #endif |
| 984 | |
| 985 | #if _LIBCPP_STD_VER >= 17 |
| 986 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED |
| 987 | #else |
| 988 | # define _LIBCPP_DEPRECATED_IN_CXX17 |
| 989 | #endif |
| 990 | |
Marek Kurdej | c984814 | 2020-11-26 10:07:16 +0100 | [diff] [blame] | 991 | #if _LIBCPP_STD_VER > 17 |
| 992 | # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED |
| 993 | #else |
| 994 | # define _LIBCPP_DEPRECATED_IN_CXX20 |
| 995 | #endif |
| 996 | |
Arthur O'Dwyer | afa5d5f | 2021-04-18 21:47:08 -0400 | [diff] [blame] | 997 | #if !defined(_LIBCPP_HAS_NO_CHAR8_T) |
Martin Storsjö | e3a7197 | 2020-10-26 13:18:46 +0200 | [diff] [blame] | 998 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED |
| 999 | #else |
| 1000 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T |
| 1001 | #endif |
| 1002 | |
Richard Smith | bfc256b | 2019-10-19 00:06:00 +0000 | [diff] [blame] | 1003 | // Macros to enter and leave a state where deprecation warnings are suppressed. |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 1004 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) |
| 1005 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ |
| 1006 | _Pragma("GCC diagnostic push") \ |
Louis Dionne | af6be62 | 2021-07-27 17:30:47 -0400 | [diff] [blame] | 1007 | _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ |
| 1008 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 1009 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP \ |
| 1010 | _Pragma("GCC diagnostic pop") |
| 1011 | #else |
| 1012 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 1013 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP |
Richard Smith | bfc256b | 2019-10-19 00:06:00 +0000 | [diff] [blame] | 1014 | #endif |
| 1015 | |
Marshall Clow | 1045cee | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 1016 | #if _LIBCPP_STD_VER <= 11 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1017 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 |
Marshall Clow | 1045cee | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 1018 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1019 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit |
Marshall Clow | 1045cee | 2013-07-15 14:57:19 +0000 | [diff] [blame] | 1020 | #endif |
| 1021 | |
Louis Dionne | e3594f1 | 2021-08-24 11:58:36 -0400 | [diff] [blame] | 1022 | #if _LIBCPP_STD_VER > 11 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1023 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr |
Eric Fiselier | b4c0c66 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 1024 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1025 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Eric Fiselier | b4c0c66 | 2014-07-17 05:16:18 +0000 | [diff] [blame] | 1026 | #endif |
| 1027 | |
Louis Dionne | e3594f1 | 2021-08-24 11:58:36 -0400 | [diff] [blame] | 1028 | #if _LIBCPP_STD_VER > 14 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1029 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr |
Eric Fiselier | 0b3bfbe | 2016-03-17 03:30:56 +0000 | [diff] [blame] | 1030 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1031 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 |
Eric Fiselier | 0b3bfbe | 2016-03-17 03:30:56 +0000 | [diff] [blame] | 1032 | #endif |
| 1033 | |
Louis Dionne | e3594f1 | 2021-08-24 11:58:36 -0400 | [diff] [blame] | 1034 | #if _LIBCPP_STD_VER > 17 |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1035 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr |
Marshall Clow | 2a5c421 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1036 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1037 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 |
Marshall Clow | 2a5c421 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1038 | #endif |
| 1039 | |
Roman Lebedev | b5959fa | 2018-09-22 17:54:48 +0000 | [diff] [blame] | 1040 | #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) |
Louis Dionne | 9118292 | 2021-08-30 16:01:38 -0400 | [diff] [blame] | 1041 | # define _LIBCPP_NODISCARD [[nodiscard]] |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 1042 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) |
Louis Dionne | 9118292 | 2021-08-30 16:01:38 -0400 | [diff] [blame] | 1043 | # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] |
Roman Lebedev | b5959fa | 2018-09-22 17:54:48 +0000 | [diff] [blame] | 1044 | #else |
| 1045 | // We can't use GCC's [[gnu::warn_unused_result]] and |
| 1046 | // __attribute__((warn_unused_result)), because GCC does not silence them via |
| 1047 | // (void) cast. |
Louis Dionne | 9118292 | 2021-08-30 16:01:38 -0400 | [diff] [blame] | 1048 | # define _LIBCPP_NODISCARD |
Roman Lebedev | b5959fa | 2018-09-22 17:54:48 +0000 | [diff] [blame] | 1049 | #endif |
| 1050 | |
| 1051 | // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not |
| 1052 | // specified as such as an extension. |
| 1053 | #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) |
Louis Dionne | 9118292 | 2021-08-30 16:01:38 -0400 | [diff] [blame] | 1054 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD |
Roman Lebedev | b5959fa | 2018-09-22 17:54:48 +0000 | [diff] [blame] | 1055 | #else |
| 1056 | # define _LIBCPP_NODISCARD_EXT |
| 1057 | #endif |
| 1058 | |
| 1059 | #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ |
| 1060 | (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) |
Louis Dionne | 9118292 | 2021-08-30 16:01:38 -0400 | [diff] [blame] | 1061 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD |
Marshall Clow | 2a5c421 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1062 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1063 | # define _LIBCPP_NODISCARD_AFTER_CXX17 |
Marshall Clow | 2a5c421 | 2017-11-14 22:26:50 +0000 | [diff] [blame] | 1064 | #endif |
| 1065 | |
Louis Dionne | a39f1ef | 2019-04-17 18:20:19 +0000 | [diff] [blame] | 1066 | #if __has_attribute(no_destroy) |
| 1067 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) |
| 1068 | #else |
| 1069 | # define _LIBCPP_NO_DESTROY |
| 1070 | #endif |
| 1071 | |
Marshall Clow | 2cd9d37 | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 1072 | #ifndef _LIBCPP_HAS_NO_ASAN |
Azat Khuzhin | cdfb87f | 2020-12-17 16:19:50 -0500 | [diff] [blame] | 1073 | extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
Marshall Clow | 2cd9d37 | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 1074 | const void *, const void *, const void *, const void *); |
| 1075 | #endif |
| 1076 | |
Howard Hinnant | 1308788 | 2013-10-04 21:24:21 +0000 | [diff] [blame] | 1077 | // Try to find out if RTTI is disabled. |
Marek Kurdej | f319792 | 2021-04-01 08:29:55 +0200 | [diff] [blame] | 1078 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) |
Louis Dionne | ef0c662 | 2020-07-14 16:28:41 -0400 | [diff] [blame] | 1079 | # define _LIBCPP_NO_RTTI |
| 1080 | #elif defined(__GNUC__) && !defined(__GXX_RTTI) |
| 1081 | # define _LIBCPP_NO_RTTI |
| 1082 | #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) |
| 1083 | # define _LIBCPP_NO_RTTI |
Howard Hinnant | 1308788 | 2013-10-04 21:24:21 +0000 | [diff] [blame] | 1084 | #endif |
| 1085 | |
Howard Hinnant | 33f0472 | 2013-10-04 23:56:37 +0000 | [diff] [blame] | 1086 | #ifndef _LIBCPP_WEAK |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1087 | #define _LIBCPP_WEAK __attribute__((__weak__)) |
Howard Hinnant | 33f0472 | 2013-10-04 23:56:37 +0000 | [diff] [blame] | 1088 | #endif |
| 1089 | |
Asiri Rathnayake | fa2e203 | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1090 | // Thread API |
Eric Fiselier | bfd4553 | 2017-01-06 23:15:16 +0000 | [diff] [blame] | 1091 | #if !defined(_LIBCPP_HAS_NO_THREADS) && \ |
Asiri Rathnayake | c07f0be | 2017-02-27 16:10:57 +0000 | [diff] [blame] | 1092 | !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ |
Eric Fiselier | d8a6c89 | 2017-05-10 21:34:58 +0000 | [diff] [blame] | 1093 | !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ |
Asiri Rathnayake | c07f0be | 2017-02-27 16:10:57 +0000 | [diff] [blame] | 1094 | !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1095 | # if defined(__FreeBSD__) || \ |
Dan Gohman | 280fd6b | 2019-05-01 16:47:30 +0000 | [diff] [blame] | 1096 | defined(__wasi__) || \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1097 | defined(__NetBSD__) || \ |
Brad Smith | f6f5509 | 2021-01-12 14:16:15 -0500 | [diff] [blame] | 1098 | defined(__OpenBSD__) || \ |
Xiang Xiao | 8552923 | 2020-11-18 16:16:18 -0500 | [diff] [blame] | 1099 | defined(__NuttX__) || \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1100 | defined(__linux__) || \ |
Louis Dionne | 3cfcaeb | 2018-11-20 21:14:05 +0000 | [diff] [blame] | 1101 | defined(__GNU__) || \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1102 | defined(__APPLE__) || \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1103 | defined(__sun__) || \ |
Zbigniew Sarbinowski | ca6367d | 2020-12-05 00:13:23 +0000 | [diff] [blame] | 1104 | defined(__MVS__) || \ |
Martin Storsjö | c86337b | 2021-10-01 23:44:17 +0300 | [diff] [blame] | 1105 | defined(_AIX) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1106 | # define _LIBCPP_HAS_THREAD_API_PTHREAD |
Petr Hosek | d0e7fe4 | 2019-12-04 10:38:22 -0800 | [diff] [blame] | 1107 | # elif defined(__Fuchsia__) |
Petr Hosek | e6ad6e4 | 2020-01-16 12:12:38 -0800 | [diff] [blame] | 1108 | // TODO(44575): Switch to C11 thread API when possible. |
| 1109 | # define _LIBCPP_HAS_THREAD_API_PTHREAD |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1110 | # elif defined(_LIBCPP_WIN32API) |
| 1111 | # define _LIBCPP_HAS_THREAD_API_WIN32 |
| 1112 | # else |
| 1113 | # error "No thread API" |
| 1114 | # endif // _LIBCPP_HAS_THREAD_API |
Asiri Rathnayake | fa2e203 | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1115 | #endif // _LIBCPP_HAS_NO_THREADS |
| 1116 | |
Dan Albert | ad29301 | 2019-09-18 18:13:32 +0000 | [diff] [blame] | 1117 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
| 1118 | #if defined(__ANDROID__) && __ANDROID_API__ >= 30 |
| 1119 | #define _LIBCPP_HAS_COND_CLOCKWAIT |
| 1120 | #elif defined(_LIBCPP_GLIBC_PREREQ) |
| 1121 | #if _LIBCPP_GLIBC_PREREQ(2, 30) |
| 1122 | #define _LIBCPP_HAS_COND_CLOCKWAIT |
| 1123 | #endif |
| 1124 | #endif |
| 1125 | #endif |
| 1126 | |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 1127 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1128 | #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ |
| 1129 | _LIBCPP_HAS_NO_THREADS is not defined. |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 1130 | #endif |
Asiri Rathnayake | fa2e203 | 2016-05-06 14:06:29 +0000 | [diff] [blame] | 1131 | |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 1132 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1133 | #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ |
| 1134 | _LIBCPP_HAS_NO_THREADS is defined. |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 1135 | #endif |
| 1136 | |
Eric Fiselier | 715b416 | 2014-12-06 20:09:11 +0000 | [diff] [blame] | 1137 | #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1138 | #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ |
| 1139 | _LIBCPP_HAS_NO_THREADS is defined. |
Eric Fiselier | 715b416 | 2014-12-06 20:09:11 +0000 | [diff] [blame] | 1140 | #endif |
| 1141 | |
Nico Weber | 6b58e1d | 2019-07-30 14:32:47 +0000 | [diff] [blame] | 1142 | #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) |
| 1143 | #define __STDCPP_THREADS__ 1 |
| 1144 | #endif |
| 1145 | |
Louis Dionne | 66c58fd | 2019-07-25 20:29:20 +0000 | [diff] [blame] | 1146 | // The glibc and Bionic implementation of pthreads implements |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1147 | // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 |
| 1148 | // mutexes have no destroy mechanism. |
Louis Dionne | 66c58fd | 2019-07-25 20:29:20 +0000 | [diff] [blame] | 1149 | // |
| 1150 | // This optimization can't be performed on Apple platforms, where |
| 1151 | // pthread_mutex_destroy can allow the kernel to release resources. |
| 1152 | // See https://llvm.org/D64298 for details. |
| 1153 | // |
| 1154 | // TODO(EricWF): Enable this optimization on Bionic after speaking to their |
| 1155 | // respective stakeholders. |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1156 | #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ |
Petr Hosek | d0e7fe4 | 2019-12-04 10:38:22 -0800 | [diff] [blame] | 1157 | || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1158 | || defined(_LIBCPP_HAS_THREAD_API_WIN32) |
Eric Fiselier | f6dac86 | 2019-07-07 01:20:54 +0000 | [diff] [blame] | 1159 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION |
| 1160 | #endif |
| 1161 | |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1162 | // Destroying a condvar is a nop on Windows. |
Louis Dionne | 66c58fd | 2019-07-25 20:29:20 +0000 | [diff] [blame] | 1163 | // |
| 1164 | // This optimization can't be performed on Apple platforms, where |
| 1165 | // pthread_cond_destroy can allow the kernel to release resources. |
| 1166 | // See https://llvm.org/D64298 for details. |
| 1167 | // |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1168 | // TODO(EricWF): This is potentially true for some pthread implementations |
| 1169 | // as well. |
Petr Hosek | d0e7fe4 | 2019-12-04 10:38:22 -0800 | [diff] [blame] | 1170 | #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ |
| 1171 | defined(_LIBCPP_HAS_THREAD_API_WIN32) |
Eric Fiselier | 256466e | 2019-07-07 17:24:03 +0000 | [diff] [blame] | 1172 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION |
| 1173 | #endif |
| 1174 | |
Dimitry Andric | 2e72c80 | 2019-09-07 22:18:20 +0000 | [diff] [blame] | 1175 | // Some systems do not provide gets() in their C library, for security reasons. |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 1176 | #if defined(_LIBCPP_MSVCRT) || \ |
| 1177 | (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ |
| 1178 | defined(__OpenBSD__) |
| 1179 | # define _LIBCPP_C_HAS_NO_GETS |
Dimitry Andric | 2e72c80 | 2019-09-07 22:18:20 +0000 | [diff] [blame] | 1180 | #endif |
| 1181 | |
Louis Dionne | 59426ee | 2021-08-24 11:40:05 -0400 | [diff] [blame] | 1182 | #if defined(__BIONIC__) || defined(__NuttX__) || \ |
Muiez Ahmed | af108fb | 2020-11-10 09:54:03 -0500 | [diff] [blame] | 1183 | defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \ |
Brad Smith | f6f5509 | 2021-01-12 14:16:15 -0500 | [diff] [blame] | 1184 | defined(__MVS__) || defined(__OpenBSD__) |
Dan Albert | ebdf28b | 2015-03-11 00:51:06 +0000 | [diff] [blame] | 1185 | #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE |
| 1186 | #endif |
| 1187 | |
Eric Fiselier | ba72507 | 2017-01-14 04:27:58 +0000 | [diff] [blame] | 1188 | #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1189 | # define _LIBCPP_HAS_C_ATOMIC_IMP |
Richard Smith | ca47d0f | 2019-04-25 20:02:10 +0000 | [diff] [blame] | 1190 | #elif defined(_LIBCPP_COMPILER_GCC) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1191 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1192 | #endif |
| 1193 | |
Louis Dionne | af2d2a8 | 2021-11-17 10:59:31 -0500 | [diff] [blame] | 1194 | #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ |
| 1195 | !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ |
| 1196 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) |
Davide Italiano | 011f80a | 2019-03-05 18:40:49 +0000 | [diff] [blame] | 1197 | # define _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 1198 | #else |
| 1199 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE |
| 1200 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool |
| 1201 | # endif |
| 1202 | # ifdef _LIBCPP_FREESTANDING |
| 1203 | # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS |
| 1204 | # endif |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1205 | #endif |
| 1206 | |
Marshall Clow | 91c7f64 | 2016-01-11 19:27:10 +0000 | [diff] [blame] | 1207 | #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 1208 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
Eric Fiselier | 100e24b | 2016-02-11 11:59:44 +0000 | [diff] [blame] | 1209 | #endif |
| 1210 | |
Saleem Abdulrasool | b82f960 | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1211 | #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1212 | # if defined(__clang__) && __has_attribute(acquire_capability) |
Saleem Abdulrasool | b82f960 | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1213 | // Work around the attribute handling in clang. When both __declspec and |
| 1214 | // __attribute__ are present, the processing goes awry preventing the definition |
| 1215 | // of the types. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1216 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 1217 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS |
| 1218 | # endif |
| 1219 | # endif |
Saleem Abdulrasool | b82f960 | 2017-02-13 15:26:51 +0000 | [diff] [blame] | 1220 | #endif |
Eric Fiselier | c0c6c98 | 2016-03-16 02:30:06 +0000 | [diff] [blame] | 1221 | |
Louis Dionne | 93f1fd7 | 2021-06-04 13:31:22 -0400 | [diff] [blame] | 1222 | #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS |
| 1223 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) |
| 1224 | #else |
| 1225 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) |
| 1226 | #endif |
Eric Fiselier | 510690e | 2019-12-13 15:42:07 -0500 | [diff] [blame] | 1227 | |
Eric Fiselier | 0d3da63 | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1228 | #if __has_attribute(require_constant_initialization) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1229 | # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) |
Eric Fiselier | 0d3da63 | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1230 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1231 | # define _LIBCPP_SAFE_STATIC |
Eric Fiselier | 0d3da63 | 2016-09-03 00:11:33 +0000 | [diff] [blame] | 1232 | #endif |
| 1233 | |
Eric Fiselier | a7a14ed | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1234 | #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1235 | # define _LIBCPP_DIAGNOSE_WARNING(...) \ |
| 1236 | __attribute__((diagnose_if(__VA_ARGS__, "warning"))) |
| 1237 | # define _LIBCPP_DIAGNOSE_ERROR(...) \ |
| 1238 | __attribute__((diagnose_if(__VA_ARGS__, "error"))) |
Eric Fiselier | a7a14ed | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1239 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1240 | # define _LIBCPP_DIAGNOSE_WARNING(...) |
| 1241 | # define _LIBCPP_DIAGNOSE_ERROR(...) |
Eric Fiselier | a7a14ed | 2017-01-13 22:02:08 +0000 | [diff] [blame] | 1242 | #endif |
| 1243 | |
Eric Fiselier | 4db8003 | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1244 | // Use a function like macro to imply that it must be followed by a semicolon |
Reid Kleckner | 75d4e00 | 2018-11-01 18:24:03 +0000 | [diff] [blame] | 1245 | #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) |
| 1246 | # define _LIBCPP_FALLTHROUGH() [[fallthrough]] |
| 1247 | #elif __has_cpp_attribute(clang::fallthrough) |
| 1248 | # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] |
Louis Dionne | 3e0c433 | 2021-08-31 10:49:06 -0400 | [diff] [blame] | 1249 | #elif __has_attribute(__fallthrough__) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1250 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) |
Eric Fiselier | 4db8003 | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1251 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1252 | # define _LIBCPP_FALLTHROUGH() ((void)0) |
Eric Fiselier | 4db8003 | 2017-05-05 20:32:26 +0000 | [diff] [blame] | 1253 | #endif |
| 1254 | |
Eric Fiselier | 4fc82a2 | 2019-06-12 02:03:31 +0000 | [diff] [blame] | 1255 | #if __has_attribute(__nodebug__) |
| 1256 | #define _LIBCPP_NODEBUG __attribute__((__nodebug__)) |
Eric Fiselier | 74ebee6 | 2019-06-08 01:31:19 +0000 | [diff] [blame] | 1257 | #else |
| 1258 | #define _LIBCPP_NODEBUG |
| 1259 | #endif |
| 1260 | |
Amy Huang | 63f53b5 | 2021-03-15 14:20:49 -0700 | [diff] [blame] | 1261 | #if __has_attribute(__standalone_debug__) |
| 1262 | #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) |
| 1263 | #else |
| 1264 | #define _LIBCPP_STANDALONE_DEBUG |
| 1265 | #endif |
| 1266 | |
Richard Smith | 256954d | 2020-11-11 17:12:18 -0800 | [diff] [blame] | 1267 | #if __has_attribute(__preferred_name__) |
| 1268 | #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) |
| 1269 | #else |
| 1270 | #define _LIBCPP_PREFERRED_NAME(x) |
| 1271 | #endif |
| 1272 | |
Louis Dionne | 8925814 | 2021-08-23 15:32:36 -0400 | [diff] [blame] | 1273 | // We often repeat things just for handling wide characters in the library. |
| 1274 | // When wide characters are disabled, it can be useful to have a quick way of |
| 1275 | // disabling it without having to resort to #if-#endif, which has a larger |
| 1276 | // impact on readability. |
| 1277 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) |
| 1278 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) |
| 1279 | #else |
| 1280 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ |
| 1281 | #endif |
| 1282 | |
Eric Fiselier | e3cec5f | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1283 | #if defined(_LIBCPP_ABI_MICROSOFT) && \ |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1284 | (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) |
| 1285 | # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) |
Eric Fiselier | e3cec5f | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1286 | #else |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1287 | # define _LIBCPP_DECLSPEC_EMPTY_BASES |
Eric Fiselier | e3cec5f | 2017-01-16 21:15:08 +0000 | [diff] [blame] | 1288 | #endif |
| 1289 | |
Eric Fiselier | ddd7779 | 2017-02-17 03:25:08 +0000 | [diff] [blame] | 1290 | #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1291 | #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1292 | #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1293 | #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE |
| 1294 | #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS |
Eric Fiselier | ddd7779 | 2017-02-17 03:25:08 +0000 | [diff] [blame] | 1295 | #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES |
| 1296 | |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1297 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) |
| 1298 | #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS |
Arthur O'Dwyer | f5486c8 | 2021-05-25 14:34:18 -0400 | [diff] [blame] | 1299 | #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1300 | #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS |
| 1301 | #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR |
wmbat | f5b3376 | 2021-07-02 17:08:36 +0000 | [diff] [blame] | 1302 | #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS |
Arthur O'Dwyer | a6b5107 | 2021-05-24 18:36:17 -0400 | [diff] [blame] | 1303 | #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES |
| 1304 | |
Chuanqi Xu | 6fdf619 | 2021-11-16 14:05:34 +0800 | [diff] [blame] | 1305 | #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L |
| 1306 | #define _LIBCPP_HAS_NO_CXX20_COROUTINES |
Eric Fiselier | 40b6622 | 2017-05-26 01:52:59 +0000 | [diff] [blame] | 1307 | #endif |
| 1308 | |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1309 | #if defined(_LIBCPP_COMPILER_IBM) |
| 1310 | #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO |
| 1311 | #endif |
| 1312 | |
| 1313 | #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1314 | # define _LIBCPP_PUSH_MACROS |
| 1315 | # define _LIBCPP_POP_MACROS |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1316 | #else |
| 1317 | // Don't warn about macro conflicts when we can restore them at the |
| 1318 | // end of the header. |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1319 | # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS |
| 1320 | # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS |
| 1321 | # endif |
| 1322 | # if defined(_LIBCPP_COMPILER_MSVC) |
| 1323 | # define _LIBCPP_PUSH_MACROS \ |
| 1324 | __pragma(push_macro("min")) \ |
| 1325 | __pragma(push_macro("max")) |
| 1326 | # define _LIBCPP_POP_MACROS \ |
| 1327 | __pragma(pop_macro("min")) \ |
| 1328 | __pragma(pop_macro("max")) |
| 1329 | # else |
| 1330 | # define _LIBCPP_PUSH_MACROS \ |
| 1331 | _Pragma("push_macro(\"min\")") \ |
| 1332 | _Pragma("push_macro(\"max\")") |
| 1333 | # define _LIBCPP_POP_MACROS \ |
| 1334 | _Pragma("pop_macro(\"min\")") \ |
| 1335 | _Pragma("pop_macro(\"max\")") |
| 1336 | # endif |
Eric Fiselier | f4433a3 | 2017-05-31 22:07:49 +0000 | [diff] [blame] | 1337 | #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) |
| 1338 | |
Peter Collingbourne | 1aa99c5 | 2018-01-24 04:30:19 +0000 | [diff] [blame] | 1339 | #ifndef _LIBCPP_NO_AUTO_LINK |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1340 | # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) |
Martin Storsjö | 57db41b | 2021-04-15 11:16:28 +0300 | [diff] [blame] | 1341 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Logan Chien | 7b4845e | 2018-02-24 07:57:32 +0000 | [diff] [blame] | 1342 | # pragma comment(lib, "c++.lib") |
| 1343 | # else |
| 1344 | # pragma comment(lib, "libc++.lib") |
| 1345 | # endif |
| 1346 | # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) |
Peter Collingbourne | 1aa99c5 | 2018-01-24 04:30:19 +0000 | [diff] [blame] | 1347 | #endif // _LIBCPP_NO_AUTO_LINK |
Eric Fiselier | 911dcad | 2017-06-16 01:57:41 +0000 | [diff] [blame] | 1348 | |
Dan Albert | 9550df6 | 2019-09-16 19:26:41 +0000 | [diff] [blame] | 1349 | // Configures the fopen close-on-exec mode character, if any. This string will |
| 1350 | // be appended to any mode string used by fstream for fopen/fdopen. |
| 1351 | // |
| 1352 | // Not all platforms support this, but it helps avoid fd-leaks on platforms that |
| 1353 | // do. |
| 1354 | #if defined(__BIONIC__) |
| 1355 | # define _LIBCPP_FOPEN_CLOEXEC_MODE "e" |
| 1356 | #else |
| 1357 | # define _LIBCPP_FOPEN_CLOEXEC_MODE |
| 1358 | #endif |
| 1359 | |
Dan Albert | 073008c | 2020-03-12 11:16:30 -0700 | [diff] [blame] | 1360 | // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set |
| 1361 | // of functions used in cstdio may not be available for low API levels when |
| 1362 | // using 64-bit file offsets on LP32. |
| 1363 | #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 |
| 1364 | #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS |
| 1365 | #endif |
| 1366 | |
Zbigniew Sarbinowski | 4536ef4 | 2020-11-20 14:46:21 -0500 | [diff] [blame] | 1367 | #if __has_attribute(init_priority) |
Louis Dionne | 1f14cea | 2021-02-03 16:25:06 -0500 | [diff] [blame] | 1368 | // TODO: Remove this once we drop support for building libc++ with old Clangs |
| 1369 | # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ |
| 1370 | (defined(__apple_build_version__) && __apple_build_version__ < 13000000) |
| 1371 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) |
| 1372 | # else |
| 1373 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) |
| 1374 | # endif |
Zbigniew Sarbinowski | 4536ef4 | 2020-11-20 14:46:21 -0500 | [diff] [blame] | 1375 | #else |
| 1376 | # define _LIBCPP_INIT_PRIORITY_MAX |
| 1377 | #endif |
| 1378 | |
Arthur O'Dwyer | 4cbc323 | 2021-03-05 20:13:35 -0500 | [diff] [blame] | 1379 | #if defined(__GNUC__) || defined(__clang__) |
Louis Dionne | e1ad457 | 2021-11-16 15:22:10 -0500 | [diff] [blame] | 1380 | // The attribute uses 1-based indices for ordinary and static member functions. |
| 1381 | // The attribute uses 2-based indices for non-static member functions. |
| 1382 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ |
| 1383 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) |
Arthur O'Dwyer | 4cbc323 | 2021-03-05 20:13:35 -0500 | [diff] [blame] | 1384 | #else |
Louis Dionne | e1ad457 | 2021-11-16 15:22:10 -0500 | [diff] [blame] | 1385 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ |
Arthur O'Dwyer | 4cbc323 | 2021-03-05 20:13:35 -0500 | [diff] [blame] | 1386 | #endif |
| 1387 | |
Eric Fiselier | 911dcad | 2017-06-16 01:57:41 +0000 | [diff] [blame] | 1388 | #endif // __cplusplus |
| 1389 | |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 1390 | #endif // _LIBCPP_CONFIG |