__config 53 KB

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