__config 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. #define _LIBCPP_HAS_QUICK_EXIT
  353. #define _LIBCPP_HAS_C11_FEATURES
  354. #endif
  355. #endif // __linux__
  356. #endif
  357. #if !(__has_feature(cxx_noexcept))
  358. #define _LIBCPP_HAS_NO_NOEXCEPT
  359. #endif
  360. #if __has_feature(underlying_type)
  361. # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  362. #endif
  363. #if __has_feature(is_literal)
  364. # define _LIBCPP_IS_LITERAL(T) __is_literal(T)
  365. #endif
  366. // Inline namespaces are available in Clang regardless of C++ dialect.
  367. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
  368. #define _LIBCPP_END_NAMESPACE_STD } }
  369. #define _VSTD std::_LIBCPP_NAMESPACE
  370. namespace std {
  371. inline namespace _LIBCPP_NAMESPACE {
  372. }
  373. }
  374. #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
  375. #define _LIBCPP_HAS_NO_ASAN
  376. #endif
  377. // Allow for build-time disabling of unsigned integer sanitization
  378. #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
  379. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
  380. #endif
  381. #include <__sgx>
  382. #elif defined(__GNUC__)
  383. #include <__sgx>
  384. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  385. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  386. #define _LIBCPP_NORETURN __attribute__((noreturn))
  387. #if _GNUC_VER >= 407
  388. #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
  389. #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
  390. #define _LIBCPP_HAS_IS_FINAL
  391. #endif
  392. #if defined(__GNUC__) && _GNUC_VER >= 403
  393. # define _LIBCPP_HAS_IS_BASE_OF
  394. #endif
  395. #if !__EXCEPTIONS
  396. #define _LIBCPP_NO_EXCEPTIONS
  397. #endif
  398. // constexpr was added to GCC in 4.6.
  399. #if _GNUC_VER < 406
  400. #define _LIBCPP_HAS_NO_CONSTEXPR
  401. // Can only use constexpr in c++11 mode.
  402. #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
  403. #define _LIBCPP_HAS_NO_CONSTEXPR
  404. #endif
  405. // Determine if GCC supports relaxed constexpr
  406. #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
  407. #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
  408. #endif
  409. // GCC 5 will support variable templates
  410. #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
  411. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  412. #endif
  413. #ifndef __GXX_EXPERIMENTAL_CXX0X__
  414. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  415. #define _LIBCPP_HAS_NO_DECLTYPE
  416. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  417. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  418. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  419. #define _LIBCPP_HAS_NO_NULLPTR
  420. #define _LIBCPP_HAS_NO_STATIC_ASSERT
  421. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  422. #define _LIBCPP_HAS_NO_VARIADICS
  423. #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
  424. #define _LIBCPP_HAS_NO_STRONG_ENUMS
  425. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  426. #define _LIBCPP_HAS_NO_NOEXCEPT
  427. #else // __GXX_EXPERIMENTAL_CXX0X__
  428. #if _GNUC_VER < 403
  429. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  430. #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
  431. #define _LIBCPP_HAS_NO_STATIC_ASSERT
  432. #endif
  433. #if _GNUC_VER < 404
  434. #define _LIBCPP_HAS_NO_DECLTYPE
  435. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  436. #define _LIBCPP_HAS_NO_TRAILING_RETURN
  437. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  438. #define _LIBCPP_HAS_NO_VARIADICS
  439. #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  440. #endif // _GNUC_VER < 404
  441. #if _GNUC_VER < 406
  442. #define _LIBCPP_HAS_NO_NOEXCEPT
  443. #define _LIBCPP_HAS_NO_NULLPTR
  444. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  445. #endif
  446. #if _GNUC_VER < 407
  447. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  448. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  449. #endif
  450. #endif // __GXX_EXPERIMENTAL_CXX0X__
  451. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
  452. #define _LIBCPP_END_NAMESPACE_STD } }
  453. #define _VSTD std::_LIBCPP_NAMESPACE
  454. namespace std {
  455. namespace _LIBCPP_NAMESPACE {
  456. }
  457. using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
  458. }
  459. #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
  460. #define _LIBCPP_HAS_NO_ASAN
  461. #endif
  462. #elif defined(_LIBCPP_MSVC)
  463. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  464. #define _LIBCPP_HAS_NO_CONSTEXPR
  465. #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
  466. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  467. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  468. #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  469. #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  470. #define _LIBCPP_HAS_NO_NOEXCEPT
  471. #define __alignof__ __alignof
  472. #define _LIBCPP_NORETURN __declspec(noreturn)
  473. #define _ALIGNAS(x) __declspec(align(x))
  474. #define _LIBCPP_HAS_NO_VARIADICS
  475. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
  476. #define _LIBCPP_END_NAMESPACE_STD }
  477. #define _VSTD std
  478. # define _LIBCPP_WEAK
  479. namespace std {
  480. }
  481. #define _LIBCPP_HAS_NO_ASAN
  482. #elif defined(__IBMCPP__)
  483. #define _ALIGNAS(x) __attribute__((__aligned__(x)))
  484. #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
  485. #define _ATTRIBUTE(x) __attribute__((x))
  486. #define _LIBCPP_NORETURN __attribute__((noreturn))
  487. #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
  488. #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  489. #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
  490. #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  491. #define _LIBCPP_HAS_NO_NOEXCEPT
  492. #define _LIBCPP_HAS_NO_NULLPTR
  493. #define _LIBCPP_HAS_NO_UNICODE_CHARS
  494. #define _LIBCPP_HAS_IS_BASE_OF
  495. #define _LIBCPP_HAS_IS_FINAL
  496. #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
  497. #if defined(_AIX)
  498. #define __MULTILOCALE_API
  499. #endif
  500. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
  501. #define _LIBCPP_END_NAMESPACE_STD } }
  502. #define _VSTD std::_LIBCPP_NAMESPACE
  503. namespace std {
  504. inline namespace _LIBCPP_NAMESPACE {
  505. }
  506. }
  507. #define _LIBCPP_HAS_NO_ASAN
  508. #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
  509. #ifndef _LIBCPP_HAS_NO_NOEXCEPT
  510. # define _NOEXCEPT noexcept
  511. # define _NOEXCEPT_(x) noexcept(x)
  512. #else
  513. # define _NOEXCEPT throw()
  514. # define _NOEXCEPT_(x)
  515. #endif
  516. #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
  517. typedef unsigned short char16_t;
  518. typedef unsigned int char32_t;
  519. #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
  520. #ifndef __SIZEOF_INT128__
  521. #define _LIBCPP_HAS_NO_INT128
  522. #endif
  523. #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
  524. extern "C++" {
  525. template <bool> struct __static_assert_test;
  526. template <> struct __static_assert_test<true> {};
  527. template <unsigned> struct __static_assert_check {};
  528. }
  529. #define static_assert(__b, __m) \
  530. typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
  531. _LIBCPP_CONCAT(__t, __LINE__)
  532. #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
  533. #ifdef _LIBCPP_HAS_NO_DECLTYPE
  534. // GCC 4.6 provides __decltype in all standard modes.
  535. #if !__is_identifier(__decltype) || _GNUC_VER >= 406
  536. # define decltype(__x) __decltype(__x)
  537. #else
  538. # define decltype(__x) __typeof__(__x)
  539. #endif
  540. #endif
  541. #ifdef _LIBCPP_HAS_NO_CONSTEXPR
  542. #define _LIBCPP_CONSTEXPR
  543. #else
  544. #define _LIBCPP_CONSTEXPR constexpr
  545. #endif
  546. #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  547. #define _LIBCPP_DEFAULT {}
  548. #else
  549. #define _LIBCPP_DEFAULT = default;
  550. #endif
  551. #ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  552. #define _LIBCPP_EQUAL_DELETE
  553. #else
  554. #define _LIBCPP_EQUAL_DELETE = delete
  555. #endif
  556. #ifdef __GNUC__
  557. #define _NOALIAS __attribute__((__malloc__))
  558. #else
  559. #define _NOALIAS
  560. #endif
  561. #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
  562. # define _LIBCPP_EXPLICIT explicit
  563. #else
  564. # define _LIBCPP_EXPLICIT
  565. #endif
  566. #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
  567. # define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
  568. #endif
  569. #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
  570. #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
  571. #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
  572. __lx __v_; \
  573. _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
  574. _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
  575. _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
  576. };
  577. #else // _LIBCPP_HAS_NO_STRONG_ENUMS
  578. #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
  579. #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
  580. #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
  581. #ifdef _LIBCPP_DEBUG
  582. # if _LIBCPP_DEBUG == 0
  583. # define _LIBCPP_DEBUG_LEVEL 1
  584. # elif _LIBCPP_DEBUG == 1
  585. # define _LIBCPP_DEBUG_LEVEL 2
  586. # else
  587. # error Supported values for _LIBCPP_DEBUG are 0 and 1
  588. # endif
  589. # define _LIBCPP_EXTERN_TEMPLATE(...)
  590. #endif
  591. #ifndef _LIBCPP_EXTERN_TEMPLATE
  592. #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
  593. #endif
  594. #ifndef _LIBCPP_EXTERN_TEMPLATE2
  595. #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
  596. #endif
  597. #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
  598. #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
  599. #endif
  600. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
  601. defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
  602. #define _LIBCPP_LOCALE__L_EXTENSIONS 1
  603. #endif
  604. #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
  605. // Most unix variants have catopen. These are the specific ones that don't.
  606. #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && !defined(__LIBCPP_SGX)
  607. #define _LIBCPP_HAS_CATOPEN 1
  608. #endif
  609. #endif
  610. #ifdef __FreeBSD__
  611. #define _DECLARE_C99_LDBL_MATH 1
  612. #endif
  613. #if defined(__APPLE__) || defined(__FreeBSD__)
  614. #define _LIBCPP_HAS_DEFAULTRUNELOCALE
  615. #endif
  616. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
  617. #define _LIBCPP_WCTYPE_IS_MASK
  618. #endif
  619. #ifndef _LIBCPP_STD_VER
  620. # if __cplusplus <= 201103L
  621. # define _LIBCPP_STD_VER 11
  622. # elif __cplusplus <= 201402L
  623. # define _LIBCPP_STD_VER 14
  624. # else
  625. # define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
  626. # endif
  627. #endif // _LIBCPP_STD_VER
  628. #if _LIBCPP_STD_VER > 11
  629. #define _LIBCPP_DEPRECATED [[deprecated]]
  630. #else
  631. #define _LIBCPP_DEPRECATED
  632. #endif
  633. #if _LIBCPP_STD_VER <= 11
  634. #define _LIBCPP_EXPLICIT_AFTER_CXX11
  635. #define _LIBCPP_DEPRECATED_AFTER_CXX11
  636. #else
  637. #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
  638. #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
  639. #endif
  640. #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  641. #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
  642. #else
  643. #define _LIBCPP_CONSTEXPR_AFTER_CXX11
  644. #endif
  645. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
  646. #define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
  647. #else
  648. #define _LIBCPP_CONSTEXPR_AFTER_CXX14
  649. #endif
  650. #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  651. # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
  652. #else
  653. # define _LIBCPP_EXPLICIT_MOVE(x) (x)
  654. #endif
  655. #ifndef _LIBCPP_HAS_NO_ASAN
  656. extern "C" void __sanitizer_annotate_contiguous_container(
  657. const void *, const void *, const void *, const void *);
  658. #endif
  659. // Try to find out if RTTI is disabled.
  660. // g++ and cl.exe have RTTI on by default and define a macro when it is.
  661. // g++ only defines the macro in 4.3.2 and onwards.
  662. #if !defined(_LIBCPP_NO_RTTI)
  663. # if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
  664. (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
  665. # define _LIBCPP_NO_RTTI
  666. # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
  667. # define _LIBCPP_NO_RTTI
  668. # endif
  669. #endif
  670. #ifndef _LIBCPP_WEAK
  671. # define _LIBCPP_WEAK __attribute__((__weak__))
  672. #endif
  673. // Thread API
  674. #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  675. # if defined(__FreeBSD__) || \
  676. defined(__NetBSD__) || \
  677. defined(__linux__) || \
  678. defined(__APPLE__) || \
  679. defined(__CloudABI__) || \
  680. defined(__sun__)
  681. # define _LIBCPP_HAS_THREAD_API_PTHREAD
  682. # else
  683. # error "No thread API"
  684. # endif // _LIBCPP_HAS_THREAD_API
  685. #endif // _LIBCPP_HAS_NO_THREADS
  686. #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
  687. # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
  688. _LIBCPP_HAS_NO_THREADS is not defined.
  689. #endif
  690. #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
  691. # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  692. _LIBCPP_HAS_NO_THREADS is defined.
  693. #endif
  694. // Systems that use capability-based security (FreeBSD with Capsicum,
  695. // Nuxi CloudABI) may only provide local filesystem access (using *at()).
  696. // Functions like open(), rename(), unlink() and stat() should not be
  697. // used, as they attempt to access the global filesystem namespace.
  698. #ifdef __CloudABI__
  699. #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
  700. #endif
  701. // CloudABI is intended for running networked services. Processes do not
  702. // have standard input and output channels.
  703. #ifdef __CloudABI__
  704. #define _LIBCPP_HAS_NO_STDIN
  705. #define _LIBCPP_HAS_NO_STDOUT
  706. #endif
  707. #if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC)
  708. #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
  709. #endif
  710. // Thread-unsafe functions such as strtok(), mbtowc() and localtime()
  711. // are not available.
  712. #ifdef __CloudABI__
  713. #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
  714. #endif
  715. #if __has_feature(cxx_atomic) || __has_extension(c_atomic)
  716. #define _LIBCPP_HAS_C_ATOMIC_IMP
  717. #elif _GNUC_VER > 407
  718. #define _LIBCPP_HAS_GCC_ATOMIC_IMP
  719. #endif
  720. #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
  721. || defined(_LIBCPP_HAS_NO_THREADS)
  722. #define _LIBCPP_HAS_NO_ATOMIC_HEADER
  723. #endif
  724. #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  725. #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
  726. #endif
  727. #if __cplusplus < 201103L
  728. #define _LIBCPP_CXX03_LANG
  729. #else
  730. #if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
  731. #error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
  732. #endif
  733. #endif
  734. #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
  735. && __has_attribute(acquire_capability))
  736. #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
  737. #endif
  738. #endif // __cplusplus
  739. #endif // _LIBCPP_CONFIG