__config 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  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
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_CONFIG
  10. #define _LIBCPP_CONFIG
  11. #include <__wrappers_config>
  12. #if defined(_MSC_VER) && !defined(__clang__)
  13. # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  14. # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  15. # endif
  16. #endif
  17. #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  18. #pragma GCC system_header
  19. #endif
  20. // Move outside #ifdef __cplusplus because this needs to work in both C and C++ headers.
  21. #if defined(__apple_build_version__)
  22. # define _LIBCPP_COMPILER_CLANG_BASED
  23. # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
  24. #elif defined(__clang__)
  25. #define _LIBCPP_COMPILER_CLANG
  26. # define _LIBCPP_COMPILER_CLANG_BASED
  27. # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
  28. #elif defined(__GNUC__)
  29. #define _LIBCPP_COMPILER_GCC
  30. #elif defined(_MSC_VER)
  31. #define _LIBCPP_COMPILER_MSVC
  32. #if _MSVC_LANG == 201705L
  33. # define _LIBCPP_STD_VER 20
  34. #elif _MSVC_LANG == 201703L
  35. # define _LIBCPP_STD_VER 17
  36. #else
  37. # define _LIBCPP_STD_VER 14
  38. #endif
  39. #define _LIBCPP_UCRT_INCLUDE(x) <Y_UCRT_INCLUDE/x>
  40. #define _LIBCPP_MSVC_INCLUDE(x) <Y_MSVC_INCLUDE/x>
  41. #elif defined(__IBMCPP__)
  42. #define _LIBCPP_COMPILER_IBM
  43. #endif
  44. #ifdef __cplusplus
  45. #define _LIBCPP_VERSION 14000
  46. #ifndef _LIBCPP_ABI_VERSION
  47. # define _LIBCPP_ABI_VERSION 1
  48. #endif
  49. #if __STDC_HOSTED__ == 0
  50. # define _LIBCPP_FREESTANDING
  51. #endif
  52. #ifndef _LIBCPP_STD_VER
  53. # if __cplusplus <= 201103L
  54. # define _LIBCPP_STD_VER 11
  55. # elif __cplusplus <= 201402L
  56. # define _LIBCPP_STD_VER 14
  57. # elif __cplusplus <= 201703L
  58. # define _LIBCPP_STD_VER 17
  59. # elif __cplusplus <= 202002L
  60. # define _LIBCPP_STD_VER 20
  61. # else
  62. # define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
  63. # endif
  64. #endif // _LIBCPP_STD_VER
  65. #if defined(__ELF__)
  66. # define _LIBCPP_OBJECT_FORMAT_ELF 1
  67. #elif defined(__MACH__)
  68. # define _LIBCPP_OBJECT_FORMAT_MACHO 1
  69. #elif defined(_WIN32) || defined(__CYGWIN__)
  70. # define _LIBCPP_OBJECT_FORMAT_COFF 1
  71. #elif defined(__wasm__)
  72. # define _LIBCPP_OBJECT_FORMAT_WASM 1
  73. #else
  74. // ... add new file formats here ...
  75. #endif
  76. #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
  77. // Change short string representation so that string data starts at offset 0,
  78. // improving its alignment in some cases.
  79. # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  80. // Fix deque iterator type in order to support incomplete types.
  81. # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
  82. // Fix undefined behavior in how std::list stores its linked nodes.
  83. # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
  84. // Fix undefined behavior in how __tree stores its end and parent nodes.
  85. # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
  86. // Fix undefined behavior in how __hash_table stores its pointer types.
  87. # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
  88. # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
  89. # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
  90. // Define a key function for `bad_function_call` in the library, to centralize
  91. // its vtable and typeinfo to libc++ rather than having all other libraries
  92. // using that class define their own copies.
  93. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
  94. // Override the default return value of exception::what() for
  95. // bad_function_call::what() with a string that is specific to
  96. // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
  97. // because it changes the vtable layout of bad_function_call.
  98. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
  99. // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
  100. # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
  101. // In C++20 and later, don't derive std::plus from std::binary_function,
  102. // nor std::negate from std::unary_function.
  103. # define _LIBCPP_ABI_NO_BINDER_BASES
  104. // Give reverse_iterator<T> one data member of type T, not two.
  105. // Also, in C++17 and later, don't derive iterator types from std::iterator.
  106. # define _LIBCPP_ABI_NO_ITERATOR_BASES
  107. // Use the smallest possible integer type to represent the index of the variant.
  108. // Previously libc++ used "unsigned int" exclusively.
  109. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
  110. // Unstable attempt to provide a more optimized std::function
  111. # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
  112. // All the regex constants must be distinct and nonzero.
  113. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
  114. // Use raw pointers, not wrapped ones, for std::span's iterator type.
  115. # define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
  116. // Re-worked external template instantiations for std::string with a focus on
  117. // performance and fast-path inlining.
  118. # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
  119. // Enable clang::trivial_abi on std::unique_ptr.
  120. # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
  121. // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
  122. # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
  123. // std::random_device holds some state when it uses an implementation that gets
  124. // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
  125. // implementation to another one on a platform that has already shipped
  126. // std::random_device, one needs to retain the same object layout to remain ABI
  127. // compatible. This switch removes these workarounds for platforms that don't care
  128. // about ABI compatibility.
  129. # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
  130. // Remove basic_string common base
  131. # define _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS
  132. #elif _LIBCPP_ABI_VERSION == 1
  133. # if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
  134. // Enable compiling copies of now inline methods into the dylib to support
  135. // applications compiled against older libraries. This is unnecessary with
  136. // COFF dllexport semantics, since dllexport forces a non-inline definition
  137. // of inline functions to be emitted anyway. Our own non-inline copy would
  138. // conflict with the dllexport-emitted copy, so we disable it.
  139. # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
  140. # endif
  141. // Feature macros for disabling pre ABI v1 features. All of these options
  142. // are deprecated.
  143. # if defined(__FreeBSD__)
  144. # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
  145. # endif
  146. #endif
  147. // By default, don't use a nullptr_t emulation type in C++03.
  148. //
  149. // This is technically an ABI break from previous releases, however it is
  150. // very unlikely to impact anyone. If a user is impacted by this break,
  151. // they can return to using the C++03 nullptr emulation by defining
  152. // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION.
  153. //
  154. // This switch will be removed entirely in favour of never providing a
  155. // C++03 emulation after one release.
  156. //
  157. // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE
  158. // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN
  159. // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION.
  160. #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION
  161. # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
  162. #endif
  163. #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
  164. // Enable additional explicit instantiations of iostreams components. This
  165. // reduces the number of weak definitions generated in programs that use
  166. // iostreams by providing a single strong definition in the shared library.
  167. # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
  168. // Define a key function for `bad_function_call` in the library, to centralize
  169. // its vtable and typeinfo to libc++ rather than having all other libraries
  170. // using that class define their own copies.
  171. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
  172. #endif
  173. #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
  174. #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
  175. #ifndef _LIBCPP_ABI_NAMESPACE
  176. # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__y,_LIBCPP_ABI_VERSION)
  177. #endif
  178. #if __cplusplus < 201103L && !defined(_LIBCPP_COMPILER_MSVC)
  179. #define _LIBCPP_CXX03_LANG
  180. #endif
  181. #ifndef __has_attribute
  182. #define __has_attribute(__x) 0
  183. #endif
  184. #ifndef __has_builtin
  185. #define __has_builtin(__x) 0
  186. #endif
  187. #ifndef __has_extension
  188. #define __has_extension(__x) 0
  189. #endif
  190. #ifndef __has_feature
  191. #define __has_feature(__x) 0
  192. #endif
  193. #ifndef __has_cpp_attribute
  194. #define __has_cpp_attribute(__x) 0
  195. #endif
  196. // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
  197. // the compiler and '1' otherwise.
  198. #ifndef __is_identifier
  199. #define __is_identifier(__x) 1
  200. #endif
  201. #ifndef __has_declspec_attribute
  202. #define __has_declspec_attribute(__x) 0
  203. #endif
  204. #define __has_keyword(__x) !(__is_identifier(__x))
  205. #ifndef __has_include
  206. #define __has_include(...) 0
  207. #endif
  208. #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
  209. #error "libc++ does not support using GCC with C++03. Please enable C++11"
  210. #endif
  211. // FIXME: ABI detection should be done via compiler builtin macros. This
  212. // is just a placeholder until Clang implements such macros. For now assume
  213. // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
  214. // and allow the user to explicitly specify the ABI to handle cases where this
  215. // heuristic falls short.
  216. #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
  217. # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
  218. #elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
  219. # define _LIBCPP_ABI_ITANIUM
  220. #elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
  221. # define _LIBCPP_ABI_MICROSOFT
  222. #else
  223. # if defined(_WIN32) && defined(_MSC_VER)
  224. # define _LIBCPP_ABI_MICROSOFT
  225. # else
  226. # define _LIBCPP_ABI_ITANIUM
  227. # endif
  228. #endif
  229. #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
  230. # define _LIBCPP_ABI_VCRUNTIME
  231. #endif
  232. // Need to detect which libc we're using if we're on Linux.
  233. #if defined(__linux__)
  234. # include <features.h>
  235. # if defined(__GLIBC_PREREQ)
  236. # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
  237. # else
  238. # define _LIBCPP_GLIBC_PREREQ(a, b) 0
  239. # endif // defined(__GLIBC_PREREQ)
  240. #endif // defined(__linux__)
  241. #if defined(__MVS__)
  242. # include <features.h> // for __NATIVE_ASCII_F
  243. #endif
  244. #ifdef __LITTLE_ENDIAN__
  245. # if __LITTLE_ENDIAN__
  246. # define _LIBCPP_LITTLE_ENDIAN
  247. # endif // __LITTLE_ENDIAN__
  248. #endif // __LITTLE_ENDIAN__
  249. #ifdef __BIG_ENDIAN__
  250. # if __BIG_ENDIAN__
  251. # define _LIBCPP_BIG_ENDIAN
  252. # endif // __BIG_ENDIAN__
  253. #endif // __BIG_ENDIAN__
  254. #ifdef __BYTE_ORDER__
  255. # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  256. # define _LIBCPP_LITTLE_ENDIAN
  257. # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  258. # define _LIBCPP_BIG_ENDIAN
  259. # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  260. #endif // __BYTE_ORDER__
  261. #ifdef __FreeBSD__
  262. # include <sys/endian.h>
  263. # include <osreldate.h>
  264. # if _BYTE_ORDER == _LITTLE_ENDIAN
  265. # define _LIBCPP_LITTLE_ENDIAN
  266. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  267. # define _LIBCPP_BIG_ENDIAN
  268. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  269. #endif // __FreeBSD__
  270. #if defined(__NetBSD__) || defined(__OpenBSD__)
  271. # include <sys/endian.h>
  272. # if _BYTE_ORDER == _LITTLE_ENDIAN
  273. # define _LIBCPP_LITTLE_ENDIAN
  274. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  275. # define _LIBCPP_BIG_ENDIAN
  276. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  277. #endif // defined(__NetBSD__) || defined(__OpenBSD__)
  278. #if defined(_WIN32)
  279. # define _LIBCPP_WIN32API
  280. # define _LIBCPP_LITTLE_ENDIAN
  281. # define _LIBCPP_SHORT_WCHAR 1
  282. // Both MinGW and native MSVC provide a "MSVC"-like environment
  283. # define _LIBCPP_MSVCRT_LIKE
  284. // If mingw not explicitly detected, assume using MS C runtime only if
  285. // a MS compatibility version is specified.
  286. # if defined(_MSC_VER) && !defined(__MINGW32__)
  287. # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
  288. # endif
  289. # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
  290. # define _LIBCPP_HAS_BITSCAN64
  291. # endif
  292. # define _LIBCPP_HAS_OPEN_WITH_WCHAR
  293. # if defined(_LIBCPP_MSVCRT)
  294. # define _LIBCPP_HAS_QUICK_EXIT
  295. # endif
  296. // Some CRT APIs are unavailable to store apps
  297. # if defined(WINAPI_FAMILY)
  298. # include <winapifamily.h>
  299. # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
  300. (!defined(WINAPI_PARTITION_SYSTEM) || \
  301. !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
  302. # define _LIBCPP_WINDOWS_STORE_APP
  303. # endif
  304. # endif
  305. #endif // defined(_WIN32)
  306. #ifdef __sun__
  307. # include <sys/isa_defs.h>
  308. # ifdef _LITTLE_ENDIAN
  309. # define _LIBCPP_LITTLE_ENDIAN
  310. # else
  311. # define _LIBCPP_BIG_ENDIAN
  312. # endif
  313. #endif // __sun__
  314. #if defined(_AIX) && !defined(__64BIT__)
  315. // The size of wchar is 2 byte on 32-bit mode on AIX.
  316. # define _LIBCPP_SHORT_WCHAR 1
  317. #endif
  318. // Libc++ supports various implementations of std::random_device.
  319. //
  320. // _LIBCPP_USING_DEV_RANDOM
  321. // Read entropy from the given file, by default `/dev/urandom`.
  322. // If a token is provided, it is assumed to be the path to a file
  323. // to read entropy from. This is the default behavior if nothing
  324. // else is specified. This implementation requires storing state
  325. // inside `std::random_device`.
  326. //
  327. // _LIBCPP_USING_ARC4_RANDOM
  328. // Use arc4random(). This allows obtaining random data even when
  329. // using sandboxing mechanisms. On some platforms like Apple, this
  330. // is the recommended source of entropy for user-space programs.
  331. // When this option is used, the token passed to `std::random_device`'s
  332. // constructor *must* be "/dev/urandom" -- anything else is an error.
  333. //
  334. // _LIBCPP_USING_GETENTROPY
  335. // Use getentropy().
  336. // When this option is used, the token passed to `std::random_device`'s
  337. // constructor *must* be "/dev/urandom" -- anything else is an error.
  338. //
  339. // _LIBCPP_USING_FUCHSIA_CPRNG
  340. // Use Fuchsia's zx_cprng_draw() system call, which is specified to
  341. // deliver high-quality entropy and cannot fail.
  342. // When this option is used, the token passed to `std::random_device`'s
  343. // constructor *must* be "/dev/urandom" -- anything else is an error.
  344. //
  345. // _LIBCPP_USING_NACL_RANDOM
  346. // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
  347. // including accesses to the special files under `/dev`. This implementation
  348. // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
  349. // When this option is used, the token passed to `std::random_device`'s
  350. // constructor *must* be "/dev/urandom" -- anything else is an error.
  351. //
  352. // _LIBCPP_USING_WIN32_RANDOM
  353. // Use rand_s(), for use on Windows.
  354. // When this option is used, the token passed to `std::random_device`'s
  355. // constructor *must* be "/dev/urandom" -- anything else is an error.
  356. #if defined(__OpenBSD__) || defined(__APPLE__)
  357. # define _LIBCPP_USING_ARC4_RANDOM
  358. #elif defined(__wasi__)
  359. # define _LIBCPP_USING_GETENTROPY
  360. #elif defined(__Fuchsia__)
  361. # define _LIBCPP_USING_FUCHSIA_CPRNG
  362. #elif defined(__native_client__)
  363. # define _LIBCPP_USING_NACL_RANDOM
  364. #elif defined(_LIBCPP_WIN32API)
  365. # define _LIBCPP_USING_WIN32_RANDOM
  366. #else
  367. # define _LIBCPP_USING_DEV_RANDOM
  368. #endif
  369. #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
  370. # include <endian.h>
  371. # if __BYTE_ORDER == __LITTLE_ENDIAN
  372. # define _LIBCPP_LITTLE_ENDIAN
  373. # elif __BYTE_ORDER == __BIG_ENDIAN
  374. # define _LIBCPP_BIG_ENDIAN
  375. # else // __BYTE_ORDER == __BIG_ENDIAN
  376. # error unable to determine endian
  377. # endif
  378. #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
  379. #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
  380. # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
  381. #else
  382. # define _LIBCPP_NO_CFI
  383. #endif
  384. // If the compiler supports using_if_exists, pretend we have those functions and they'll
  385. // be picked up if the C library provides them.
  386. //
  387. // TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
  388. // for platforms that don't have a conforming C11 library, so we can drop this whole thing.
  389. #if __has_attribute(using_if_exists)
  390. # define _LIBCPP_HAS_TIMESPEC_GET
  391. # define _LIBCPP_HAS_QUICK_EXIT
  392. # define _LIBCPP_HAS_ALIGNED_ALLOC
  393. #else
  394. #if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
  395. # if defined(__FreeBSD__)
  396. # define _LIBCPP_HAS_ALIGNED_ALLOC
  397. # define _LIBCPP_HAS_QUICK_EXIT
  398. # if __FreeBSD_version >= 1300064 || \
  399. (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000)
  400. # define _LIBCPP_HAS_TIMESPEC_GET
  401. # endif
  402. # elif defined(__BIONIC__)
  403. # if __ANDROID_API__ >= 21
  404. # define _LIBCPP_HAS_QUICK_EXIT
  405. # endif
  406. # if __ANDROID_API__ >= 28
  407. # define _LIBCPP_HAS_ALIGNED_ALLOC
  408. # endif
  409. # if __ANDROID_API__ >= 29
  410. # define _LIBCPP_HAS_TIMESPEC_GET
  411. # endif
  412. # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__)
  413. # define _LIBCPP_HAS_ALIGNED_ALLOC
  414. # define _LIBCPP_HAS_QUICK_EXIT
  415. # define _LIBCPP_HAS_TIMESPEC_GET
  416. # elif defined(__OpenBSD__)
  417. # define _LIBCPP_HAS_ALIGNED_ALLOC
  418. # define _LIBCPP_HAS_TIMESPEC_GET
  419. # elif defined(__linux__)
  420. # if !defined(_LIBCPP_HAS_MUSL_LIBC)
  421. # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
  422. # define _LIBCPP_HAS_QUICK_EXIT
  423. # endif
  424. # if _LIBCPP_GLIBC_PREREQ(2, 17)
  425. # define _LIBCPP_HAS_ALIGNED_ALLOC
  426. # define _LIBCPP_HAS_TIMESPEC_GET
  427. # endif
  428. # else // defined(_LIBCPP_HAS_MUSL_LIBC)
  429. # define _LIBCPP_HAS_ALIGNED_ALLOC
  430. # define _LIBCPP_HAS_QUICK_EXIT
  431. # define _LIBCPP_HAS_TIMESPEC_GET
  432. # endif
  433. # elif defined(_LIBCPP_MSVCRT)
  434. // Using Microsoft's C Runtime library, not MinGW
  435. # define _LIBCPP_HAS_TIMESPEC_GET
  436. # elif defined(__APPLE__)
  437. // timespec_get and aligned_alloc were introduced in macOS 10.15 and
  438. // aligned releases
  439. # if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
  440. (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
  441. (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
  442. (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
  443. # define _LIBCPP_HAS_ALIGNED_ALLOC
  444. # define _LIBCPP_HAS_TIMESPEC_GET
  445. # endif
  446. # endif // __APPLE__
  447. #endif
  448. #endif // __has_attribute(using_if_exists)
  449. #ifndef _LIBCPP_CXX03_LANG
  450. # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
  451. #elif defined(_LIBCPP_COMPILER_CLANG_BASED)
  452. # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
  453. #else
  454. # error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
  455. #endif
  456. #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
  457. #if defined(_LIBCPP_COMPILER_CLANG_BASED)
  458. #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
  459. # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
  460. #endif
  461. #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
  462. (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
  463. # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  464. #endif
  465. #if __has_feature(cxx_alignas)
  466. # define _ALIGNAS_TYPE(x) alignas(x)
  467. # define _ALIGNAS(x) alignas(x)
  468. #else
  469. # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  470. # define _ALIGNAS(x) __attribute__((__aligned__(x)))
  471. #endif
  472. #if __cplusplus < 201103L
  473. typedef __char16_t char16_t;
  474. typedef __char32_t char32_t;
  475. #endif
  476. #if !__has_feature(cxx_exceptions)
  477. # define _LIBCPP_NO_EXCEPTIONS
  478. #endif
  479. #if !(__has_feature(cxx_strong_enums))
  480. #define _LIBCPP_HAS_NO_STRONG_ENUMS
  481. #endif
  482. #if __has_feature(cxx_attributes)
  483. # define _LIBCPP_NORETURN [[noreturn]]
  484. #else
  485. # define _LIBCPP_NORETURN __attribute__ ((noreturn))
  486. #endif
  487. #if !(__has_feature(cxx_nullptr))
  488. # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
  489. # define nullptr __nullptr
  490. # else
  491. # define _LIBCPP_HAS_NO_NULLPTR
  492. # endif
  493. #endif
  494. // Objective-C++ features (opt-in)
  495. #if __has_feature(objc_arc)
  496. #define _LIBCPP_HAS_OBJC_ARC
  497. #endif
  498. #if __has_feature(objc_arc_weak)
  499. #define _LIBCPP_HAS_OBJC_ARC_WEAK
  500. #endif
  501. #if __has_extension(blocks)
  502. # define _LIBCPP_HAS_EXTENSION_BLOCKS
  503. #endif
  504. #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
  505. # define _LIBCPP_HAS_BLOCKS_RUNTIME
  506. #endif
  507. #if !(__has_feature(cxx_noexcept))
  508. #define _LIBCPP_HAS_NO_NOEXCEPT
  509. #endif
  510. #if !__has_feature(address_sanitizer)
  511. #define _LIBCPP_HAS_NO_ASAN
  512. #endif
  513. // Allow for build-time disabling of unsigned integer sanitization
  514. #if __has_attribute(no_sanitize)
  515. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
  516. #endif
  517. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  518. #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  519. #elif defined(_LIBCPP_COMPILER_GCC)
  520. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  521. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  522. #define _LIBCPP_NORETURN __attribute__((noreturn))
  523. #if !defined(__EXCEPTIONS)
  524. # define _LIBCPP_NO_EXCEPTIONS
  525. #endif
  526. #if !defined(__SANITIZE_ADDRESS__)
  527. #define _LIBCPP_HAS_NO_ASAN
  528. #endif
  529. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  530. #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  531. #elif defined(_LIBCPP_COMPILER_MSVC)
  532. #define _LIBCPP_TOSTRING2(x) #x
  533. #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
  534. #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
  535. #if _MSC_VER < 1900
  536. #error "MSVC versions prior to Visual Studio 2015 are not supported"
  537. #endif
  538. #define _LIBCPP_HAS_IS_FINAL
  539. #define __alignof__ __alignof
  540. #define _LIBCPP_NORETURN __declspec(noreturn)
  541. #define _ALIGNAS(x) __declspec(align(x))
  542. #define _ALIGNAS_TYPE(x) alignas(x)
  543. #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  544. #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  545. #undef __has_feature
  546. #define __has_feature(x) __has_feature_##x
  547. #define __has_feature_is_standard_layout 1
  548. #define __has_feature_is_trivially_copyable 1
  549. #define __has_feature_is_trivial 1
  550. #define __has_feature_is_pod 1
  551. #define __has_feature_cxx_noexcept 1
  552. #define __has_feature_has_nothrow_assign 1
  553. #define __has_feature_is_union 1
  554. #define __has_feature_is_class 1
  555. #define __has_feature_is_enum 1
  556. #define __has_feature_is_convertible_to 1
  557. #define __has_feature_is_empty 1
  558. #define __has_feature_is_polymorphic 1
  559. #define __has_feature_has_virtual_destructor 1
  560. #define __has_feature_cxx_reference_qualified_functions 1
  561. #define __has_feature_is_constructible 1
  562. #define __has_feature_is_trivially_constructible 1
  563. #define __has_feature_is_trivially_assignable 1
  564. #define __has_feature_is_convertible_to 1
  565. #define __has_feature_has_trivial_constructor 1
  566. #define __has_feature_has_trivial_destructor 1
  567. #define __has_feature_has_nothrow_constructor 1
  568. #define __has_feature_has_nothrow_copy 1
  569. #define __has_feature_cxx_explicit_conversions 1
  570. #undef __has_builtin
  571. #define __has_builtin(x) __has_builtin_##x
  572. #define __has_builtin___builtin_addressof 1
  573. #define _LIBCPP_WEAK
  574. #define _LIBCPP_HAS_NO_ASAN
  575. #define _LIBCPP_ALWAYS_INLINE __forceinline
  576. #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
  577. #define _LIBCPP_DISABLE_EXTENSION_WARNING
  578. #elif defined(_LIBCPP_COMPILER_IBM)
  579. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  580. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  581. #define _ATTRIBUTE(x) __attribute__((x))
  582. #define _LIBCPP_NORETURN __attribute__((noreturn))
  583. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  584. #if defined(_AIX)
  585. #define __MULTILOCALE_API
  586. #endif
  587. #define _LIBCPP_HAS_NO_ASAN
  588. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  589. #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
  590. #define _LIBCPP_DISABLE_EXTENSION_WARNING
  591. #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
  592. #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
  593. #ifdef _DLL
  594. # define _LIBCPP_CRT_FUNC __declspec(dllimport)
  595. #else
  596. # define _LIBCPP_CRT_FUNC
  597. #endif
  598. #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  599. # define _LIBCPP_DLL_VIS
  600. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  601. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  602. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  603. # define _LIBCPP_EXPORTED_FROM_ABI
  604. #elif defined(_LIBCPP_BUILDING_LIBRARY)
  605. # define _LIBCPP_DLL_VIS __declspec(dllexport)
  606. # if defined(__MINGW32__)
  607. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  608. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  609. # else
  610. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  611. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
  612. # endif
  613. # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
  614. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
  615. #else
  616. # define _LIBCPP_DLL_VIS __declspec(dllimport)
  617. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  618. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  619. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  620. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
  621. #endif
  622. #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
  623. #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
  624. #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
  625. #define _LIBCPP_HIDDEN
  626. #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  627. #define _LIBCPP_TEMPLATE_VIS
  628. #define _LIBCPP_TEMPLATE_DATA_VIS
  629. #define _LIBCPP_ENUM_VIS
  630. #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
  631. #ifndef _LIBCPP_HIDDEN
  632. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  633. # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
  634. # else
  635. # define _LIBCPP_HIDDEN
  636. # endif
  637. #endif
  638. #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  639. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  640. // The inline should be removed once PR32114 is resolved
  641. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
  642. # else
  643. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  644. # endif
  645. #endif
  646. #ifndef _LIBCPP_FUNC_VIS
  647. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  648. # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
  649. # else
  650. # define _LIBCPP_FUNC_VIS
  651. # endif
  652. #endif
  653. #ifndef _LIBCPP_TYPE_VIS
  654. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  655. # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
  656. # else
  657. # define _LIBCPP_TYPE_VIS
  658. # endif
  659. #endif
  660. #ifndef _LIBCPP_TEMPLATE_VIS
  661. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  662. # if __has_attribute(__type_visibility__)
  663. # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
  664. # else
  665. # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
  666. # endif
  667. # else
  668. # define _LIBCPP_TEMPLATE_VIS
  669. # endif
  670. #endif
  671. #ifndef _LIBCPP_TEMPLATE_DATA_VIS
  672. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  673. # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
  674. # else
  675. # define _LIBCPP_TEMPLATE_DATA_VIS
  676. # endif
  677. #endif
  678. #ifndef _LIBCPP_EXPORTED_FROM_ABI
  679. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  680. # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
  681. # else
  682. # define _LIBCPP_EXPORTED_FROM_ABI
  683. # endif
  684. #endif
  685. #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
  686. #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
  687. #endif
  688. #ifndef _LIBCPP_EXCEPTION_ABI
  689. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  690. # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
  691. # else
  692. # define _LIBCPP_EXCEPTION_ABI
  693. # endif
  694. #endif
  695. #ifndef _LIBCPP_ENUM_VIS
  696. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
  697. # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
  698. # else
  699. # define _LIBCPP_ENUM_VIS
  700. # endif
  701. #endif
  702. #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  703. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  704. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
  705. # else
  706. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  707. # endif
  708. #endif
  709. #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  710. #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  711. #endif
  712. #if __has_attribute(internal_linkage)
  713. # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
  714. #else
  715. # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
  716. #endif
  717. #if __has_attribute(exclude_from_explicit_instantiation)
  718. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
  719. #else
  720. // Try to approximate the effect of exclude_from_explicit_instantiation
  721. // (which is that entities are not assumed to be provided by explicit
  722. // template instantiations in the dylib) by always inlining those entities.
  723. #ifdef _LIBCPP_COMPILER_MSVC
  724. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
  725. #else
  726. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
  727. #endif
  728. #endif
  729. #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
  730. # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
  731. # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
  732. # else
  733. # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
  734. # endif
  735. #endif
  736. #ifndef _LIBCPP_HIDE_FROM_ABI
  737. # if _LIBCPP_HIDE_FROM_ABI_PER_TU
  738. # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
  739. # else
  740. # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
  741. # endif
  742. #endif
  743. #ifdef _LIBCPP_BUILDING_LIBRARY
  744. # if _LIBCPP_ABI_VERSION > 1
  745. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  746. # else
  747. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  748. # endif
  749. #else
  750. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  751. #endif
  752. // Just so we can migrate to the new macros gradually.
  753. #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
  754. // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
  755. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
  756. #define _LIBCPP_END_NAMESPACE_STD } }
  757. #define _VSTD std::_LIBCPP_ABI_NAMESPACE
  758. _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
  759. #if _LIBCPP_STD_VER >= 17
  760. #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  761. _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
  762. #else
  763. #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  764. _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
  765. #endif
  766. #define _LIBCPP_END_NAMESPACE_FILESYSTEM \
  767. _LIBCPP_END_NAMESPACE_STD } }
  768. #define _VSTD_FS _VSTD::__fs::filesystem
  769. #if __has_attribute(__enable_if__)
  770. # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
  771. #endif
  772. #ifndef _LIBCPP_HAS_NO_NOEXCEPT
  773. # define _NOEXCEPT noexcept
  774. # define _NOEXCEPT_(x) noexcept(x)
  775. #else
  776. # define _NOEXCEPT throw()
  777. # define _NOEXCEPT_(x)
  778. #endif
  779. #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
  780. typedef unsigned short char16_t;
  781. typedef unsigned int char32_t;
  782. #endif
  783. #ifndef __SIZEOF_INT128__
  784. #define _LIBCPP_HAS_NO_INT128
  785. #endif
  786. #ifdef _LIBCPP_CXX03_LANG
  787. # define static_assert(...) _Static_assert(__VA_ARGS__)
  788. # define decltype(...) __decltype(__VA_ARGS__)
  789. #endif // _LIBCPP_CXX03_LANG
  790. #ifdef _LIBCPP_CXX03_LANG
  791. # define _LIBCPP_CONSTEXPR
  792. #else
  793. # define _LIBCPP_CONSTEXPR constexpr
  794. #endif
  795. #ifndef __cpp_consteval
  796. # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
  797. #else
  798. # define _LIBCPP_CONSTEVAL consteval
  799. #endif
  800. #if !defined(__cpp_concepts) || __cpp_concepts < 201907L
  801. #define _LIBCPP_HAS_NO_CONCEPTS
  802. #endif
  803. #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS)
  804. #define _LIBCPP_HAS_NO_RANGES
  805. #endif
  806. #ifdef __GNUC__
  807. # define _LIBCPP_NOALIAS __attribute__((__malloc__))
  808. #else
  809. # define _LIBCPP_NOALIAS
  810. #endif
  811. #if __has_attribute(using_if_exists)
  812. # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
  813. #else
  814. # define _LIBCPP_USING_IF_EXISTS
  815. #endif
  816. #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
  817. # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
  818. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
  819. __lx __v_; \
  820. _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
  821. _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
  822. _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
  823. };
  824. #else // _LIBCPP_HAS_NO_STRONG_ENUMS
  825. # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
  826. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
  827. #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
  828. // _LIBCPP_DEBUG potential values:
  829. // - undefined: No assertions. This is the default.
  830. // - 0: Basic assertions
  831. // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
  832. # if !defined(_LIBCPP_DEBUG)
  833. # define _LIBCPP_DEBUG_LEVEL 0
  834. # elif _LIBCPP_DEBUG == 0
  835. # define _LIBCPP_DEBUG_LEVEL 1
  836. # elif _LIBCPP_DEBUG == 1
  837. # define _LIBCPP_DEBUG_LEVEL 2
  838. # else
  839. # error Supported values for _LIBCPP_DEBUG are 0 and 1
  840. # endif
  841. # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
  842. # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
  843. # endif
  844. # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
  845. # if defined(_LIBCPP_CXX03_LANG)
  846. # error Support for unspecified stability is only for C++11 and higher
  847. # endif
  848. # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
  849. do { \
  850. if (!__builtin_is_constant_evaluated()) \
  851. _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
  852. } while (false)
  853. # else
  854. # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
  855. do { \
  856. } while (false)
  857. # endif
  858. // Libc++ allows disabling extern template instantiation declarations by
  859. // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
  860. //
  861. // Furthermore, when the Debug mode is enabled, we disable extern declarations
  862. // when building user code because we don't want to use the functions compiled
  863. // in the library, which might not have had the debug mode enabled when built.
  864. // However, some extern declarations need to be used, because code correctness
  865. // depends on it (several instances in <locale>). Those special declarations
  866. // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
  867. // even when the debug mode is enabled.
  868. #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
  869. # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
  870. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
  871. #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
  872. # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
  873. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
  874. #else
  875. # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
  876. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
  877. #endif
  878. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
  879. defined(__sun__) || defined(__NetBSD__)
  880. #define _LIBCPP_LOCALE__L_EXTENSIONS 1
  881. #endif
  882. #ifdef __FreeBSD__
  883. #define _DECLARE_C99_LDBL_MATH 1
  884. #endif
  885. // If we are getting operator new from the MSVC CRT, then allocation overloads
  886. // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
  887. #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
  888. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  889. #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
  890. // We're deferring to Microsoft's STL to provide aligned new et al. We don't
  891. // have it unless the language feature test macro is defined.
  892. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  893. #elif defined(__MVS__)
  894. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  895. #endif
  896. #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
  897. (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
  898. # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
  899. #endif
  900. #if defined(__APPLE__) || defined(__FreeBSD__)
  901. #define _LIBCPP_HAS_DEFAULTRUNELOCALE
  902. #endif
  903. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
  904. #define _LIBCPP_WCTYPE_IS_MASK
  905. #endif
  906. #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
  907. #define _LIBCPP_HAS_NO_CHAR8_T
  908. #endif
  909. // Deprecation macros.
  910. //
  911. // Deprecations warnings are always enabled, except when users explicitly opt-out
  912. // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
  913. #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
  914. # if __has_attribute(deprecated)
  915. # define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
  916. # elif _LIBCPP_STD_VER > 11
  917. # define _LIBCPP_DEPRECATED [[deprecated]]
  918. # else
  919. # define _LIBCPP_DEPRECATED
  920. # endif
  921. #else
  922. # define _LIBCPP_DEPRECATED
  923. #endif
  924. #if !defined(_LIBCPP_CXX03_LANG)
  925. # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
  926. #else
  927. # define _LIBCPP_DEPRECATED_IN_CXX11
  928. #endif
  929. #if _LIBCPP_STD_VER >= 14
  930. # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
  931. #else
  932. # define _LIBCPP_DEPRECATED_IN_CXX14
  933. #endif
  934. #if _LIBCPP_STD_VER >= 17
  935. # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
  936. #else
  937. # define _LIBCPP_DEPRECATED_IN_CXX17
  938. #endif
  939. #if _LIBCPP_STD_VER > 17
  940. # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
  941. #else
  942. # define _LIBCPP_DEPRECATED_IN_CXX20
  943. #endif
  944. #if !defined(_LIBCPP_HAS_NO_CHAR8_T)
  945. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
  946. #else
  947. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
  948. #endif
  949. #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
  950. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
  951. _Pragma("GCC diagnostic push") \
  952. _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
  953. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  954. # define _LIBCPP_SUPPRESS_DEPRECATED_POP \
  955. _Pragma("GCC diagnostic pop")
  956. #else
  957. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  958. # define _LIBCPP_SUPPRESS_DEPRECATED_POP
  959. #endif
  960. #if _LIBCPP_STD_VER <= 11
  961. # define _LIBCPP_EXPLICIT_AFTER_CXX11
  962. #else
  963. # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
  964. #endif
  965. #if _LIBCPP_STD_VER > 11
  966. # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  967. #else
  968. # define _LIBCPP_CONSTEXPR_AFTER_CXX11
  969. #endif
  970. #if _LIBCPP_STD_VER > 14
  971. # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  972. #else
  973. # define _LIBCPP_CONSTEXPR_AFTER_CXX14
  974. #endif
  975. #if _LIBCPP_STD_VER > 17
  976. # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
  977. #else
  978. # define _LIBCPP_CONSTEXPR_AFTER_CXX17
  979. #endif
  980. #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
  981. # define _LIBCPP_NODISCARD [[nodiscard]]
  982. #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
  983. # define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
  984. #else
  985. // We can't use GCC's [[gnu::warn_unused_result]] and
  986. // __attribute__((warn_unused_result)), because GCC does not silence them via
  987. // (void) cast.
  988. # define _LIBCPP_NODISCARD
  989. #endif
  990. // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
  991. // specified as such as an extension.
  992. #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
  993. # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
  994. #else
  995. # define _LIBCPP_NODISCARD_EXT
  996. #endif
  997. #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
  998. (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
  999. # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
  1000. #else
  1001. # define _LIBCPP_NODISCARD_AFTER_CXX17
  1002. #endif
  1003. #if __has_attribute(no_destroy)
  1004. # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
  1005. #else
  1006. # define _LIBCPP_NO_DESTROY
  1007. #endif
  1008. #ifndef _LIBCPP_HAS_NO_ASAN
  1009. extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
  1010. const void *, const void *, const void *, const void *);
  1011. #endif
  1012. // Try to find out if RTTI is disabled.
  1013. #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
  1014. # define _LIBCPP_NO_RTTI
  1015. #elif defined(__GNUC__) && !defined(__GXX_RTTI)
  1016. # define _LIBCPP_NO_RTTI
  1017. #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
  1018. # define _LIBCPP_NO_RTTI
  1019. #endif
  1020. #ifndef _LIBCPP_WEAK
  1021. #define _LIBCPP_WEAK __attribute__((__weak__))
  1022. #endif
  1023. // Thread API
  1024. #if !defined(_LIBCPP_HAS_NO_THREADS) && \
  1025. !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
  1026. !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
  1027. !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  1028. # if defined(__FreeBSD__) || \
  1029. defined(__wasi__) || \
  1030. defined(__NetBSD__) || \
  1031. defined(__OpenBSD__) || \
  1032. defined(__NuttX__) || \
  1033. defined(__linux__) || \
  1034. defined(__GNU__) || \
  1035. defined(__APPLE__) || \
  1036. defined(__sun__) || \
  1037. defined(__MVS__) || \
  1038. defined(_AIX) || \
  1039. defined(__CYGWIN__)
  1040. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  1041. # elif defined(__Fuchsia__)
  1042. // TODO(44575): Switch to C11 thread API when possible.
  1043. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  1044. # elif defined(_LIBCPP_WIN32API)
  1045. # define _LIBCPP_HAS_THREAD_API_WIN32
  1046. # else
  1047. # error "No thread API"
  1048. # endif // _LIBCPP_HAS_THREAD_API
  1049. #endif // _LIBCPP_HAS_NO_THREADS
  1050. #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  1051. #if defined(__ANDROID__) && __ANDROID_API__ >= 30
  1052. #define _LIBCPP_HAS_COND_CLOCKWAIT
  1053. #elif defined(_LIBCPP_GLIBC_PREREQ)
  1054. #if _LIBCPP_GLIBC_PREREQ(2, 30)
  1055. #define _LIBCPP_HAS_COND_CLOCKWAIT
  1056. #endif
  1057. #endif
  1058. #endif
  1059. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  1060. #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
  1061. _LIBCPP_HAS_NO_THREADS is not defined.
  1062. #endif
  1063. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  1064. #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
  1065. _LIBCPP_HAS_NO_THREADS is defined.
  1066. #endif
  1067. #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
  1068. #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  1069. _LIBCPP_HAS_NO_THREADS is defined.
  1070. #endif
  1071. #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
  1072. #define __STDCPP_THREADS__ 1
  1073. #endif
  1074. // The glibc and Bionic implementation of pthreads implements
  1075. // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
  1076. // mutexes have no destroy mechanism.
  1077. //
  1078. // This optimization can't be performed on Apple platforms, where
  1079. // pthread_mutex_destroy can allow the kernel to release resources.
  1080. // See https://llvm.org/D64298 for details.
  1081. //
  1082. // TODO(EricWF): Enable this optimization on Bionic after speaking to their
  1083. // respective stakeholders.
  1084. #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
  1085. || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
  1086. || defined(_LIBCPP_HAS_THREAD_API_WIN32)
  1087. # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
  1088. #endif
  1089. // Destroying a condvar is a nop on Windows.
  1090. //
  1091. // This optimization can't be performed on Apple platforms, where
  1092. // pthread_cond_destroy can allow the kernel to release resources.
  1093. // See https://llvm.org/D64298 for details.
  1094. //
  1095. // TODO(EricWF): This is potentially true for some pthread implementations
  1096. // as well.
  1097. #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
  1098. defined(_LIBCPP_HAS_THREAD_API_WIN32)
  1099. # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
  1100. #endif
  1101. // Some systems do not provide gets() in their C library, for security reasons.
  1102. #if defined(_LIBCPP_MSVCRT) || \
  1103. (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
  1104. defined(__OpenBSD__)
  1105. # define _LIBCPP_C_HAS_NO_GETS
  1106. #endif
  1107. #if defined(__BIONIC__) || defined(__NuttX__) || \
  1108. defined(__Fuchsia__) || defined(__wasi__) || \
  1109. defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
  1110. #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
  1111. #endif
  1112. #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
  1113. # define _LIBCPP_HAS_C_ATOMIC_IMP
  1114. #elif defined(_LIBCPP_COMPILER_GCC)
  1115. # define _LIBCPP_HAS_GCC_ATOMIC_IMP
  1116. #endif
  1117. #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
  1118. !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
  1119. !defined(_LIBCPP_COMPILER_MSVC) && \
  1120. !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
  1121. # define _LIBCPP_HAS_NO_ATOMIC_HEADER
  1122. #else
  1123. # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
  1124. # define _LIBCPP_ATOMIC_FLAG_TYPE bool
  1125. # endif
  1126. # ifdef _LIBCPP_FREESTANDING
  1127. # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
  1128. # endif
  1129. #endif
  1130. #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  1131. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  1132. #endif
  1133. #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
  1134. # if defined(__clang__) && __has_attribute(acquire_capability)
  1135. // Work around the attribute handling in clang. When both __declspec and
  1136. // __attribute__ are present, the processing goes awry preventing the definition
  1137. // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
  1138. // combining the two does work.
  1139. # if !defined(_MSC_VER)
  1140. # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  1141. # endif
  1142. # endif
  1143. #endif
  1144. #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  1145. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
  1146. #else
  1147. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
  1148. #endif
  1149. #if __has_attribute(require_constant_initialization)
  1150. # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
  1151. #else
  1152. # define _LIBCPP_SAFE_STATIC
  1153. #endif
  1154. #if !__has_builtin(__builtin_is_constant_evaluated) || (defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER < 900) || __CUDACC_VER_MAJOR__ == 10
  1155. #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
  1156. #endif
  1157. #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
  1158. # define _LIBCPP_DIAGNOSE_WARNING(...) \
  1159. __attribute__((diagnose_if(__VA_ARGS__, "warning")))
  1160. # define _LIBCPP_DIAGNOSE_ERROR(...) \
  1161. __attribute__((diagnose_if(__VA_ARGS__, "error")))
  1162. #else
  1163. # define _LIBCPP_DIAGNOSE_WARNING(...)
  1164. # define _LIBCPP_DIAGNOSE_ERROR(...)
  1165. #endif
  1166. // Use a function like macro to imply that it must be followed by a semicolon
  1167. #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
  1168. # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
  1169. #elif __has_cpp_attribute(clang::fallthrough)
  1170. # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
  1171. #elif __has_attribute(__fallthrough__)
  1172. # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
  1173. #else
  1174. # define _LIBCPP_FALLTHROUGH() ((void)0)
  1175. #endif
  1176. #if __has_attribute(__nodebug__) && !defined(__CUDACC__)
  1177. #define _LIBCPP_NODEBUG __attribute__((__nodebug__))
  1178. #else
  1179. #define _LIBCPP_NODEBUG
  1180. #endif
  1181. #if __has_attribute(__standalone_debug__)
  1182. #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
  1183. #else
  1184. #define _LIBCPP_STANDALONE_DEBUG
  1185. #endif
  1186. #if __has_attribute(__preferred_name__)
  1187. #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
  1188. #else
  1189. #define _LIBCPP_PREFERRED_NAME(x)
  1190. #endif
  1191. // We often repeat things just for handling wide characters in the library.
  1192. // When wide characters are disabled, it can be useful to have a quick way of
  1193. // disabling it without having to resort to #if-#endif, which has a larger
  1194. // impact on readability.
  1195. #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
  1196. # define _LIBCPP_IF_WIDE_CHARACTERS(...)
  1197. #else
  1198. # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
  1199. #endif
  1200. #if defined(_LIBCPP_ABI_MICROSOFT) && \
  1201. (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
  1202. !defined(__CUDACC__)
  1203. # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
  1204. #else
  1205. # define _LIBCPP_DECLSPEC_EMPTY_BASES
  1206. #endif
  1207. #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
  1208. #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
  1209. #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
  1210. #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
  1211. #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
  1212. #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
  1213. #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
  1214. #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
  1215. #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
  1216. #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
  1217. #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
  1218. #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
  1219. #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
  1220. #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
  1221. #define _LIBCPP_HAS_NO_CXX20_COROUTINES
  1222. #endif
  1223. // Yandex-specific: We build our own libc++, so it has everything available
  1224. #define _LIBCPP_DISABLE_AVAILABILITY
  1225. // End of Yandex-specific
  1226. #if defined(_LIBCPP_COMPILER_IBM) || defined(__CUDACC__)
  1227. #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
  1228. #endif
  1229. #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
  1230. # define _LIBCPP_PUSH_MACROS
  1231. # define _LIBCPP_POP_MACROS
  1232. #else
  1233. // Don't warn about macro conflicts when we can restore them at the
  1234. // end of the header.
  1235. # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
  1236. # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
  1237. # endif
  1238. # if defined(_LIBCPP_COMPILER_MSVC)
  1239. # define _LIBCPP_PUSH_MACROS \
  1240. __pragma(push_macro("min")) \
  1241. __pragma(push_macro("max"))
  1242. # define _LIBCPP_POP_MACROS \
  1243. __pragma(pop_macro("min")) \
  1244. __pragma(pop_macro("max"))
  1245. # else
  1246. # define _LIBCPP_PUSH_MACROS \
  1247. _Pragma("push_macro(\"min\")") \
  1248. _Pragma("push_macro(\"max\")")
  1249. # define _LIBCPP_POP_MACROS \
  1250. _Pragma("pop_macro(\"min\")") \
  1251. _Pragma("pop_macro(\"max\")")
  1252. # endif
  1253. #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
  1254. #ifndef _LIBCPP_NO_AUTO_LINK
  1255. # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  1256. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  1257. # pragma comment(lib, "c++.lib")
  1258. # else
  1259. # pragma comment(lib, "libc++.lib")
  1260. # endif
  1261. # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  1262. #endif // _LIBCPP_NO_AUTO_LINK
  1263. // Configures the fopen close-on-exec mode character, if any. This string will
  1264. // be appended to any mode string used by fstream for fopen/fdopen.
  1265. //
  1266. // Not all platforms support this, but it helps avoid fd-leaks on platforms that
  1267. // do.
  1268. #if defined(__BIONIC__)
  1269. # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
  1270. #else
  1271. # define _LIBCPP_FOPEN_CLOEXEC_MODE
  1272. #endif
  1273. #ifdef _LIBCPP_COMPILER_MSVC
  1274. #define _LIBCPP_BUILTIN_CONSTANT_P(x) false
  1275. #else
  1276. #define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x)
  1277. #endif
  1278. // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
  1279. // of functions used in cstdio may not be available for low API levels when
  1280. // using 64-bit file offsets on LP32.
  1281. #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
  1282. #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
  1283. #endif
  1284. #if __has_attribute(init_priority)
  1285. // TODO: Remove this once we drop support for building libc++ with old Clangs
  1286. # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
  1287. (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
  1288. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
  1289. # else
  1290. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
  1291. # endif
  1292. #else
  1293. # define _LIBCPP_INIT_PRIORITY_MAX
  1294. #endif
  1295. #if defined(__GNUC__) || defined(__clang__)
  1296. // The attribute uses 1-based indices for ordinary and static member functions.
  1297. // The attribute uses 2-based indices for non-static member functions.
  1298. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
  1299. __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
  1300. #else
  1301. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
  1302. #endif
  1303. #if __has_cpp_attribute(msvc::no_unique_address)
  1304. // MSVC implements [[no_unique_address]] as a silent no-op currently.
  1305. // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
  1306. // However, MSVC implements [[msvc::no_unique_address]] which does what
  1307. // [[no_unique_address]] is supposed to do, in general.
  1308. // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
  1309. // [[msvc::no_unique_address]] though. If/when it does implement
  1310. // [[msvc::no_unique_address]], this should be preferred though.
  1311. # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
  1312. #elif __has_cpp_attribute(no_unique_address)
  1313. # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
  1314. #else
  1315. # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
  1316. // Note that this can be replaced by #error as soon as clang-cl
  1317. // implements msvc::no_unique_address, since there should be no C++20
  1318. // compiler that doesn't support one of the two attributes at that point.
  1319. // We geenrally don't want to use this macro outside of C++20-only code,
  1320. // because using it conditionally in one language version only would make
  1321. // the ABI inconsistent.
  1322. #endif
  1323. #endif // __cplusplus
  1324. #endif // _LIBCPP_CONFIG