__config 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. // -*- C++ -*-
  2. //===--------------------------- __config ---------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_CONFIG
  11. #define _LIBCPP_CONFIG
  12. #if defined(_MSC_VER) && !defined(__clang__)
  13. #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  14. #endif
  15. #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
  16. #pragma GCC system_header
  17. #endif
  18. #ifdef __cplusplus
  19. #ifdef __GNUC__
  20. #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
  21. #else
  22. #define _GNUC_VER 0
  23. #endif
  24. #define _LIBCPP_VERSION 3900
  25. #ifndef _LIBCPP_ABI_VERSION
  26. #define _LIBCPP_ABI_VERSION 1
  27. #endif
  28. #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
  29. // Change short string represention so that string data starts at offset 0,
  30. // improving its alignment in some cases.
  31. #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  32. // Fix deque iterator type in order to support incomplete types.
  33. #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
  34. // Fix undefined behavior in how std::list stores it's linked nodes.
  35. #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
  36. // Fix undefined behavior in how __tree stores its end and parent nodes.
  37. #define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
  38. #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
  39. #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
  40. #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
  41. #elif _LIBCPP_ABI_VERSION == 1
  42. // Feature macros for disabling pre ABI v1 features. All of these options
  43. // are deprecated.
  44. #if defined(__FreeBSD__)
  45. #define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
  46. #endif
  47. #endif
  48. #ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
  49. #error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
  50. use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
  51. #endif
  52. #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
  53. #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
  54. #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
  55. #ifndef __has_attribute
  56. #define __has_attribute(__x) 0
  57. #endif
  58. #ifndef __has_builtin
  59. #define __has_builtin(__x) 0
  60. #endif
  61. #ifndef __has_extension
  62. #define __has_extension(__x) 0
  63. #endif
  64. #ifndef __has_feature
  65. #define __has_feature(__x) 0
  66. #endif
  67. // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
  68. // the compiler and '1' otherwise.
  69. #ifndef __is_identifier
  70. #define __is_identifier(__x) 1
  71. #endif
  72. #ifdef __LITTLE_ENDIAN__
  73. #if __LITTLE_ENDIAN__
  74. #define _LIBCPP_LITTLE_ENDIAN 1
  75. #define _LIBCPP_BIG_ENDIAN 0
  76. #endif // __LITTLE_ENDIAN__
  77. #endif // __LITTLE_ENDIAN__
  78. #ifdef __BIG_ENDIAN__
  79. #if __BIG_ENDIAN__
  80. #define _LIBCPP_LITTLE_ENDIAN 0
  81. #define _LIBCPP_BIG_ENDIAN 1
  82. #endif // __BIG_ENDIAN__
  83. #endif // __BIG_ENDIAN__
  84. #ifdef __BYTE_ORDER__
  85. #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  86. #define _LIBCPP_LITTLE_ENDIAN 1
  87. #define _LIBCPP_BIG_ENDIAN 0
  88. #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  89. #define _LIBCPP_LITTLE_ENDIAN 0
  90. #define _LIBCPP_BIG_ENDIAN 1
  91. #endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  92. #endif // __BYTE_ORDER__
  93. #ifdef __FreeBSD__
  94. # include <sys/endian.h>
  95. # if _BYTE_ORDER == _LITTLE_ENDIAN
  96. # define _LIBCPP_LITTLE_ENDIAN 1
  97. # define _LIBCPP_BIG_ENDIAN 0
  98. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  99. # define _LIBCPP_LITTLE_ENDIAN 0
  100. # define _LIBCPP_BIG_ENDIAN 1
  101. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  102. # ifndef __LONG_LONG_SUPPORTED
  103. # define _LIBCPP_HAS_NO_LONG_LONG
  104. # endif // __LONG_LONG_SUPPORTED
  105. #endif // __FreeBSD__
  106. #ifdef __NetBSD__
  107. # include <sys/endian.h>
  108. # if _BYTE_ORDER == _LITTLE_ENDIAN
  109. # define _LIBCPP_LITTLE_ENDIAN 1
  110. # define _LIBCPP_BIG_ENDIAN 0
  111. # else // _BYTE_ORDER == _LITTLE_ENDIAN
  112. # define _LIBCPP_LITTLE_ENDIAN 0
  113. # define _LIBCPP_BIG_ENDIAN 1
  114. # endif // _BYTE_ORDER == _LITTLE_ENDIAN
  115. # define _LIBCPP_HAS_QUICK_EXIT
  116. #endif // __NetBSD__
  117. #ifdef _WIN32
  118. # define _LIBCPP_LITTLE_ENDIAN 1
  119. # define _LIBCPP_BIG_ENDIAN 0
  120. // Compiler intrinsics (MSVC)
  121. #if defined(_MSC_VER) && _MSC_VER >= 1400
  122. # define _LIBCPP_HAS_IS_BASE_OF
  123. # endif
  124. # if defined(_MSC_VER) && !defined(__clang__)
  125. # define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
  126. # define _LIBCPP_TOSTRING2(x) #x
  127. # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
  128. # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
  129. # endif
  130. # // If mingw not explicitly detected, assume using MS C runtime only.
  131. # ifndef __MINGW32__
  132. # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
  133. # endif
  134. #endif // _WIN32
  135. #ifdef __sun__
  136. # include <sys/isa_defs.h>
  137. # ifdef _LITTLE_ENDIAN
  138. # define _LIBCPP_LITTLE_ENDIAN 1
  139. # define _LIBCPP_BIG_ENDIAN 0
  140. # else
  141. # define _LIBCPP_LITTLE_ENDIAN 0
  142. # define _LIBCPP_BIG_ENDIAN 1
  143. # endif
  144. #endif // __sun__
  145. #if defined(__CloudABI__)
  146. // Certain architectures provide arc4random(). Prefer using
  147. // arc4random() over /dev/{u,}random to make it possible to obtain
  148. // random data even when using sandboxing mechanisms such as chroots,
  149. // Capsicum, etc.
  150. # define _LIBCPP_USING_ARC4_RANDOM
  151. #elif defined(__native_client__)
  152. // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
  153. // including accesses to the special files under /dev. C++11's
  154. // std::random_device is instead exposed through a NaCl syscall.
  155. # define _LIBCPP_USING_NACL_RANDOM
  156. #elif defined(_WIN32)
  157. # define _LIBCPP_USING_WIN32_RANDOM
  158. #else
  159. # define _LIBCPP_USING_DEV_RANDOM
  160. #endif
  161. #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
  162. # include <endian.h>
  163. # if __BYTE_ORDER == __LITTLE_ENDIAN
  164. # define _LIBCPP_LITTLE_ENDIAN 1
  165. # define _LIBCPP_BIG_ENDIAN 0
  166. # elif __BYTE_ORDER == __BIG_ENDIAN
  167. # define _LIBCPP_LITTLE_ENDIAN 0
  168. # define _LIBCPP_BIG_ENDIAN 1
  169. # else // __BYTE_ORDER == __BIG_ENDIAN
  170. # error unable to determine endian
  171. # endif
  172. #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
  173. #if __has_attribute(__no_sanitize__)
  174. #define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
  175. #else
  176. #define _LIBCPP_NO_CFI
  177. #endif
  178. #ifdef _WIN32
  179. // only really useful for a DLL
  180. #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
  181. # ifdef cxx_EXPORTS
  182. # define _LIBCPP_HIDDEN
  183. # define _LIBCPP_FUNC_VIS __declspec(dllexport)
  184. # define _LIBCPP_TYPE_VIS __declspec(dllexport)
  185. # else
  186. # define _LIBCPP_HIDDEN
  187. # define _LIBCPP_FUNC_VIS __declspec(dllimport)
  188. # define _LIBCPP_TYPE_VIS __declspec(dllimport)
  189. # endif
  190. #else
  191. # define _LIBCPP_HIDDEN
  192. # define _LIBCPP_FUNC_VIS
  193. # define _LIBCPP_TYPE_VIS
  194. #endif
  195. #define _LIBCPP_TYPE_VIS_ONLY
  196. #define _LIBCPP_FUNC_VIS_ONLY
  197. #ifndef _LIBCPP_INLINE_VISIBILITY
  198. # ifdef _LIBCPP_MSVC
  199. # define _LIBCPP_INLINE_VISIBILITY __forceinline
  200. # else // MinGW GCC and Clang
  201. # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
  202. # endif
  203. #endif
  204. #ifndef _LIBCPP_EXCEPTION_ABI
  205. #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
  206. #endif
  207. #ifndef _LIBCPP_ALWAYS_INLINE
  208. # ifdef _LIBCPP_MSVC
  209. # define _LIBCPP_ALWAYS_INLINE __forceinline
  210. # endif
  211. #endif
  212. #endif // _WIN32
  213. #ifndef _LIBCPP_HIDDEN
  214. #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
  215. #endif
  216. #ifndef _LIBCPP_FUNC_VIS
  217. #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
  218. #endif
  219. #ifndef _LIBCPP_TYPE_VIS
  220. # if __has_attribute(__type_visibility__)
  221. # define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
  222. # else
  223. # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
  224. # endif
  225. #endif
  226. #ifndef _LIBCPP_PREFERRED_OVERLOAD
  227. # if __has_attribute(__enable_if__)
  228. # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
  229. # endif
  230. #endif
  231. #ifndef _LIBCPP_TYPE_VIS_ONLY
  232. # define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
  233. #endif
  234. #ifndef _LIBCPP_FUNC_VIS_ONLY
  235. # define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
  236. #endif
  237. #ifndef _LIBCPP_INLINE_VISIBILITY
  238. #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
  239. #endif
  240. #ifndef _LIBCPP_EXCEPTION_ABI
  241. #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
  242. #endif
  243. #ifndef _LIBCPP_ALWAYS_INLINE
  244. #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
  245. #endif
  246. #if defined(__clang__)
  247. // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
  248. // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
  249. #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
  250. !defined(__arm__)) || \
  251. defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
  252. #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  253. #endif
  254. #if __has_feature(cxx_alignas)
  255. # define _ALIGNAS_TYPE(x) alignas(x)
  256. # define _ALIGNAS(x) alignas(x)
  257. #else
  258. # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  259. # define _ALIGNAS(x) __attribute__((__aligned__(x)))
  260. #endif
  261. #if !__has_feature(cxx_alias_templates)
  262. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  263. #endif
  264. #if __cplusplus < 201103L
  265. typedef __char16_t char16_t;
  266. typedef __char32_t char32_t;
  267. #endif
  268. #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
  269. #define _LIBCPP_NO_EXCEPTIONS
  270. #endif
  271. #if !(__has_feature(cxx_rtti))
  272. #define _LIBCPP_NO_RTTI
  273. #endif
  274. #if !(__has_feature(cxx_strong_enums))
  275. #define _LIBCPP_HAS_NO_STRONG_ENUMS
  276. #endif
  277. #if !(__has_feature(cxx_decltype))
  278. #define _LIBCPP_HAS_NO_DECLTYPE
  279. #endif
  280. #if __has_feature(cxx_attributes)
  281. # define _LIBCPP_NORETURN [[noreturn]]
  282. #else
  283. # define _LIBCPP_NORETURN __attribute__ ((noreturn))
  284. #endif
  285. #if !(__has_feature(cxx_default_function_template_args))
  286. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  287. #endif
  288. #if !(__has_feature(cxx_defaulted_functions))
  289. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  290. #endif // !(__has_feature(cxx_defaulted_functions))
  291. #if !(__has_feature(cxx_deleted_functions))
  292. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  293. #endif // !(__has_feature(cxx_deleted_functions))
  294. #if !(__has_feature(cxx_lambdas))
  295. #define _LIBCPP_HAS_NO_LAMBDAS
  296. #endif
  297. #if !(__has_feature(cxx_nullptr))
  298. #define _LIBCPP_HAS_NO_NULLPTR
  299. #endif
  300. #if !(__has_feature(cxx_rvalue_references))
  301. #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
  302. #endif
  303. #if !(__has_feature(cxx_static_assert))
  304. #define _LIBCPP_HAS_NO_STATIC_ASSERT
  305. #endif
  306. #if !(__has_feature(cxx_auto_type))
  307. #define _LIBCPP_HAS_NO_AUTO_TYPE
  308. #endif
  309. #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
  310. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  311. #endif
  312. #if !(__has_feature(cxx_variadic_templates))
  313. #define _LIBCPP_HAS_NO_VARIADICS
  314. #endif
  315. #if !(__has_feature(cxx_trailing_return))
  316. #define _LIBCPP_HAS_NO_TRAILING_RETURN
  317. #endif
  318. #if !(__has_feature(cxx_generalized_initializers))
  319. #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  320. #endif
  321. #if __has_feature(is_base_of)
  322. # define _LIBCPP_HAS_IS_BASE_OF
  323. #endif
  324. #if __has_feature(is_final)
  325. # define _LIBCPP_HAS_IS_FINAL
  326. #endif
  327. // Objective-C++ features (opt-in)
  328. #if __has_feature(objc_arc)
  329. #define _LIBCPP_HAS_OBJC_ARC
  330. #endif
  331. #if __has_feature(objc_arc_weak)
  332. #define _LIBCPP_HAS_OBJC_ARC_WEAK
  333. #define _LIBCPP_HAS_NO_STRONG_ENUMS
  334. #endif
  335. #if !(__has_feature(cxx_constexpr))
  336. #define _LIBCPP_HAS_NO_CONSTEXPR
  337. #endif
  338. #if !(__has_feature(cxx_relaxed_constexpr))
  339. #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
  340. #endif
  341. #if !(__has_feature(cxx_variable_templates))
  342. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  343. #endif
  344. #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
  345. #if defined(__FreeBSD__)
  346. #define _LIBCPP_HAS_QUICK_EXIT
  347. #define _LIBCPP_HAS_C11_FEATURES
  348. #elif defined(__ANDROID__)
  349. #define _LIBCPP_HAS_QUICK_EXIT
  350. #elif defined(__linux__)
  351. #if !defined(_LIBCPP_HAS_MUSL_LIBC)
  352. # include <features.h>
  353. #if __GLIBC_PREREQ(2, 15)
  354. #define _LIBCPP_HAS_QUICK_EXIT
  355. #endif
  356. #if __GLIBC_PREREQ(2, 17)
  357. #define _LIBCPP_HAS_C11_FEATURES
  358. #endif
  359. #else // defined(_LIBCPP_HAS_MUSL_LIBC)
  360. #define _LIBCPP_HAS_QUICK_EXIT
  361. #define _LIBCPP_HAS_C11_FEATURES
  362. #endif
  363. #endif // __linux__
  364. #endif
  365. #if !(__has_feature(cxx_noexcept))
  366. #define _LIBCPP_HAS_NO_NOEXCEPT
  367. #endif
  368. #if __has_feature(underlying_type)
  369. # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  370. #endif
  371. #if __has_feature(is_literal)
  372. # define _LIBCPP_IS_LITERAL(T) __is_literal(T)
  373. #endif
  374. // Inline namespaces are available in Clang regardless of C++ dialect.
  375. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
  376. #define _LIBCPP_END_NAMESPACE_STD } }
  377. #define _VSTD std::_LIBCPP_NAMESPACE
  378. namespace std {
  379. inline namespace _LIBCPP_NAMESPACE {
  380. }
  381. }
  382. #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
  383. #define _LIBCPP_HAS_NO_ASAN
  384. #endif
  385. // Allow for build-time disabling of unsigned integer sanitization
  386. #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
  387. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
  388. #endif
  389. #elif defined(__GNUC__)
  390. #include <__sgx>
  391. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  392. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  393. #define _LIBCPP_NORETURN __attribute__((noreturn))
  394. #if _GNUC_VER >= 407
  395. #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  396. #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  397. #define _LIBCPP_HAS_IS_FINAL
  398. #endif
  399. #if defined(__GNUC__) && _GNUC_VER >= 403
  400. # define _LIBCPP_HAS_IS_BASE_OF
  401. #endif
  402. #if !__EXCEPTIONS
  403. #define _LIBCPP_NO_EXCEPTIONS
  404. #endif
  405. // constexpr was added to GCC in 4.6.
  406. #if _GNUC_VER < 406
  407. #define _LIBCPP_HAS_NO_CONSTEXPR
  408. // Can only use constexpr in c++11 mode.
  409. #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
  410. #define _LIBCPP_HAS_NO_CONSTEXPR
  411. #endif
  412. // Determine if GCC supports relaxed constexpr
  413. #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
  414. #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
  415. #endif
  416. // GCC 5 will support variable templates
  417. #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
  418. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  419. #endif
  420. #ifndef __GXX_EXPERIMENTAL_CXX0X__
  421. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  422. #define _LIBCPP_HAS_NO_DECLTYPE
  423. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  424. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  425. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  426. #define _LIBCPP_HAS_NO_NULLPTR
  427. #define _LIBCPP_HAS_NO_STATIC_ASSERT
  428. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  429. #define _LIBCPP_HAS_NO_VARIADICS
  430. #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
  431. #define _LIBCPP_HAS_NO_STRONG_ENUMS
  432. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  433. #define _LIBCPP_HAS_NO_NOEXCEPT
  434. #else // __GXX_EXPERIMENTAL_CXX0X__
  435. #if _GNUC_VER < 403
  436. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  437. #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
  438. #define _LIBCPP_HAS_NO_STATIC_ASSERT
  439. #endif
  440. #if _GNUC_VER < 404
  441. #define _LIBCPP_HAS_NO_DECLTYPE
  442. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  443. #define _LIBCPP_HAS_NO_TRAILING_RETURN
  444. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  445. #define _LIBCPP_HAS_NO_VARIADICS
  446. #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  447. #endif // _GNUC_VER < 404
  448. #if _GNUC_VER < 406
  449. #define _LIBCPP_HAS_NO_NOEXCEPT
  450. #define _LIBCPP_HAS_NO_NULLPTR
  451. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  452. #endif
  453. #if _GNUC_VER < 407
  454. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  455. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  456. #endif
  457. #endif // __GXX_EXPERIMENTAL_CXX0X__
  458. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
  459. #define _LIBCPP_END_NAMESPACE_STD } }
  460. #define _VSTD std::_LIBCPP_NAMESPACE
  461. namespace std {
  462. namespace _LIBCPP_NAMESPACE {
  463. }
  464. using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
  465. }
  466. #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
  467. #define _LIBCPP_HAS_NO_ASAN
  468. #endif
  469. #elif defined(_LIBCPP_MSVC)
  470. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  471. #define _LIBCPP_HAS_NO_CONSTEXPR
  472. #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
  473. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  474. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  475. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  476. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  477. #define _LIBCPP_HAS_NO_NOEXCEPT
  478. #define __alignof__ __alignof
  479. #define _LIBCPP_NORETURN __declspec(noreturn)
  480. #define _ALIGNAS(x) __declspec(align(x))
  481. #define _LIBCPP_HAS_NO_VARIADICS
  482. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
  483. #define _LIBCPP_END_NAMESPACE_STD }
  484. #define _VSTD std
  485. # define _LIBCPP_WEAK
  486. namespace std {
  487. }
  488. #define _LIBCPP_HAS_NO_ASAN
  489. #elif defined(__IBMCPP__)
  490. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  491. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  492. #define _ATTRIBUTE(x) __attribute__((x))
  493. #define _LIBCPP_NORETURN __attribute__((noreturn))
  494. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  495. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  496. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  497. #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  498. #define _LIBCPP_HAS_NO_NOEXCEPT
  499. #define _LIBCPP_HAS_NO_NULLPTR
  500. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  501. #define _LIBCPP_HAS_IS_BASE_OF
  502. #define _LIBCPP_HAS_IS_FINAL
  503. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  504. #if defined(_AIX)
  505. #define __MULTILOCALE_API
  506. #endif
  507. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
  508. #define _LIBCPP_END_NAMESPACE_STD } }
  509. #define _VSTD std::_LIBCPP_NAMESPACE
  510. namespace std {
  511. inline namespace _LIBCPP_NAMESPACE {
  512. }
  513. }
  514. #define _LIBCPP_HAS_NO_ASAN
  515. #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
  516. #ifndef _LIBCPP_HAS_NO_NOEXCEPT
  517. # define _NOEXCEPT noexcept
  518. # define _NOEXCEPT_(x) noexcept(x)
  519. #else
  520. # define _NOEXCEPT throw()
  521. # define _NOEXCEPT_(x)
  522. #endif
  523. #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
  524. typedef unsigned short char16_t;
  525. typedef unsigned int char32_t;
  526. #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
  527. #ifndef __SIZEOF_INT128__
  528. #define _LIBCPP_HAS_NO_INT128
  529. #endif
  530. #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
  531. extern "C++" {
  532. template <bool> struct __static_assert_test;
  533. template <> struct __static_assert_test<true> {};
  534. template <unsigned> struct __static_assert_check {};
  535. }
  536. #define static_assert(__b, __m) \
  537. typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
  538. _LIBCPP_CONCAT(__t, __LINE__)
  539. #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
  540. #ifdef _LIBCPP_HAS_NO_DECLTYPE
  541. // GCC 4.6 provides __decltype in all standard modes.
  542. #if !__is_identifier(__decltype) || _GNUC_VER >= 406
  543. # define decltype(__x) __decltype(__x)
  544. #else
  545. # define decltype(__x) __typeof__(__x)
  546. #endif
  547. #endif
  548. #ifdef _LIBCPP_HAS_NO_CONSTEXPR
  549. #define _LIBCPP_CONSTEXPR
  550. #else
  551. #define _LIBCPP_CONSTEXPR constexpr
  552. #endif
  553. #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  554. #define _LIBCPP_DEFAULT {}
  555. #else
  556. #define _LIBCPP_DEFAULT = default;
  557. #endif
  558. #ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  559. #define _LIBCPP_EQUAL_DELETE
  560. #else
  561. #define _LIBCPP_EQUAL_DELETE = delete
  562. #endif
  563. #ifdef __GNUC__
  564. #define _NOALIAS __attribute__((__malloc__))
  565. #else
  566. #define _NOALIAS
  567. #endif
  568. #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
  569. # define _LIBCPP_EXPLICIT explicit
  570. #else
  571. # define _LIBCPP_EXPLICIT
  572. #endif
  573. #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
  574. # define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
  575. #endif
  576. #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
  577. #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
  578. #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
  579. __lx __v_; \
  580. _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
  581. _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
  582. _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
  583. };
  584. #else // _LIBCPP_HAS_NO_STRONG_ENUMS
  585. #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
  586. #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
  587. #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
  588. #ifdef _LIBCPP_DEBUG
  589. # if _LIBCPP_DEBUG == 0
  590. # define _LIBCPP_DEBUG_LEVEL 1
  591. # elif _LIBCPP_DEBUG == 1
  592. # define _LIBCPP_DEBUG_LEVEL 2
  593. # else
  594. # error Supported values for _LIBCPP_DEBUG are 0 and 1
  595. # endif
  596. # define _LIBCPP_EXTERN_TEMPLATE(...)
  597. #endif
  598. #ifndef _LIBCPP_EXTERN_TEMPLATE
  599. #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
  600. #endif
  601. #ifndef _LIBCPP_EXTERN_TEMPLATE2
  602. #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
  603. #endif
  604. #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
  605. #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
  606. #endif
  607. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
  608. defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
  609. #define _LIBCPP_LOCALE__L_EXTENSIONS 1
  610. #endif
  611. #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
  612. // Most unix variants have catopen. These are the specific ones that don't.
  613. #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && !defined(__LIBCPP_SGX)
  614. #define _LIBCPP_HAS_CATOPEN 1
  615. #endif
  616. #endif
  617. #ifdef __FreeBSD__
  618. #define _DECLARE_C99_LDBL_MATH 1
  619. #endif
  620. #if defined(__APPLE__) || defined(__FreeBSD__)
  621. #define _LIBCPP_HAS_DEFAULTRUNELOCALE
  622. #endif
  623. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
  624. #define _LIBCPP_WCTYPE_IS_MASK
  625. #endif
  626. #ifndef _LIBCPP_STD_VER
  627. # if __cplusplus <= 201103L
  628. # define _LIBCPP_STD_VER 11
  629. # elif __cplusplus <= 201402L
  630. # define _LIBCPP_STD_VER 14
  631. # else
  632. # define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
  633. # endif
  634. #endif // _LIBCPP_STD_VER
  635. #if _LIBCPP_STD_VER > 11
  636. #define _LIBCPP_DEPRECATED [[deprecated]]
  637. #else
  638. #define _LIBCPP_DEPRECATED
  639. #endif
  640. #if _LIBCPP_STD_VER <= 11
  641. #define _LIBCPP_EXPLICIT_AFTER_CXX11
  642. #define _LIBCPP_DEPRECATED_AFTER_CXX11
  643. #else
  644. #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
  645. #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
  646. #endif
  647. #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  648. #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  649. #else
  650. #define _LIBCPP_CONSTEXPR_AFTER_CXX11
  651. #endif
  652. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  653. #define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  654. #else
  655. #define _LIBCPP_CONSTEXPR_AFTER_CXX14
  656. #endif
  657. #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  658. # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
  659. #else
  660. # define _LIBCPP_EXPLICIT_MOVE(x) (x)
  661. #endif
  662. #ifndef _LIBCPP_HAS_NO_ASAN
  663. extern "C" void __sanitizer_annotate_contiguous_container(
  664. const void *, const void *, const void *, const void *);
  665. #endif
  666. // Try to find out if RTTI is disabled.
  667. // g++ and cl.exe have RTTI on by default and define a macro when it is.
  668. // g++ only defines the macro in 4.3.2 and onwards.
  669. #if !defined(_LIBCPP_NO_RTTI)
  670. # if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
  671. (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
  672. # define _LIBCPP_NO_RTTI
  673. # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
  674. # define _LIBCPP_NO_RTTI
  675. # endif
  676. #endif
  677. #ifndef _LIBCPP_WEAK
  678. # define _LIBCPP_WEAK __attribute__((__weak__))
  679. #endif
  680. // Thread API
  681. #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  682. # if defined(__FreeBSD__) || \
  683. defined(__NetBSD__) || \
  684. defined(__linux__) || \
  685. defined(__APPLE__) || \
  686. defined(__CloudABI__) || \
  687. defined(__sun__)
  688. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  689. # else
  690. # error "No thread API"
  691. # endif // _LIBCPP_HAS_THREAD_API
  692. #endif // _LIBCPP_HAS_NO_THREADS
  693. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  694. # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
  695. _LIBCPP_HAS_NO_THREADS is not defined.
  696. #endif
  697. #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
  698. # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  699. _LIBCPP_HAS_NO_THREADS is defined.
  700. #endif
  701. // Systems that use capability-based security (FreeBSD with Capsicum,
  702. // Nuxi CloudABI) may only provide local filesystem access (using *at()).
  703. // Functions like open(), rename(), unlink() and stat() should not be
  704. // used, as they attempt to access the global filesystem namespace.
  705. #ifdef __CloudABI__
  706. #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
  707. #endif
  708. // CloudABI is intended for running networked services. Processes do not
  709. // have standard input and output channels.
  710. #ifdef __CloudABI__
  711. #define _LIBCPP_HAS_NO_STDIN
  712. #define _LIBCPP_HAS_NO_STDOUT
  713. #endif
  714. #if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC)
  715. #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
  716. #endif
  717. // Thread-unsafe functions such as strtok(), mbtowc() and localtime()
  718. // are not available.
  719. #ifdef __CloudABI__
  720. #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
  721. #endif
  722. #if __has_feature(cxx_atomic) || __has_extension(c_atomic)
  723. #define _LIBCPP_HAS_C_ATOMIC_IMP
  724. #elif _GNUC_VER > 407
  725. #define _LIBCPP_HAS_GCC_ATOMIC_IMP
  726. #endif
  727. #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
  728. || defined(_LIBCPP_HAS_NO_THREADS)
  729. #define _LIBCPP_HAS_NO_ATOMIC_HEADER
  730. #endif
  731. #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  732. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  733. #endif
  734. #if __cplusplus < 201103L
  735. #define _LIBCPP_CXX03_LANG
  736. #else
  737. #if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
  738. #error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
  739. #endif
  740. #endif
  741. #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
  742. && __has_attribute(acquire_capability))
  743. #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  744. #endif
  745. #endif // __cplusplus
  746. #endif // _LIBCPP_CONFIG