__config 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  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_attributes)
  467. # define _LIBCPP_NORETURN [[noreturn]]
  468. #else
  469. # define _LIBCPP_NORETURN __attribute__ ((noreturn))
  470. #endif
  471. #ifdef _LIBCPP_CXX03_LANG
  472. # define nullptr __nullptr
  473. #endif
  474. // Objective-C++ features (opt-in)
  475. #if __has_feature(objc_arc)
  476. #define _LIBCPP_HAS_OBJC_ARC
  477. #endif
  478. #if __has_feature(objc_arc_weak)
  479. #define _LIBCPP_HAS_OBJC_ARC_WEAK
  480. #endif
  481. #if __has_extension(blocks)
  482. # define _LIBCPP_HAS_EXTENSION_BLOCKS
  483. #endif
  484. #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
  485. # define _LIBCPP_HAS_BLOCKS_RUNTIME
  486. #endif
  487. #if !(__has_feature(cxx_noexcept))
  488. #define _LIBCPP_HAS_NO_NOEXCEPT
  489. #endif
  490. #if !__has_feature(address_sanitizer)
  491. #define _LIBCPP_HAS_NO_ASAN
  492. #endif
  493. // Allow for build-time disabling of unsigned integer sanitization
  494. #if __has_attribute(no_sanitize)
  495. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
  496. #endif
  497. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  498. #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  499. #elif defined(_LIBCPP_COMPILER_GCC)
  500. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  501. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  502. #define _LIBCPP_NORETURN __attribute__((noreturn))
  503. #if !defined(__EXCEPTIONS)
  504. # define _LIBCPP_NO_EXCEPTIONS
  505. #endif
  506. #if !defined(__SANITIZE_ADDRESS__)
  507. #define _LIBCPP_HAS_NO_ASAN
  508. #endif
  509. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  510. #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  511. #elif defined(_LIBCPP_COMPILER_MSVC)
  512. #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
  513. #if _MSC_VER < 1900
  514. #error "MSVC versions prior to Visual Studio 2015 are not supported"
  515. #endif
  516. #define _LIBCPP_HAS_IS_FINAL
  517. #define __alignof__ __alignof
  518. #define _LIBCPP_NORETURN __declspec(noreturn)
  519. #define _ALIGNAS(x) __declspec(align(x))
  520. #define _ALIGNAS_TYPE(x) alignas(x)
  521. #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  522. #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  523. #undef __has_feature
  524. #define __has_feature(x) __has_feature_##x
  525. #define __has_feature_is_standard_layout 1
  526. #define __has_feature_is_trivially_copyable 1
  527. #define __has_feature_is_trivial 1
  528. #define __has_feature_is_pod 1
  529. #define __has_feature_cxx_noexcept 1
  530. #define __has_feature_has_nothrow_assign 1
  531. #define __has_feature_is_union 1
  532. #define __has_feature_is_class 1
  533. #define __has_feature_is_enum 1
  534. #define __has_feature_is_convertible_to 1
  535. #define __has_feature_is_empty 1
  536. #define __has_feature_is_polymorphic 1
  537. #define __has_feature_has_virtual_destructor 1
  538. #define __has_feature_cxx_reference_qualified_functions 1
  539. #define __has_feature_is_constructible 1
  540. #define __has_feature_is_trivially_constructible 1
  541. #define __has_feature_is_trivially_assignable 1
  542. #define __has_feature_is_convertible_to 1
  543. #define __has_feature_has_trivial_constructor 1
  544. #define __has_feature_has_trivial_destructor 1
  545. #define __has_feature_has_nothrow_constructor 1
  546. #define __has_feature_has_nothrow_copy 1
  547. #define __has_feature_cxx_explicit_conversions 1
  548. #undef __has_builtin
  549. #define __has_builtin(x) __has_builtin_##x
  550. #define __has_builtin___builtin_addressof 1
  551. #if defined(_MSC_VER) && defined(__CUDACC__)
  552. // nvcc fails to compile __builtin_is_constant_evaluated() at the time
  553. # define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED 1
  554. #else
  555. # define __has_builtin___builtin_is_constant_evaluated 1
  556. #endif
  557. #define _LIBCPP_WEAK
  558. #define _LIBCPP_HAS_NO_ASAN
  559. #define _LIBCPP_ALWAYS_INLINE __forceinline
  560. #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
  561. #define _LIBCPP_DISABLE_EXTENSION_WARNING
  562. #elif defined(_LIBCPP_COMPILER_IBM)
  563. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  564. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  565. #define _ATTRIBUTE(x) __attribute__((x))
  566. #define _LIBCPP_NORETURN __attribute__((noreturn))
  567. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  568. #if defined(_AIX)
  569. #define __MULTILOCALE_API
  570. #endif
  571. #define _LIBCPP_HAS_NO_ASAN
  572. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
  573. #define _LIBCPP_HAS_NO_VECTOR_EXTENSION
  574. #define _LIBCPP_DISABLE_EXTENSION_WARNING
  575. #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
  576. #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
  577. #ifdef _DLL
  578. # define _LIBCPP_CRT_FUNC __declspec(dllimport)
  579. #else
  580. # define _LIBCPP_CRT_FUNC
  581. #endif
  582. #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  583. # define _LIBCPP_DLL_VIS
  584. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  585. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  586. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  587. # define _LIBCPP_EXPORTED_FROM_ABI
  588. #elif defined(_LIBCPP_BUILDING_LIBRARY)
  589. # define _LIBCPP_DLL_VIS __declspec(dllexport)
  590. # if defined(__MINGW32__)
  591. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  592. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  593. # else
  594. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  595. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
  596. # endif
  597. # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
  598. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
  599. #else
  600. # define _LIBCPP_DLL_VIS __declspec(dllimport)
  601. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  602. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  603. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  604. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
  605. #endif
  606. #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
  607. #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
  608. #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
  609. #define _LIBCPP_HIDDEN
  610. #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  611. #define _LIBCPP_TEMPLATE_VIS
  612. #define _LIBCPP_TEMPLATE_DATA_VIS
  613. #define _LIBCPP_ENUM_VIS
  614. #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
  615. #ifndef _LIBCPP_HIDDEN
  616. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  617. # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
  618. # else
  619. # define _LIBCPP_HIDDEN
  620. # endif
  621. #endif
  622. #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  623. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  624. // The inline should be removed once PR32114 is resolved
  625. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
  626. # else
  627. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  628. # endif
  629. #endif
  630. #ifndef _LIBCPP_FUNC_VIS
  631. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  632. # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
  633. # else
  634. # define _LIBCPP_FUNC_VIS
  635. # endif
  636. #endif
  637. #ifndef _LIBCPP_TYPE_VIS
  638. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  639. # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
  640. # else
  641. # define _LIBCPP_TYPE_VIS
  642. # endif
  643. #endif
  644. #ifndef _LIBCPP_TEMPLATE_VIS
  645. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  646. # if __has_attribute(__type_visibility__)
  647. # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
  648. # else
  649. # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
  650. # endif
  651. # else
  652. # define _LIBCPP_TEMPLATE_VIS
  653. # endif
  654. #endif
  655. #ifndef _LIBCPP_TEMPLATE_DATA_VIS
  656. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  657. # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
  658. # else
  659. # define _LIBCPP_TEMPLATE_DATA_VIS
  660. # endif
  661. #endif
  662. #ifndef _LIBCPP_EXPORTED_FROM_ABI
  663. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  664. # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
  665. # else
  666. # define _LIBCPP_EXPORTED_FROM_ABI
  667. # endif
  668. #endif
  669. #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
  670. #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
  671. #endif
  672. #ifndef _LIBCPP_EXCEPTION_ABI
  673. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  674. # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
  675. # else
  676. # define _LIBCPP_EXCEPTION_ABI
  677. # endif
  678. #endif
  679. #ifndef _LIBCPP_ENUM_VIS
  680. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
  681. # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
  682. # else
  683. # define _LIBCPP_ENUM_VIS
  684. # endif
  685. #endif
  686. #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  687. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  688. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
  689. # else
  690. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  691. # endif
  692. #endif
  693. #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  694. #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  695. #endif
  696. #if __has_attribute(internal_linkage)
  697. # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
  698. #else
  699. # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
  700. #endif
  701. #if __has_attribute(exclude_from_explicit_instantiation)
  702. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__))
  703. #else
  704. // Try to approximate the effect of exclude_from_explicit_instantiation
  705. // (which is that entities are not assumed to be provided by explicit
  706. // template instantiations in the dylib) by always inlining those entities.
  707. #ifdef _LIBCPP_COMPILER_MSVC
  708. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
  709. #else
  710. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
  711. #endif
  712. #endif
  713. #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
  714. # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
  715. # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
  716. # else
  717. # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
  718. # endif
  719. #endif
  720. #ifndef _LIBCPP_HIDE_FROM_ABI
  721. # if _LIBCPP_HIDE_FROM_ABI_PER_TU
  722. # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
  723. # else
  724. # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
  725. # endif
  726. #endif
  727. #ifdef _LIBCPP_BUILDING_LIBRARY
  728. # if _LIBCPP_ABI_VERSION > 1
  729. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  730. # else
  731. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  732. # endif
  733. #else
  734. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  735. #endif
  736. // Just so we can migrate to the new macros gradually.
  737. #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
  738. // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
  739. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
  740. #define _LIBCPP_END_NAMESPACE_STD } }
  741. #define _VSTD std
  742. _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
  743. #if _LIBCPP_STD_VER > 14
  744. #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  745. _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
  746. #else
  747. #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  748. _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
  749. #endif
  750. #define _LIBCPP_END_NAMESPACE_FILESYSTEM \
  751. _LIBCPP_END_NAMESPACE_STD } }
  752. #define _VSTD_FS std::__fs::filesystem
  753. #if __has_attribute(__enable_if__)
  754. # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
  755. #endif
  756. #ifndef _LIBCPP_HAS_NO_NOEXCEPT
  757. # define _NOEXCEPT noexcept
  758. # define _NOEXCEPT_(x) noexcept(x)
  759. #else
  760. # define _NOEXCEPT throw()
  761. # define _NOEXCEPT_(x)
  762. #endif
  763. #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
  764. typedef unsigned short char16_t;
  765. typedef unsigned int char32_t;
  766. #endif
  767. #ifndef __SIZEOF_INT128__
  768. #define _LIBCPP_HAS_NO_INT128
  769. #endif
  770. #ifdef _LIBCPP_CXX03_LANG
  771. # define static_assert(...) _Static_assert(__VA_ARGS__)
  772. # define decltype(...) __decltype(__VA_ARGS__)
  773. #endif // _LIBCPP_CXX03_LANG
  774. #ifdef _LIBCPP_CXX03_LANG
  775. # define _LIBCPP_CONSTEXPR
  776. #else
  777. # define _LIBCPP_CONSTEXPR constexpr
  778. #endif
  779. #ifndef __cpp_consteval
  780. # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
  781. #else
  782. # define _LIBCPP_CONSTEVAL consteval
  783. #endif
  784. #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L
  785. #define _LIBCPP_HAS_NO_CONCEPTS
  786. #endif
  787. #ifdef __GNUC__
  788. # define _LIBCPP_NOALIAS __attribute__((__malloc__))
  789. #else
  790. # define _LIBCPP_NOALIAS
  791. #endif
  792. #if __has_attribute(using_if_exists)
  793. # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
  794. #else
  795. # define _LIBCPP_USING_IF_EXISTS
  796. #endif
  797. #ifdef _LIBCPP_CXX03_LANG
  798. # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
  799. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
  800. __lx __v_; \
  801. _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
  802. _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
  803. _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \
  804. };
  805. #else // _LIBCPP_CXX03_LANG
  806. # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
  807. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
  808. #endif // _LIBCPP_CXX03_LANG
  809. // _LIBCPP_DEBUG potential values:
  810. // - undefined: No assertions. This is the default.
  811. // - 0: Basic assertions
  812. // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization.
  813. # if !defined(_LIBCPP_DEBUG)
  814. # define _LIBCPP_DEBUG_LEVEL 0
  815. # elif _LIBCPP_DEBUG == 0
  816. # define _LIBCPP_DEBUG_LEVEL 1
  817. # elif _LIBCPP_DEBUG == 1
  818. # define _LIBCPP_DEBUG_LEVEL 2
  819. # else
  820. # error Supported values for _LIBCPP_DEBUG are 0 and 1
  821. # endif
  822. # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG)
  823. # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
  824. # endif
  825. # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
  826. # if defined(_LIBCPP_CXX03_LANG)
  827. # error Support for unspecified stability is only for C++11 and higher
  828. # endif
  829. # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
  830. do { \
  831. if (!__builtin_is_constant_evaluated()) \
  832. _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \
  833. } while (false)
  834. # else
  835. # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \
  836. do { \
  837. } while (false)
  838. # endif
  839. // Libc++ allows disabling extern template instantiation declarations by
  840. // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
  841. //
  842. // Furthermore, when the Debug mode is enabled, we disable extern declarations
  843. // when building user code because we don't want to use the functions compiled
  844. // in the library, which might not have had the debug mode enabled when built.
  845. // However, some extern declarations need to be used, because code correctness
  846. // depends on it (several instances in <locale>). Those special declarations
  847. // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
  848. // even when the debug mode is enabled.
  849. #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
  850. # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
  851. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
  852. #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
  853. # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
  854. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
  855. #else
  856. # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
  857. # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
  858. #endif
  859. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
  860. defined(__sun__) || defined(__NetBSD__)
  861. #define _LIBCPP_LOCALE__L_EXTENSIONS 1
  862. #endif
  863. #ifdef __FreeBSD__
  864. #define _DECLARE_C99_LDBL_MATH 1
  865. #endif
  866. // If we are getting operator new from the MSVC CRT, then allocation overloads
  867. // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
  868. #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
  869. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  870. #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
  871. // We're deferring to Microsoft's STL to provide aligned new et al. We don't
  872. // have it unless the language feature test macro is defined.
  873. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  874. #elif defined(__MVS__)
  875. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  876. #endif
  877. #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
  878. (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
  879. # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
  880. #endif
  881. #if defined(__APPLE__) || defined(__FreeBSD__)
  882. #define _LIBCPP_HAS_DEFAULTRUNELOCALE
  883. #endif
  884. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
  885. #define _LIBCPP_WCTYPE_IS_MASK
  886. #endif
  887. #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
  888. #define _LIBCPP_HAS_NO_CHAR8_T
  889. #endif
  890. // Deprecation macros.
  891. //
  892. // Deprecations warnings are always enabled, except when users explicitly opt-out
  893. // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
  894. #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
  895. # if __has_attribute(deprecated)
  896. # define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
  897. # elif _LIBCPP_STD_VER > 11
  898. # define _LIBCPP_DEPRECATED [[deprecated]]
  899. # else
  900. # define _LIBCPP_DEPRECATED
  901. # endif
  902. #else
  903. # define _LIBCPP_DEPRECATED
  904. #endif
  905. #if !defined(_LIBCPP_CXX03_LANG)
  906. # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
  907. #else
  908. # define _LIBCPP_DEPRECATED_IN_CXX11
  909. #endif
  910. #if _LIBCPP_STD_VER > 11
  911. # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
  912. #else
  913. # define _LIBCPP_DEPRECATED_IN_CXX14
  914. #endif
  915. #if _LIBCPP_STD_VER > 14
  916. # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
  917. #else
  918. # define _LIBCPP_DEPRECATED_IN_CXX17
  919. #endif
  920. #if _LIBCPP_STD_VER > 17
  921. # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
  922. #else
  923. # define _LIBCPP_DEPRECATED_IN_CXX20
  924. #endif
  925. #if !defined(_LIBCPP_HAS_NO_CHAR8_T)
  926. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
  927. #else
  928. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
  929. #endif
  930. #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
  931. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
  932. _Pragma("GCC diagnostic push") \
  933. _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
  934. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  935. # define _LIBCPP_SUPPRESS_DEPRECATED_POP \
  936. _Pragma("GCC diagnostic pop")
  937. #else
  938. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  939. # define _LIBCPP_SUPPRESS_DEPRECATED_POP
  940. #endif
  941. #if _LIBCPP_STD_VER <= 11
  942. # define _LIBCPP_EXPLICIT_AFTER_CXX11
  943. #else
  944. # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
  945. #endif
  946. #if _LIBCPP_STD_VER > 11
  947. # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  948. #else
  949. # define _LIBCPP_CONSTEXPR_AFTER_CXX11
  950. #endif
  951. #if _LIBCPP_STD_VER > 14
  952. # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  953. #else
  954. # define _LIBCPP_CONSTEXPR_AFTER_CXX14
  955. #endif
  956. #if _LIBCPP_STD_VER > 17
  957. # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
  958. #else
  959. # define _LIBCPP_CONSTEXPR_AFTER_CXX17
  960. #endif
  961. #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
  962. # define _LIBCPP_NODISCARD [[nodiscard]]
  963. #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
  964. # define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
  965. #else
  966. // We can't use GCC's [[gnu::warn_unused_result]] and
  967. // __attribute__((warn_unused_result)), because GCC does not silence them via
  968. // (void) cast.
  969. # define _LIBCPP_NODISCARD
  970. #endif
  971. // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
  972. // specified as such as an extension.
  973. #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
  974. # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
  975. #else
  976. # define _LIBCPP_NODISCARD_EXT
  977. #endif
  978. #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \
  979. (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
  980. # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
  981. #else
  982. # define _LIBCPP_NODISCARD_AFTER_CXX17
  983. #endif
  984. #if __has_attribute(no_destroy)
  985. # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
  986. #else
  987. # define _LIBCPP_NO_DESTROY
  988. #endif
  989. #ifndef _LIBCPP_HAS_NO_ASAN
  990. extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
  991. const void *, const void *, const void *, const void *);
  992. #endif
  993. // Try to find out if RTTI is disabled.
  994. #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
  995. # define _LIBCPP_NO_RTTI
  996. #elif defined(__GNUC__) && !defined(__GXX_RTTI)
  997. # define _LIBCPP_NO_RTTI
  998. #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
  999. # define _LIBCPP_NO_RTTI
  1000. #endif
  1001. #ifndef _LIBCPP_WEAK
  1002. #define _LIBCPP_WEAK __attribute__((__weak__))
  1003. #endif
  1004. // Thread API
  1005. #if !defined(_LIBCPP_HAS_NO_THREADS) && \
  1006. !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
  1007. !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
  1008. !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  1009. # if defined(__FreeBSD__) || \
  1010. defined(__wasi__) || \
  1011. defined(__NetBSD__) || \
  1012. defined(__OpenBSD__) || \
  1013. defined(__NuttX__) || \
  1014. defined(__linux__) || \
  1015. defined(__GNU__) || \
  1016. defined(__APPLE__) || \
  1017. defined(__sun__) || \
  1018. defined(__MVS__) || \
  1019. defined(_AIX) || \
  1020. defined(__CYGWIN__)
  1021. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  1022. # elif defined(__Fuchsia__)
  1023. // TODO(44575): Switch to C11 thread API when possible.
  1024. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  1025. # elif defined(_LIBCPP_WIN32API)
  1026. # define _LIBCPP_HAS_THREAD_API_WIN32
  1027. # else
  1028. # error "No thread API"
  1029. # endif // _LIBCPP_HAS_THREAD_API
  1030. #endif // _LIBCPP_HAS_NO_THREADS
  1031. #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  1032. #if defined(__ANDROID__) && __ANDROID_API__ >= 30
  1033. #define _LIBCPP_HAS_COND_CLOCKWAIT
  1034. #elif defined(_LIBCPP_GLIBC_PREREQ)
  1035. #if _LIBCPP_GLIBC_PREREQ(2, 30)
  1036. #define _LIBCPP_HAS_COND_CLOCKWAIT
  1037. #endif
  1038. #endif
  1039. #endif
  1040. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  1041. #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
  1042. _LIBCPP_HAS_NO_THREADS is not defined.
  1043. #endif
  1044. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  1045. #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
  1046. _LIBCPP_HAS_NO_THREADS is defined.
  1047. #endif
  1048. #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
  1049. #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  1050. _LIBCPP_HAS_NO_THREADS is defined.
  1051. #endif
  1052. #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
  1053. #define __STDCPP_THREADS__ 1
  1054. #endif
  1055. // The glibc and Bionic implementation of pthreads implements
  1056. // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
  1057. // mutexes have no destroy mechanism.
  1058. //
  1059. // This optimization can't be performed on Apple platforms, where
  1060. // pthread_mutex_destroy can allow the kernel to release resources.
  1061. // See https://llvm.org/D64298 for details.
  1062. //
  1063. // TODO(EricWF): Enable this optimization on Bionic after speaking to their
  1064. // respective stakeholders.
  1065. #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
  1066. || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
  1067. || defined(_LIBCPP_HAS_THREAD_API_WIN32)
  1068. # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
  1069. #endif
  1070. // Destroying a condvar is a nop on Windows.
  1071. //
  1072. // This optimization can't be performed on Apple platforms, where
  1073. // pthread_cond_destroy can allow the kernel to release resources.
  1074. // See https://llvm.org/D64298 for details.
  1075. //
  1076. // TODO(EricWF): This is potentially true for some pthread implementations
  1077. // as well.
  1078. #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
  1079. defined(_LIBCPP_HAS_THREAD_API_WIN32)
  1080. # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
  1081. #endif
  1082. // Some systems do not provide gets() in their C library, for security reasons.
  1083. #if defined(_LIBCPP_MSVCRT) || \
  1084. (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
  1085. defined(__OpenBSD__)
  1086. # define _LIBCPP_C_HAS_NO_GETS
  1087. #endif
  1088. #if defined(__BIONIC__) || defined(__NuttX__) || \
  1089. defined(__Fuchsia__) || defined(__wasi__) || \
  1090. defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
  1091. #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
  1092. #endif
  1093. #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
  1094. # define _LIBCPP_HAS_C_ATOMIC_IMP
  1095. #elif defined(_LIBCPP_COMPILER_GCC)
  1096. # define _LIBCPP_HAS_GCC_ATOMIC_IMP
  1097. #endif
  1098. #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
  1099. !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
  1100. !defined(_LIBCPP_COMPILER_MSVC) && \
  1101. !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
  1102. # define _LIBCPP_HAS_NO_ATOMIC_HEADER
  1103. #else
  1104. # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
  1105. # define _LIBCPP_ATOMIC_FLAG_TYPE bool
  1106. # endif
  1107. # ifdef _LIBCPP_FREESTANDING
  1108. # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
  1109. # endif
  1110. #endif
  1111. #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  1112. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  1113. #endif
  1114. #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
  1115. # if defined(__clang__) && __has_attribute(acquire_capability)
  1116. // Work around the attribute handling in clang. When both __declspec and
  1117. // __attribute__ are present, the processing goes awry preventing the definition
  1118. // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
  1119. // combining the two does work.
  1120. # if !defined(_MSC_VER)
  1121. # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  1122. # endif
  1123. # endif
  1124. #endif
  1125. #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  1126. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
  1127. #else
  1128. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
  1129. #endif
  1130. #if _LIBCPP_STD_VER > 17 && (!defined(_MSC_VER) || _MSC_VER >= 1929)
  1131. # define _LIBCPP_CONSTINIT constinit
  1132. #elif __has_attribute(require_constant_initialization)
  1133. # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
  1134. #else
  1135. # define _LIBCPP_CONSTINIT
  1136. #endif
  1137. #if !__has_builtin(__builtin_is_constant_evaluated) || (defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER < 900) || __CUDACC_VER_MAJOR__ == 10
  1138. #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
  1139. #endif
  1140. #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
  1141. # define _LIBCPP_DIAGNOSE_WARNING(...) \
  1142. __attribute__((diagnose_if(__VA_ARGS__, "warning")))
  1143. # define _LIBCPP_DIAGNOSE_ERROR(...) \
  1144. __attribute__((diagnose_if(__VA_ARGS__, "error")))
  1145. #else
  1146. # define _LIBCPP_DIAGNOSE_WARNING(...)
  1147. # define _LIBCPP_DIAGNOSE_ERROR(...)
  1148. #endif
  1149. // Use a function like macro to imply that it must be followed by a semicolon
  1150. #if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough)
  1151. # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
  1152. #elif __has_cpp_attribute(clang::fallthrough)
  1153. # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]]
  1154. #elif __has_attribute(__fallthrough__)
  1155. # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
  1156. #else
  1157. # define _LIBCPP_FALLTHROUGH() ((void)0)
  1158. #endif
  1159. #if defined(_LIBCPP_COMPILER_CLANG_BASED)
  1160. # define _LIBCPP_REINITIALIZES_OBJECT [[clang::reinitializes]]
  1161. #else
  1162. # define _LIBCPP_REINITIALIZES_OBJECT
  1163. #endif
  1164. #if __has_attribute(__nodebug__) && !defined(__CUDACC__)
  1165. #define _LIBCPP_NODEBUG __attribute__((__nodebug__))
  1166. #else
  1167. #define _LIBCPP_NODEBUG
  1168. #endif
  1169. #if __has_attribute(__standalone_debug__)
  1170. #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
  1171. #else
  1172. #define _LIBCPP_STANDALONE_DEBUG
  1173. #endif
  1174. #if __has_attribute(__preferred_name__)
  1175. #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
  1176. #else
  1177. #define _LIBCPP_PREFERRED_NAME(x)
  1178. #endif
  1179. // We often repeat things just for handling wide characters in the library.
  1180. // When wide characters are disabled, it can be useful to have a quick way of
  1181. // disabling it without having to resort to #if-#endif, which has a larger
  1182. // impact on readability.
  1183. #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
  1184. # define _LIBCPP_IF_WIDE_CHARACTERS(...)
  1185. #else
  1186. # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
  1187. #endif
  1188. #if defined(_LIBCPP_ABI_MICROSOFT) && \
  1189. (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
  1190. !defined(__CUDACC__)
  1191. # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
  1192. #else
  1193. # define _LIBCPP_DECLSPEC_EMPTY_BASES
  1194. #endif
  1195. #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
  1196. #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
  1197. #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
  1198. #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
  1199. #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
  1200. #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
  1201. #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
  1202. #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
  1203. #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
  1204. #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
  1205. #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
  1206. #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
  1207. #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
  1208. #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
  1209. #define _LIBCPP_HAS_NO_CXX20_COROUTINES
  1210. #endif
  1211. // Yandex-specific: We build our own libc++, so it has everything available
  1212. #define _LIBCPP_DISABLE_AVAILABILITY
  1213. // End of Yandex-specific
  1214. #if defined(_LIBCPP_COMPILER_IBM) || defined(__CUDACC__)
  1215. #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
  1216. #endif
  1217. #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
  1218. # define _LIBCPP_PUSH_MACROS
  1219. # define _LIBCPP_POP_MACROS
  1220. #else
  1221. // Don't warn about macro conflicts when we can restore them at the
  1222. // end of the header.
  1223. # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
  1224. # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
  1225. # endif
  1226. # if defined(_LIBCPP_COMPILER_MSVC)
  1227. # define _LIBCPP_PUSH_MACROS \
  1228. __pragma(push_macro("min")) \
  1229. __pragma(push_macro("max"))
  1230. # define _LIBCPP_POP_MACROS \
  1231. __pragma(pop_macro("min")) \
  1232. __pragma(pop_macro("max"))
  1233. # else
  1234. # define _LIBCPP_PUSH_MACROS \
  1235. _Pragma("push_macro(\"min\")") \
  1236. _Pragma("push_macro(\"max\")")
  1237. # define _LIBCPP_POP_MACROS \
  1238. _Pragma("pop_macro(\"min\")") \
  1239. _Pragma("pop_macro(\"max\")")
  1240. # endif
  1241. #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
  1242. #ifndef _LIBCPP_NO_AUTO_LINK
  1243. # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  1244. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  1245. # pragma comment(lib, "c++.lib")
  1246. # else
  1247. # pragma comment(lib, "libc++.lib")
  1248. # endif
  1249. # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  1250. #endif // _LIBCPP_NO_AUTO_LINK
  1251. // Configures the fopen close-on-exec mode character, if any. This string will
  1252. // be appended to any mode string used by fstream for fopen/fdopen.
  1253. //
  1254. // Not all platforms support this, but it helps avoid fd-leaks on platforms that
  1255. // do.
  1256. #if defined(__BIONIC__)
  1257. # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
  1258. #else
  1259. # define _LIBCPP_FOPEN_CLOEXEC_MODE
  1260. #endif
  1261. #ifdef _LIBCPP_COMPILER_MSVC
  1262. #define _LIBCPP_BUILTIN_CONSTANT_P(x) false
  1263. #else
  1264. #define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x)
  1265. #endif
  1266. // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
  1267. // of functions used in cstdio may not be available for low API levels when
  1268. // using 64-bit file offsets on LP32.
  1269. #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
  1270. #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
  1271. #endif
  1272. #if __has_attribute(init_priority)
  1273. // TODO: Remove this once we drop support for building libc++ with old Clangs
  1274. # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
  1275. (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
  1276. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
  1277. # else
  1278. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
  1279. # endif
  1280. #else
  1281. # define _LIBCPP_INIT_PRIORITY_MAX
  1282. #endif
  1283. #if defined(__GNUC__) || defined(__clang__)
  1284. // The attribute uses 1-based indices for ordinary and static member functions.
  1285. // The attribute uses 2-based indices for non-static member functions.
  1286. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
  1287. __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
  1288. #else
  1289. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
  1290. #endif
  1291. #if __has_cpp_attribute(msvc::no_unique_address)
  1292. // MSVC implements [[no_unique_address]] as a silent no-op currently.
  1293. // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
  1294. // However, MSVC implements [[msvc::no_unique_address]] which does what
  1295. // [[no_unique_address]] is supposed to do, in general.
  1296. // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
  1297. // [[msvc::no_unique_address]] though. If/when it does implement
  1298. // [[msvc::no_unique_address]], this should be preferred though.
  1299. # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
  1300. #elif __has_cpp_attribute(no_unique_address)
  1301. # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
  1302. #else
  1303. # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
  1304. // Note that this can be replaced by #error as soon as clang-cl
  1305. // implements msvc::no_unique_address, since there should be no C++20
  1306. // compiler that doesn't support one of the two attributes at that point.
  1307. // We geenrally don't want to use this macro outside of C++20-only code,
  1308. // because using it conditionally in one language version only would make
  1309. // the ABI inconsistent.
  1310. #endif
  1311. #if __has_cpp_attribute(msvc::no_unique_address)
  1312. // MSVC implements [[no_unique_address]] as a silent no-op currently.
  1313. // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
  1314. // However, MSVC implements [[msvc::no_unique_address]] which does what
  1315. // [[no_unique_address]] is supposed to do, in general.
  1316. // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
  1317. // [[msvc::no_unique_address]] though. If/when it does implement
  1318. // [[msvc::no_unique_address]], this should be preferred though.
  1319. # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
  1320. #elif __has_cpp_attribute(no_unique_address)
  1321. # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
  1322. #else
  1323. # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
  1324. // Note that this can be replaced by #error as soon as clang-cl
  1325. // implements msvc::no_unique_address, since there should be no C++20
  1326. // compiler that doesn't support one of the two attributes at that point.
  1327. // We generally don't want to use this macro outside of C++20-only code,
  1328. // because using it conditionally in one language version only would make
  1329. // the ABI inconsistent.
  1330. #endif
  1331. #ifdef _LIBCPP_COMPILER_CLANG_BASED
  1332. # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
  1333. # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
  1334. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
  1335. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
  1336. #elif defined(_LIBCPP_COMPILER_GCC)
  1337. # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
  1338. # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
  1339. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
  1340. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
  1341. #else
  1342. # define _LIBCPP_DIAGNOSTIC_PUSH
  1343. # define _LIBCPP_DIAGNOSTIC_POP
  1344. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
  1345. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
  1346. #endif
  1347. #if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
  1348. # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
  1349. # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
  1350. #else
  1351. # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
  1352. # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
  1353. #endif
  1354. #endif // __cplusplus
  1355. #endif // _LIBCPP_CONFIG