__config 48 KB

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