__config 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  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. #endif
  42. #ifdef __cplusplus
  43. # define _LIBCPP_VERSION 15000
  44. # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
  45. # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
  46. // Valid C++ identifier that revs with every libc++ version. This can be used to
  47. // generate identifiers that must be unique for every released libc++ version.
  48. # define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION)
  49. # if __STDC_HOSTED__ == 0
  50. # define _LIBCPP_FREESTANDING
  51. # endif
  52. # ifndef _LIBCPP_STD_VER
  53. # if __cplusplus <= 201103L
  54. # define _LIBCPP_STD_VER 11
  55. # elif __cplusplus <= 201402L
  56. # define _LIBCPP_STD_VER 14
  57. # elif __cplusplus <= 201703L
  58. # define _LIBCPP_STD_VER 17
  59. # elif __cplusplus <= 202002L
  60. # define _LIBCPP_STD_VER 20
  61. # else
  62. # define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
  63. # endif
  64. # endif // _LIBCPP_STD_VER
  65. # if defined(__ELF__)
  66. # define _LIBCPP_OBJECT_FORMAT_ELF 1
  67. # elif defined(__MACH__)
  68. # define _LIBCPP_OBJECT_FORMAT_MACHO 1
  69. # elif defined(_WIN32) || defined(__CYGWIN__)
  70. # define _LIBCPP_OBJECT_FORMAT_COFF 1
  71. # elif defined(__wasm__)
  72. # define _LIBCPP_OBJECT_FORMAT_WASM 1
  73. # elif defined(_AIX)
  74. # define _LIBCPP_OBJECT_FORMAT_XCOFF 1
  75. # else
  76. // ... add new file formats here ...
  77. # endif
  78. # if _LIBCPP_ABI_VERSION >= 2
  79. // Change short string representation so that string data starts at offset 0,
  80. // improving its alignment in some cases.
  81. # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  82. // Fix deque iterator type in order to support incomplete types.
  83. # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
  84. // Fix undefined behavior in how std::list stores its linked nodes.
  85. # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
  86. // Fix undefined behavior in how __tree stores its end and parent nodes.
  87. # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
  88. // Fix undefined behavior in how __hash_table stores its pointer types.
  89. # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
  90. # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
  91. # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
  92. // Define a key function for `bad_function_call` in the library, to centralize
  93. // its vtable and typeinfo to libc++ rather than having all other libraries
  94. // using that class define their own copies.
  95. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
  96. // Override the default return value of exception::what() for
  97. // bad_function_call::what() with a string that is specific to
  98. // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
  99. // because it changes the vtable layout of bad_function_call.
  100. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
  101. // Enable optimized version of __do_get_(un)signed which avoids redundant copies.
  102. # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
  103. // Give reverse_iterator<T> one data member of type T, not two.
  104. // Also, in C++17 and later, don't derive iterator types from std::iterator.
  105. # define _LIBCPP_ABI_NO_ITERATOR_BASES
  106. // Use the smallest possible integer type to represent the index of the variant.
  107. // Previously libc++ used "unsigned int" exclusively.
  108. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
  109. // Unstable attempt to provide a more optimized std::function
  110. #ifdef __EMSCRIPTEN__
  111. // XXX EMSCRIPTEN https://github.com/emscripten-core/emscripten/issues/11022
  112. //# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
  113. #else
  114. # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
  115. #endif
  116. // All the regex constants must be distinct and nonzero.
  117. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
  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. // Don't export the legacy __basic_string_common class and its methods from the built library.
  133. # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
  134. // Don't export the legacy __vector_base_common class and its methods from the built library.
  135. # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
  136. // According to the Standard, `bitset::operator[] const` returns bool
  137. # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
  138. // Remove the base 10 implementation of std::to_chars from the dylib.
  139. // The implementation moved to the header, but we still export the symbols from
  140. // the dylib for backwards compatibility.
  141. # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
  142. # elif _LIBCPP_ABI_VERSION == 1
  143. # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
  144. // Enable compiling copies of now inline methods into the dylib to support
  145. // applications compiled against older libraries. This is unnecessary with
  146. // COFF dllexport semantics, since dllexport forces a non-inline definition
  147. // of inline functions to be emitted anyway. Our own non-inline copy would
  148. // conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
  149. // the linker will take issue with the symbols in the shared object if the
  150. // weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
  151. // so disable it.
  152. # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
  153. # endif
  154. // Feature macros for disabling pre ABI v1 features. All of these options
  155. // are deprecated.
  156. # if defined(__FreeBSD__)
  157. # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
  158. # endif
  159. # endif
  160. # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
  161. // Enable additional explicit instantiations of iostreams components. This
  162. // reduces the number of weak definitions generated in programs that use
  163. // iostreams by providing a single strong definition in the shared library.
  164. # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
  165. // Define a key function for `bad_function_call` in the library, to centralize
  166. // its vtable and typeinfo to libc++ rather than having all other libraries
  167. // using that class define their own copies.
  168. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
  169. # endif
  170. # define _LIBCPP_TOSTRING2(x) # x
  171. # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
  172. # if __cplusplus < 201103L
  173. # define _LIBCPP_CXX03_LANG
  174. # endif
  175. # ifndef __has_attribute
  176. # define __has_attribute(__x) 0
  177. # endif
  178. # ifndef __has_builtin
  179. # define __has_builtin(__x) 0
  180. # endif
  181. # ifndef __has_extension
  182. # define __has_extension(__x) 0
  183. # endif
  184. # ifndef __has_feature
  185. # define __has_feature(__x) 0
  186. # endif
  187. # ifndef __has_cpp_attribute
  188. # define __has_cpp_attribute(__x) 0
  189. # endif
  190. // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
  191. // the compiler and '1' otherwise.
  192. # ifndef __is_identifier
  193. # define __is_identifier(__x) 1
  194. # endif
  195. # ifndef __has_declspec_attribute
  196. # define __has_declspec_attribute(__x) 0
  197. # endif
  198. # define __has_keyword(__x) !(__is_identifier(__x))
  199. # ifndef __has_include
  200. # define __has_include(...) 0
  201. # endif
  202. # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
  203. # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
  204. # endif
  205. // FIXME: ABI detection should be done via compiler builtin macros. This
  206. // is just a placeholder until Clang implements such macros. For now assume
  207. // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
  208. // and allow the user to explicitly specify the ABI to handle cases where this
  209. // heuristic falls short.
  210. # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
  211. # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
  212. # elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
  213. # define _LIBCPP_ABI_ITANIUM
  214. # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
  215. # define _LIBCPP_ABI_MICROSOFT
  216. # else
  217. # if defined(_WIN32) && defined(_MSC_VER)
  218. # define _LIBCPP_ABI_MICROSOFT
  219. # else
  220. # define _LIBCPP_ABI_ITANIUM
  221. # endif
  222. # endif
  223. # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
  224. # define _LIBCPP_ABI_VCRUNTIME
  225. # endif
  226. // Need to detect which libc we're using if we're on Linux.
  227. # if defined(__linux__)
  228. # include <features.h>
  229. # if defined(__GLIBC_PREREQ)
  230. # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
  231. # else
  232. # define _LIBCPP_GLIBC_PREREQ(a, b) 0
  233. # endif // defined(__GLIBC_PREREQ)
  234. # endif // defined(__linux__)
  235. # if defined(__MVS__)
  236. # include <features.h> // for __NATIVE_ASCII_F
  237. # endif
  238. # ifdef __LITTLE_ENDIAN__
  239. # if __LITTLE_ENDIAN__
  240. # define _LIBCPP_LITTLE_ENDIAN
  241. # endif // __LITTLE_ENDIAN__
  242. # endif // __LITTLE_ENDIAN__
  243. # ifdef __BIG_ENDIAN__
  244. # if __BIG_ENDIAN__
  245. # define _LIBCPP_BIG_ENDIAN
  246. # endif // __BIG_ENDIAN__
  247. # endif // __BIG_ENDIAN__
  248. # ifdef __BYTE_ORDER__
  249. # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  250. # define _LIBCPP_LITTLE_ENDIAN
  251. # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  252. # define _LIBCPP_BIG_ENDIAN
  253. # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  254. # endif // __BYTE_ORDER__
  255. # ifdef __FreeBSD__
  256. # include <sys/endian.h>
  257. # include <osreldate.h>
  258. # if _BYTE_ORDER == _LITTLE_ENDIAN
  259. # define _LIBCPP_LITTLE_ENDIAN
  260. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  261. # define _LIBCPP_BIG_ENDIAN
  262. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  263. # endif // __FreeBSD__
  264. # if defined(__NetBSD__) || defined(__OpenBSD__)
  265. # include <sys/endian.h>
  266. # if _BYTE_ORDER == _LITTLE_ENDIAN
  267. # define _LIBCPP_LITTLE_ENDIAN
  268. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  269. # define _LIBCPP_BIG_ENDIAN
  270. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  271. # endif // defined(__NetBSD__) || defined(__OpenBSD__)
  272. # if defined(_WIN32)
  273. # define _LIBCPP_WIN32API
  274. # define _LIBCPP_LITTLE_ENDIAN
  275. # define _LIBCPP_SHORT_WCHAR 1
  276. // Both MinGW and native MSVC provide a "MSVC"-like environment
  277. # define _LIBCPP_MSVCRT_LIKE
  278. // If mingw not explicitly detected, assume using MS C runtime only if
  279. // a MS compatibility version is specified.
  280. # if defined(_MSC_VER) && !defined(__MINGW32__)
  281. # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
  282. # endif
  283. # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
  284. # define _LIBCPP_HAS_BITSCAN64
  285. # endif
  286. # define _LIBCPP_HAS_OPEN_WITH_WCHAR
  287. # endif // defined(_WIN32)
  288. # ifdef __sun__
  289. # include <sys/isa_defs.h>
  290. # ifdef _LITTLE_ENDIAN
  291. # define _LIBCPP_LITTLE_ENDIAN
  292. # else
  293. # define _LIBCPP_BIG_ENDIAN
  294. # endif
  295. # endif // __sun__
  296. # if defined(_AIX) && !defined(__64BIT__)
  297. // The size of wchar is 2 byte on 32-bit mode on AIX.
  298. # define _LIBCPP_SHORT_WCHAR 1
  299. # endif
  300. // Libc++ supports various implementations of std::random_device.
  301. //
  302. // _LIBCPP_USING_DEV_RANDOM
  303. // Read entropy from the given file, by default `/dev/urandom`.
  304. // If a token is provided, it is assumed to be the path to a file
  305. // to read entropy from. This is the default behavior if nothing
  306. // else is specified. This implementation requires storing state
  307. // inside `std::random_device`.
  308. //
  309. // _LIBCPP_USING_ARC4_RANDOM
  310. // Use arc4random(). This allows obtaining random data even when
  311. // using sandboxing mechanisms. On some platforms like Apple, this
  312. // is the recommended source of entropy for user-space programs.
  313. // When this option is used, the token passed to `std::random_device`'s
  314. // constructor *must* be "/dev/urandom" -- anything else is an error.
  315. //
  316. // _LIBCPP_USING_GETENTROPY
  317. // Use getentropy().
  318. // When this option is used, the token passed to `std::random_device`'s
  319. // constructor *must* be "/dev/urandom" -- anything else is an error.
  320. //
  321. // _LIBCPP_USING_FUCHSIA_CPRNG
  322. // Use Fuchsia's zx_cprng_draw() system call, which is specified to
  323. // deliver high-quality entropy and cannot fail.
  324. // When this option is used, the token passed to `std::random_device`'s
  325. // constructor *must* be "/dev/urandom" -- anything else is an error.
  326. //
  327. // _LIBCPP_USING_NACL_RANDOM
  328. // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
  329. // including accesses to the special files under `/dev`. This implementation
  330. // uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
  331. // When this option is used, the token passed to `std::random_device`'s
  332. // constructor *must* be "/dev/urandom" -- anything else is an error.
  333. //
  334. // _LIBCPP_USING_WIN32_RANDOM
  335. // Use rand_s(), for use on Windows.
  336. // When this option is used, the token passed to `std::random_device`'s
  337. // constructor *must* be "/dev/urandom" -- anything else is an error.
  338. # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
  339. defined(__DragonFly__) || defined(__sun__)
  340. # define _LIBCPP_USING_ARC4_RANDOM
  341. # elif defined(__wasi__) || defined(__EMSCRIPTEN__)
  342. # define _LIBCPP_USING_GETENTROPY
  343. # elif defined(__Fuchsia__)
  344. # define _LIBCPP_USING_FUCHSIA_CPRNG
  345. # elif defined(__native_client__)
  346. # define _LIBCPP_USING_NACL_RANDOM
  347. # elif defined(_LIBCPP_WIN32API)
  348. # define _LIBCPP_USING_WIN32_RANDOM
  349. # else
  350. # define _LIBCPP_USING_DEV_RANDOM
  351. # endif
  352. # if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
  353. # include <endian.h>
  354. # if __BYTE_ORDER == __LITTLE_ENDIAN
  355. # define _LIBCPP_LITTLE_ENDIAN
  356. # elif __BYTE_ORDER == __BIG_ENDIAN
  357. # define _LIBCPP_BIG_ENDIAN
  358. # else // __BYTE_ORDER == __BIG_ENDIAN
  359. # error unable to determine endian
  360. # endif
  361. # endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
  362. # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
  363. # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
  364. # else
  365. # define _LIBCPP_NO_CFI
  366. # endif
  367. # ifndef _LIBCPP_CXX03_LANG
  368. # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
  369. # define _ALIGNAS_TYPE(x) alignas(x)
  370. # define _ALIGNAS(x) alignas(x)
  371. # define _LIBCPP_NORETURN [[noreturn]]
  372. # define _NOEXCEPT noexcept
  373. # define _NOEXCEPT_(x) noexcept(x)
  374. # else
  375. # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
  376. # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
  377. # define _ALIGNAS(x) __attribute__((__aligned__(x)))
  378. # define _LIBCPP_NORETURN __attribute__((noreturn))
  379. # define _LIBCPP_HAS_NO_NOEXCEPT
  380. # define nullptr __nullptr
  381. # define _NOEXCEPT throw()
  382. # define _NOEXCEPT_(x)
  383. typedef __char16_t char16_t;
  384. typedef __char32_t char32_t;
  385. # endif
  386. # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
  387. # define _LIBCPP_NO_EXCEPTIONS
  388. # endif
  389. # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
  390. # if defined(_LIBCPP_COMPILER_CLANG_BASED)
  391. # if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
  392. # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  393. # endif
  394. // Objective-C++ features (opt-in)
  395. # if __has_feature(objc_arc)
  396. # define _LIBCPP_HAS_OBJC_ARC
  397. # endif
  398. # if __has_feature(objc_arc_weak)
  399. # define _LIBCPP_HAS_OBJC_ARC_WEAK
  400. # endif
  401. # if __has_extension(blocks)
  402. # define _LIBCPP_HAS_EXTENSION_BLOCKS
  403. # endif
  404. # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
  405. # define _LIBCPP_HAS_BLOCKS_RUNTIME
  406. # endif
  407. # if !__has_feature(address_sanitizer)
  408. # define _LIBCPP_HAS_NO_ASAN
  409. # endif
  410. // Allow for build-time disabling of unsigned integer sanitization
  411. # if __has_attribute(no_sanitize)
  412. # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
  413. # endif
  414. # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
  415. # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  416. # elif defined(_LIBCPP_COMPILER_GCC)
  417. # if !defined(__SANITIZE_ADDRESS__)
  418. # define _LIBCPP_HAS_NO_ASAN
  419. # endif
  420. # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
  421. # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
  422. # elif defined(_LIBCPP_COMPILER_MSVC)
  423. # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
  424. # if _MSC_VER < 1900
  425. # error "MSVC versions prior to Visual Studio 2015 are not supported"
  426. # endif
  427. # define _LIBCPP_NORETURN __declspec(noreturn)
  428. # define _LIBCPP_WEAK
  429. # define _LIBCPP_HAS_NO_ASAN
  430. # define _LIBCPP_ALWAYS_INLINE __forceinline
  431. # define _LIBCPP_HAS_NO_VECTOR_EXTENSION
  432. # define _LIBCPP_DISABLE_EXTENSION_WARNING
  433. # endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
  434. # if defined(_LIBCPP_OBJECT_FORMAT_COFF)
  435. # ifdef _DLL
  436. # define _LIBCPP_CRT_FUNC __declspec(dllimport)
  437. # else
  438. # define _LIBCPP_CRT_FUNC
  439. # endif
  440. # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
  441. # define _LIBCPP_DLL_VIS
  442. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  443. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  444. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  445. # define _LIBCPP_EXPORTED_FROM_ABI
  446. # elif defined(_LIBCPP_BUILDING_LIBRARY)
  447. # define _LIBCPP_DLL_VIS __declspec(dllexport)
  448. # if defined(__MINGW32__)
  449. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  450. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  451. # else
  452. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
  453. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
  454. # endif
  455. # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
  456. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
  457. # else
  458. # define _LIBCPP_DLL_VIS __declspec(dllimport)
  459. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
  460. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  461. # define _LIBCPP_OVERRIDABLE_FUNC_VIS
  462. # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
  463. # endif
  464. # define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
  465. # define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
  466. # define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
  467. # define _LIBCPP_HIDDEN
  468. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  469. # define _LIBCPP_TEMPLATE_VIS
  470. # define _LIBCPP_TEMPLATE_DATA_VIS
  471. # define _LIBCPP_ENUM_VIS
  472. # else
  473. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  474. # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
  475. # else
  476. # define _LIBCPP_VISIBILITY(vis)
  477. # endif
  478. # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
  479. # define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default")
  480. # define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default")
  481. # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
  482. # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
  483. # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
  484. # define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default")
  485. # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
  486. # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
  487. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  488. // The inline should be removed once PR32114 is resolved
  489. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
  490. # else
  491. # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
  492. # endif
  493. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  494. # if __has_attribute(__type_visibility__)
  495. # define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default")))
  496. # else
  497. # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
  498. # endif
  499. # else
  500. # define _LIBCPP_TEMPLATE_VIS
  501. # endif
  502. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
  503. # define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
  504. # else
  505. # define _LIBCPP_ENUM_VIS
  506. # endif
  507. # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
  508. # if __has_attribute(exclude_from_explicit_instantiation)
  509. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
  510. # else
  511. // Try to approximate the effect of exclude_from_explicit_instantiation
  512. // (which is that entities are not assumed to be provided by explicit
  513. // template instantiations in the dylib) by always inlining those entities.
  514. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
  515. # endif
  516. // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
  517. // on two levels:
  518. // 1. The symbol is given hidden visibility, which ensures that users won't start exporting
  519. // symbols from their dynamic library by means of using the libc++ headers. This ensures
  520. // that those symbols stay private to the dynamic library in which it is defined.
  521. //
  522. // 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures
  523. // that no ODR violation can arise from mixing two TUs compiled with different versions
  524. // of libc++ where we would have changed the definition of a symbol. If the symbols shared
  525. // the same name, the ODR would require that their definitions be token-by-token equivalent,
  526. // which basically prevents us from being able to make any change to any function in our
  527. // headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at
  528. // each release, which lets us change the definition of these symbols at our leisure.
  529. // Note that historically, this has been achieved in various ways, including force-inlining
  530. // all functions or giving internal linkage to all functions. Both these (previous) solutions
  531. // suffer from drawbacks that lead notably to code bloat.
  532. //
  533. // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
  534. // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
  535. //
  536. // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
  537. // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
  538. // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
  539. # if !defined(_LIBCPP_NO_ABI_TAG) && !defined(__CUDACC__)
  540. # define _LIBCPP_HIDE_FROM_ABI \
  541. _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
  542. __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
  543. # else
  544. # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
  545. # endif
  546. # ifdef _LIBCPP_BUILDING_LIBRARY
  547. # if _LIBCPP_ABI_VERSION > 1
  548. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  549. # else
  550. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1
  551. # endif
  552. # else
  553. # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
  554. # endif
  555. // Just so we can migrate to the new macros gradually.
  556. # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
  557. // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
  558. // clang-format off
  559. # define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE {
  560. # define _LIBCPP_END_NAMESPACE_STD }}
  561. # define _VSTD std
  562. _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
  563. # if _LIBCPP_STD_VER > 14
  564. # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  565. _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem {
  566. # else
  567. # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \
  568. _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem {
  569. # endif
  570. # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
  571. // clang-format on
  572. # define _VSTD_FS std::__fs::filesystem
  573. # if __has_attribute(__enable_if__)
  574. # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
  575. # endif
  576. # ifndef __SIZEOF_INT128__
  577. # define _LIBCPP_HAS_NO_INT128
  578. # endif
  579. # ifdef _LIBCPP_CXX03_LANG
  580. # define static_assert(...) _Static_assert(__VA_ARGS__)
  581. # define decltype(...) __decltype(__VA_ARGS__)
  582. # endif // _LIBCPP_CXX03_LANG
  583. # ifdef _LIBCPP_CXX03_LANG
  584. # define _LIBCPP_CONSTEXPR
  585. # else
  586. # define _LIBCPP_CONSTEXPR constexpr
  587. # endif
  588. # ifndef __cpp_consteval
  589. # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
  590. # else
  591. # define _LIBCPP_CONSTEVAL consteval
  592. # endif
  593. # ifdef __GNUC__
  594. # define _LIBCPP_NOALIAS __attribute__((__malloc__))
  595. # else
  596. # define _LIBCPP_NOALIAS
  597. # endif
  598. # if __has_attribute(using_if_exists)
  599. # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
  600. # else
  601. # define _LIBCPP_USING_IF_EXISTS
  602. # endif
  603. # ifdef _LIBCPP_CXX03_LANG
  604. # define _LIBCPP_DECLARE_STRONG_ENUM(x) \
  605. struct _LIBCPP_TYPE_VIS x { \
  606. enum __lx
  607. // clang-format off
  608. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
  609. __lx __v_; \
  610. _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \
  611. _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
  612. _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \
  613. };
  614. // clang-format on
  615. # else // _LIBCPP_CXX03_LANG
  616. # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
  617. # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
  618. # endif // _LIBCPP_CXX03_LANG
  619. # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
  620. defined(__NetBSD__)
  621. # define _LIBCPP_LOCALE__L_EXTENSIONS 1
  622. # endif
  623. # ifdef __FreeBSD__
  624. # define _DECLARE_C99_LDBL_MATH 1
  625. # endif
  626. // If we are getting operator new from the MSVC CRT, then allocation overloads
  627. // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
  628. # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
  629. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  630. # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
  631. // We're deferring to Microsoft's STL to provide aligned new et al. We don't
  632. // have it unless the language feature test macro is defined.
  633. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  634. # elif defined(__MVS__)
  635. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
  636. # endif
  637. # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
  638. # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
  639. # endif
  640. # if defined(__APPLE__) || defined(__FreeBSD__)
  641. # define _LIBCPP_HAS_DEFAULTRUNELOCALE
  642. # endif
  643. # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
  644. # define _LIBCPP_WCTYPE_IS_MASK
  645. # endif
  646. # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
  647. # define _LIBCPP_HAS_NO_CHAR8_T
  648. # endif
  649. // Deprecation macros.
  650. //
  651. // Deprecations warnings are always enabled, except when users explicitly opt-out
  652. // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
  653. # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
  654. # if __has_attribute(deprecated)
  655. # define _LIBCPP_DEPRECATED __attribute__((deprecated))
  656. # define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
  657. # elif _LIBCPP_STD_VER > 11
  658. # define _LIBCPP_DEPRECATED [[deprecated]]
  659. # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
  660. # else
  661. # define _LIBCPP_DEPRECATED
  662. # define _LIBCPP_DEPRECATED_(m)
  663. # endif
  664. # else
  665. # define _LIBCPP_DEPRECATED
  666. # define _LIBCPP_DEPRECATED_(m)
  667. # endif
  668. # if !defined(_LIBCPP_CXX03_LANG)
  669. # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
  670. # else
  671. # define _LIBCPP_DEPRECATED_IN_CXX11
  672. # endif
  673. # if _LIBCPP_STD_VER > 11
  674. # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
  675. # else
  676. # define _LIBCPP_DEPRECATED_IN_CXX14
  677. # endif
  678. # if _LIBCPP_STD_VER > 14
  679. # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
  680. # else
  681. # define _LIBCPP_DEPRECATED_IN_CXX17
  682. # endif
  683. # if _LIBCPP_STD_VER > 17
  684. # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
  685. # else
  686. # define _LIBCPP_DEPRECATED_IN_CXX20
  687. # endif
  688. # if !defined(_LIBCPP_HAS_NO_CHAR8_T)
  689. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
  690. # else
  691. # define _LIBCPP_DEPRECATED_WITH_CHAR8_T
  692. # endif
  693. // Macros to enter and leave a state where deprecation warnings are suppressed.
  694. # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
  695. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
  696. _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
  697. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  698. # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
  699. # else
  700. # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
  701. # define _LIBCPP_SUPPRESS_DEPRECATED_POP
  702. # endif
  703. # if _LIBCPP_STD_VER <= 11
  704. # define _LIBCPP_EXPLICIT_AFTER_CXX11
  705. # else
  706. # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
  707. # endif
  708. # if _LIBCPP_STD_VER > 11
  709. # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  710. # else
  711. # define _LIBCPP_CONSTEXPR_AFTER_CXX11
  712. # endif
  713. # if _LIBCPP_STD_VER > 14
  714. # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  715. # else
  716. # define _LIBCPP_CONSTEXPR_AFTER_CXX14
  717. # endif
  718. # if _LIBCPP_STD_VER > 17
  719. # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
  720. # else
  721. # define _LIBCPP_CONSTEXPR_AFTER_CXX17
  722. # endif
  723. # if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
  724. # define _LIBCPP_NODISCARD [[nodiscard]]
  725. # elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
  726. # define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
  727. # else
  728. // We can't use GCC's [[gnu::warn_unused_result]] and
  729. // __attribute__((warn_unused_result)), because GCC does not silence them via
  730. // (void) cast.
  731. # define _LIBCPP_NODISCARD
  732. # endif
  733. // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
  734. // specified as such as an extension.
  735. # if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
  736. # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
  737. # else
  738. # define _LIBCPP_NODISCARD_EXT
  739. # endif
  740. # if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
  741. # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
  742. # else
  743. # define _LIBCPP_NODISCARD_AFTER_CXX17
  744. # endif
  745. # if __has_attribute(no_destroy)
  746. # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
  747. # else
  748. # define _LIBCPP_NO_DESTROY
  749. # endif
  750. # ifndef _LIBCPP_HAS_NO_ASAN
  751. extern "C" _LIBCPP_FUNC_VIS void
  752. __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
  753. # endif
  754. // Try to find out if RTTI is disabled.
  755. # if !defined(__cpp_rtti) || __cpp_rtti < 199711L
  756. # define _LIBCPP_NO_RTTI
  757. # endif
  758. # ifndef _LIBCPP_WEAK
  759. # define _LIBCPP_WEAK __attribute__((__weak__))
  760. # endif
  761. // Thread API
  762. // clang-format off
  763. # if !defined(_LIBCPP_HAS_NO_THREADS) && \
  764. !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
  765. !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
  766. !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  767. # if defined(__FreeBSD__) || \
  768. defined(__wasi__) || \
  769. defined(__NetBSD__) || \
  770. defined(__OpenBSD__) || \
  771. defined(__NuttX__) || \
  772. defined(__linux__) || \
  773. defined(__GNU__) || \
  774. defined(__APPLE__) || \
  775. defined(__sun__) || \
  776. defined(__MVS__) || \
  777. defined(_AIX) || \
  778. defined(__EMSCRIPTEN__) || \
  779. defined(__CYGWIN__)
  780. // clang-format on
  781. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  782. # elif defined(__Fuchsia__)
  783. // TODO(44575): Switch to C11 thread API when possible.
  784. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  785. # elif defined(_LIBCPP_WIN32API)
  786. # define _LIBCPP_HAS_THREAD_API_WIN32
  787. # else
  788. # error "No thread API"
  789. # endif // _LIBCPP_HAS_THREAD_API
  790. # endif // _LIBCPP_HAS_NO_THREADS
  791. # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  792. # if defined(__ANDROID__) && __ANDROID_API__ >= 30
  793. # define _LIBCPP_HAS_COND_CLOCKWAIT
  794. # elif defined(_LIBCPP_GLIBC_PREREQ)
  795. # if _LIBCPP_GLIBC_PREREQ(2, 30)
  796. # define _LIBCPP_HAS_COND_CLOCKWAIT
  797. # endif
  798. # endif
  799. # endif
  800. # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  801. # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
  802. _LIBCPP_HAS_NO_THREADS is not defined.
  803. # endif
  804. # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
  805. # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
  806. _LIBCPP_HAS_NO_THREADS is defined.
  807. # endif
  808. # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
  809. # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  810. _LIBCPP_HAS_NO_THREADS is defined.
  811. # endif
  812. # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
  813. # define __STDCPP_THREADS__ 1
  814. # endif
  815. // The glibc and Bionic implementation of pthreads implements
  816. // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
  817. // mutexes have no destroy mechanism.
  818. //
  819. // This optimization can't be performed on Apple platforms, where
  820. // pthread_mutex_destroy can allow the kernel to release resources.
  821. // See https://llvm.org/D64298 for details.
  822. //
  823. // TODO(EricWF): Enable this optimization on Bionic after speaking to their
  824. // respective stakeholders.
  825. // clang-format off
  826. # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \
  827. (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \
  828. defined(_LIBCPP_HAS_THREAD_API_WIN32)
  829. // clang-format on
  830. # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
  831. # endif
  832. // Destroying a condvar is a nop on Windows.
  833. //
  834. // This optimization can't be performed on Apple platforms, where
  835. // pthread_cond_destroy can allow the kernel to release resources.
  836. // See https://llvm.org/D64298 for details.
  837. //
  838. // TODO(EricWF): This is potentially true for some pthread implementations
  839. // as well.
  840. # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)
  841. # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
  842. # endif
  843. // Some systems do not provide gets() in their C library, for security reasons.
  844. # if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__)
  845. # define _LIBCPP_C_HAS_NO_GETS
  846. # endif
  847. # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
  848. defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)
  849. # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
  850. # endif
  851. # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
  852. # define _LIBCPP_HAS_C_ATOMIC_IMP
  853. # elif defined(_LIBCPP_COMPILER_GCC)
  854. # define _LIBCPP_HAS_GCC_ATOMIC_IMP
  855. # endif
  856. # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
  857. !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)
  858. # define _LIBCPP_HAS_NO_ATOMIC_HEADER
  859. # else
  860. # ifndef _LIBCPP_ATOMIC_FLAG_TYPE
  861. # define _LIBCPP_ATOMIC_FLAG_TYPE bool
  862. # endif
  863. # ifdef _LIBCPP_FREESTANDING
  864. # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
  865. # endif
  866. # endif
  867. # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  868. # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  869. # endif
  870. # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
  871. # if defined(__clang__) && __has_attribute(acquire_capability)
  872. // Work around the attribute handling in clang. When both __declspec and
  873. // __attribute__ are present, the processing goes awry preventing the definition
  874. // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
  875. // combining the two does work.
  876. # if !defined(_MSC_VER)
  877. # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  878. # endif
  879. # endif
  880. # endif
  881. # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  882. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
  883. # else
  884. # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
  885. # endif
  886. # if _LIBCPP_STD_VER > 17
  887. # define _LIBCPP_CONSTINIT constinit
  888. # elif __has_attribute(require_constant_initialization)
  889. # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
  890. # else
  891. # define _LIBCPP_CONSTINIT
  892. # endif
  893. # if !__has_builtin(__builtin_is_constant_evaluated) || (defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER < 900) || __CUDACC_VER_MAJOR__ == 10
  894. # define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
  895. # endif
  896. # if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
  897. # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
  898. # define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
  899. # else
  900. # define _LIBCPP_DIAGNOSE_WARNING(...)
  901. # define _LIBCPP_DIAGNOSE_ERROR(...)
  902. # endif
  903. // Use a function like macro to imply that it must be followed by a semicolon
  904. # if __has_cpp_attribute(fallthrough)
  905. # define _LIBCPP_FALLTHROUGH() [[fallthrough]]
  906. # elif __has_attribute(__fallthrough__)
  907. # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
  908. # else
  909. # define _LIBCPP_FALLTHROUGH() ((void)0)
  910. # endif
  911. # if defined(_LIBCPP_COMPILER_CLANG_BASED)
  912. # define _LIBCPP_REINITIALIZES_OBJECT [[clang::reinitializes]]
  913. # else
  914. # define _LIBCPP_REINITIALIZES_OBJECT
  915. # endif
  916. # if __has_attribute(__nodebug__) && !defined(__CUDACC__)
  917. # define _LIBCPP_NODEBUG __attribute__((__nodebug__))
  918. # else
  919. # define _LIBCPP_NODEBUG
  920. # endif
  921. # if __has_attribute(__standalone_debug__)
  922. # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
  923. # else
  924. # define _LIBCPP_STANDALONE_DEBUG
  925. # endif
  926. # if __has_attribute(__preferred_name__)
  927. # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
  928. # else
  929. # define _LIBCPP_PREFERRED_NAME(x)
  930. # endif
  931. // We often repeat things just for handling wide characters in the library.
  932. // When wide characters are disabled, it can be useful to have a quick way of
  933. // disabling it without having to resort to #if-#endif, which has a larger
  934. // impact on readability.
  935. # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
  936. # define _LIBCPP_IF_WIDE_CHARACTERS(...)
  937. # else
  938. # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
  939. # endif
  940. # if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) && \
  941. !defined(__CUDACC__)
  942. # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
  943. # else
  944. # define _LIBCPP_DECLSPEC_EMPTY_BASES
  945. # endif
  946. # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
  947. # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
  948. # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
  949. # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
  950. # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
  951. # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
  952. # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
  953. # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
  954. # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
  955. # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
  956. # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
  957. # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
  958. # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
  959. # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
  960. # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
  961. # if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
  962. # define _LIBCPP_HAS_NO_CXX20_COROUTINES
  963. # endif
  964. // Yandex-specific: We build our own libc++, so it has everything available
  965. # define _LIBCPP_DISABLE_AVAILABILITY
  966. // End of Yandex-specific
  967. # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
  968. # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
  969. # ifndef _LIBCPP_NO_AUTO_LINK
  970. # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  971. # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
  972. # pragma comment(lib, "c++.lib")
  973. # else
  974. # pragma comment(lib, "libc++.lib")
  975. # endif
  976. # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  977. # endif // _LIBCPP_NO_AUTO_LINK
  978. // Configures the fopen close-on-exec mode character, if any. This string will
  979. // be appended to any mode string used by fstream for fopen/fdopen.
  980. //
  981. // Not all platforms support this, but it helps avoid fd-leaks on platforms that
  982. // do.
  983. # if defined(__BIONIC__)
  984. # define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
  985. # else
  986. # define _LIBCPP_FOPEN_CLOEXEC_MODE
  987. # endif
  988. // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set
  989. // of functions used in cstdio may not be available for low API levels when
  990. // using 64-bit file offsets on LP32.
  991. # if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24
  992. # define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
  993. # endif
  994. # if __has_attribute(init_priority)
  995. // TODO: Remove this once we drop support for building libc++ with old Clangs
  996. # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
  997. (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
  998. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
  999. # else
  1000. # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
  1001. # endif
  1002. # else
  1003. # define _LIBCPP_INIT_PRIORITY_MAX
  1004. # endif
  1005. # if defined(__GNUC__) || defined(__clang__)
  1006. // The attribute uses 1-based indices for ordinary and static member functions.
  1007. // The attribute uses 2-based indices for non-static member functions.
  1008. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
  1009. __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
  1010. # else
  1011. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
  1012. # endif
  1013. # if __has_cpp_attribute(msvc::no_unique_address)
  1014. // MSVC implements [[no_unique_address]] as a silent no-op currently.
  1015. // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
  1016. // However, MSVC implements [[msvc::no_unique_address]] which does what
  1017. // [[no_unique_address]] is supposed to do, in general.
  1018. // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
  1019. // [[msvc::no_unique_address]] though. If/when it does implement
  1020. // [[msvc::no_unique_address]], this should be preferred though.
  1021. # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
  1022. # elif __has_cpp_attribute(no_unique_address)
  1023. # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]]
  1024. # else
  1025. # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
  1026. // Note that this can be replaced by #error as soon as clang-cl
  1027. // implements msvc::no_unique_address, since there should be no C++20
  1028. // compiler that doesn't support one of the two attributes at that point.
  1029. // We generally don't want to use this macro outside of C++20-only code,
  1030. // because using it conditionally in one language version only would make
  1031. // the ABI inconsistent.
  1032. # endif
  1033. # ifdef _LIBCPP_COMPILER_CLANG_BASED
  1034. # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
  1035. # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
  1036. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
  1037. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
  1038. # elif defined(_LIBCPP_COMPILER_GCC)
  1039. # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
  1040. # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
  1041. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
  1042. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
  1043. # else
  1044. # define _LIBCPP_DIAGNOSTIC_PUSH
  1045. # define _LIBCPP_DIAGNOSTIC_POP
  1046. # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
  1047. # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
  1048. # endif
  1049. # if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC)
  1050. # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)")
  1051. # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)")
  1052. # else
  1053. # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */
  1054. # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */
  1055. # endif
  1056. # if __has_attribute(__packed__) && !defined(__CUDACC__)
  1057. # define _LIBCPP_PACKED __attribute__((__packed__))
  1058. # else
  1059. # define _LIBCPP_PACKED
  1060. # endif
  1061. #endif // __cplusplus
  1062. #endif // _LIBCPP___CONFIG