__config 49 KB

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