__config 53 KB

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