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 11#ifndef _LIBCPP_CONFIG 12#define _LIBCPP_CONFIG 13 14#if defined(_MSC_VER) && !defined(__clang__) 15#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 16#endif 17 18#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 19#pragma GCC system_header 20#endif 21 22#ifdef __cplusplus 23 24#ifdef __GNUC__ 25#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) 26#else 27#define _GNUC_VER 0 28#endif 29 30#define _LIBCPP_VERSION 4000 31 32#ifndef _LIBCPP_ABI_VERSION 33#define _LIBCPP_ABI_VERSION 1 34#endif 35 36#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 37// Change short string representation so that string data starts at offset 0, 38// improving its alignment in some cases. 39#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 40// Fix deque iterator type in order to support incomplete types. 41#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 42// Fix undefined behavior in how std::list stores it's linked nodes. 43#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 44// Fix undefined behavior in how __tree stores its end and parent nodes. 45#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 46// Fix undefined behavior in how __hash_table stores it's pointer types 47#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 48#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 49#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 50#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD 51// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr 52// provided under the alternate keyword __nullptr, which changes the mangling 53// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. 54#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR 55// Define the `pointer_safety` enum as a C++11 strongly typed enumeration 56// instead of as a class simulating an enum. If this option is enabled 57// `pointer_safety` and `get_pointer_safety()` will no longer be available 58// in C++03. 59#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE 60#elif _LIBCPP_ABI_VERSION == 1 61#if !defined(_WIN32) 62// Enable compiling a definition of error_category() into the libc++ dylib. 63#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR 64#endif 65// Feature macros for disabling pre ABI v1 features. All of these options 66// are deprecated. 67#if defined(__FreeBSD__) 68#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 69#endif 70#endif 71 72#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 73#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ 74 use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead 75#endif 76 77#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y 78#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) 79 80#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) 81 82#if __cplusplus < 201103L 83#define _LIBCPP_CXX03_LANG 84#endif 85 86#ifndef __has_attribute 87#define __has_attribute(__x) 0 88#endif 89#ifndef __has_builtin 90#define __has_builtin(__x) 0 91#endif 92#ifndef __has_extension 93#define __has_extension(__x) 0 94#endif 95#ifndef __has_feature 96#define __has_feature(__x) 0 97#endif 98// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by 99// the compiler and '1' otherwise. 100#ifndef __is_identifier 101#define __is_identifier(__x) 1 102#endif 103 104#if defined(__clang__) 105#define _LIBCPP_COMPILER_CLANG 106# ifndef __apple_build_version__ 107# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) 108# endif 109#elif defined(__GNUC__) 110#define _LIBCPP_COMPILER_GCC 111#elif defined(_MSC_VER) 112#define _LIBCPP_COMPILER_MSVC 113#elif defined(__IBMCPP__) 114#define _LIBCPP_COMPILER_IBM 115#endif 116 117#ifndef _LIBCPP_CLANG_VER 118# define _LIBCPP_CLANG_VER 0 119#endif 120 121// FIXME: ABI detection should be done via compiler builtin macros. This 122// is just a placeholder until Clang implements such macros. For now assume 123// that Windows compilers pretending to be MSVC++ target the microsoft ABI. 124#if defined(_WIN32) && defined(_MSC_VER) 125# define _LIBCPP_ABI_MICROSOFT 126#else 127# define _LIBCPP_ABI_ITANIUM 128#endif 129 130// Need to detect which libc we're using if we're on Linux. 131#if defined(__linux__) 132#include <features.h> 133#if !defined(__GLIBC_PREREQ) 134#define __GLIBC_PREREQ(a, b) 0 135#endif // !defined(__GLIBC_PREREQ) 136#endif // defined(__linux__) 137 138#ifdef __LITTLE_ENDIAN__ 139#if __LITTLE_ENDIAN__ 140#define _LIBCPP_LITTLE_ENDIAN 1 141#define _LIBCPP_BIG_ENDIAN 0 142#endif // __LITTLE_ENDIAN__ 143#endif // __LITTLE_ENDIAN__ 144 145#ifdef __BIG_ENDIAN__ 146#if __BIG_ENDIAN__ 147#define _LIBCPP_LITTLE_ENDIAN 0 148#define _LIBCPP_BIG_ENDIAN 1 149#endif // __BIG_ENDIAN__ 150#endif // __BIG_ENDIAN__ 151 152#ifdef __BYTE_ORDER__ 153#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 154#define _LIBCPP_LITTLE_ENDIAN 1 155#define _LIBCPP_BIG_ENDIAN 0 156#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 157#define _LIBCPP_LITTLE_ENDIAN 0 158#define _LIBCPP_BIG_ENDIAN 1 159#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 160#endif // __BYTE_ORDER__ 161 162#ifdef __FreeBSD__ 163# include <sys/endian.h> 164# if _BYTE_ORDER == _LITTLE_ENDIAN 165# define _LIBCPP_LITTLE_ENDIAN 1 166# define _LIBCPP_BIG_ENDIAN 0 167# else // _BYTE_ORDER == _LITTLE_ENDIAN 168# define _LIBCPP_LITTLE_ENDIAN 0 169# define _LIBCPP_BIG_ENDIAN 1 170# endif // _BYTE_ORDER == _LITTLE_ENDIAN 171# ifndef __LONG_LONG_SUPPORTED 172# define _LIBCPP_HAS_NO_LONG_LONG 173# endif // __LONG_LONG_SUPPORTED 174#endif // __FreeBSD__ 175 176#ifdef __NetBSD__ 177# include <sys/endian.h> 178# if _BYTE_ORDER == _LITTLE_ENDIAN 179# define _LIBCPP_LITTLE_ENDIAN 1 180# define _LIBCPP_BIG_ENDIAN 0 181# else // _BYTE_ORDER == _LITTLE_ENDIAN 182# define _LIBCPP_LITTLE_ENDIAN 0 183# define _LIBCPP_BIG_ENDIAN 1 184# endif // _BYTE_ORDER == _LITTLE_ENDIAN 185# define _LIBCPP_HAS_QUICK_EXIT 186#endif // __NetBSD__ 187 188#if defined(_WIN32) 189# define _LIBCPP_WIN32API 1 190# define _LIBCPP_LITTLE_ENDIAN 1 191# define _LIBCPP_BIG_ENDIAN 0 192# define _LIBCPP_SHORT_WCHAR 1 193 194// If mingw not explicitly detected, assume using MS C runtime only. 195# ifndef __MINGW32__ 196# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library 197# endif 198# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) 199# define _LIBCPP_HAS_BITSCAN64 200# endif 201#endif // defined(_WIN32) 202 203#ifdef __sun__ 204# include <sys/isa_defs.h> 205# ifdef _LITTLE_ENDIAN 206# define _LIBCPP_LITTLE_ENDIAN 1 207# define _LIBCPP_BIG_ENDIAN 0 208# else 209# define _LIBCPP_LITTLE_ENDIAN 0 210# define _LIBCPP_BIG_ENDIAN 1 211# endif 212#endif // __sun__ 213 214#if defined(__CloudABI__) 215 // Certain architectures provide arc4random(). Prefer using 216 // arc4random() over /dev/{u,}random to make it possible to obtain 217 // random data even when using sandboxing mechanisms such as chroots, 218 // Capsicum, etc. 219# define _LIBCPP_USING_ARC4_RANDOM 220#elif defined(__native_client__) 221 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, 222 // including accesses to the special files under /dev. C++11's 223 // std::random_device is instead exposed through a NaCl syscall. 224# define _LIBCPP_USING_NACL_RANDOM 225#elif defined(_LIBCPP_WIN32API) 226# define _LIBCPP_USING_WIN32_RANDOM 227#else 228# define _LIBCPP_USING_DEV_RANDOM 229#endif 230 231#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) 232# include <endian.h> 233# if __BYTE_ORDER == __LITTLE_ENDIAN 234# define _LIBCPP_LITTLE_ENDIAN 1 235# define _LIBCPP_BIG_ENDIAN 0 236# elif __BYTE_ORDER == __BIG_ENDIAN 237# define _LIBCPP_LITTLE_ENDIAN 0 238# define _LIBCPP_BIG_ENDIAN 1 239# else // __BYTE_ORDER == __BIG_ENDIAN 240# error unable to determine endian 241# endif 242#endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) 243 244#if __has_attribute(__no_sanitize__) 245#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) 246#else 247#define _LIBCPP_NO_CFI 248#endif 249 250#if defined(_LIBCPP_COMPILER_CLANG) 251 252// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for 253// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. 254#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ 255 !defined(__arm__)) || \ 256 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) 257#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 258#endif 259 260#if __has_feature(cxx_alignas) 261# define _ALIGNAS_TYPE(x) alignas(x) 262# define _ALIGNAS(x) alignas(x) 263#else 264# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 265# define _ALIGNAS(x) __attribute__((__aligned__(x))) 266#endif 267 268#if __cplusplus < 201103L 269typedef __char16_t char16_t; 270typedef __char32_t char32_t; 271#endif 272 273#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) 274#define _LIBCPP_NO_EXCEPTIONS 275#endif 276 277#if !(__has_feature(cxx_rtti)) 278#define _LIBCPP_NO_RTTI 279#endif 280 281#if !(__has_feature(cxx_strong_enums)) 282#define _LIBCPP_HAS_NO_STRONG_ENUMS 283#endif 284 285#if !(__has_feature(cxx_decltype)) 286#define _LIBCPP_HAS_NO_DECLTYPE 287#endif 288 289#if __has_feature(cxx_attributes) 290# define _LIBCPP_NORETURN [[noreturn]] 291#else 292# define _LIBCPP_NORETURN __attribute__ ((noreturn)) 293#endif 294 295#if !(__has_feature(cxx_lambdas)) 296#define _LIBCPP_HAS_NO_LAMBDAS 297#endif 298 299#if !(__has_feature(cxx_nullptr)) 300# if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) 301# define nullptr __nullptr 302# else 303# define _LIBCPP_HAS_NO_NULLPTR 304# endif 305#endif 306 307#if !(__has_feature(cxx_rvalue_references)) 308#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 309#endif 310 311#if !(__has_feature(cxx_auto_type)) 312#define _LIBCPP_HAS_NO_AUTO_TYPE 313#endif 314 315#if !(__has_feature(cxx_variadic_templates)) 316#define _LIBCPP_HAS_NO_VARIADICS 317#endif 318 319#if !(__has_feature(cxx_generalized_initializers)) 320#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 321#endif 322 323#if __has_feature(is_base_of) 324# define _LIBCPP_HAS_IS_BASE_OF 325#endif 326 327#if __has_feature(is_final) 328# define _LIBCPP_HAS_IS_FINAL 329#endif 330 331// Objective-C++ features (opt-in) 332#if __has_feature(objc_arc) 333#define _LIBCPP_HAS_OBJC_ARC 334#endif 335 336#if __has_feature(objc_arc_weak) 337#define _LIBCPP_HAS_OBJC_ARC_WEAK 338#define _LIBCPP_HAS_NO_STRONG_ENUMS 339#endif 340 341#if !(__has_feature(cxx_constexpr)) 342#define _LIBCPP_HAS_NO_CONSTEXPR 343#endif 344 345#if !(__has_feature(cxx_relaxed_constexpr)) 346#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 347#endif 348 349#if !(__has_feature(cxx_variable_templates)) 350#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 351#endif 352 353#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L 354#if defined(__FreeBSD__) 355#define _LIBCPP_HAS_QUICK_EXIT 356#define _LIBCPP_HAS_C11_FEATURES 357#elif defined(__Fuchsia__) 358#define _LIBCPP_HAS_QUICK_EXIT 359#define _LIBCPP_HAS_C11_FEATURES 360#elif defined(__linux__) 361#if !defined(_LIBCPP_HAS_MUSL_LIBC) 362#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__) 363#define _LIBCPP_HAS_QUICK_EXIT 364#endif 365#if __GLIBC_PREREQ(2, 17) 366#define _LIBCPP_HAS_C11_FEATURES 367#endif 368#else // defined(_LIBCPP_HAS_MUSL_LIBC) 369#define _LIBCPP_HAS_QUICK_EXIT 370#define _LIBCPP_HAS_C11_FEATURES 371#endif 372#endif // __linux__ 373#endif 374 375#if !(__has_feature(cxx_noexcept)) 376#define _LIBCPP_HAS_NO_NOEXCEPT 377#endif 378 379#if __has_feature(underlying_type) 380# define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) 381#endif 382 383#if __has_feature(is_literal) 384# define _LIBCPP_IS_LITERAL(T) __is_literal(T) 385#endif 386 387// Inline namespaces are available in Clang regardless of C++ dialect. 388#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { 389#define _LIBCPP_END_NAMESPACE_STD } } 390#define _VSTD std::_LIBCPP_NAMESPACE 391 392namespace std { 393 inline namespace _LIBCPP_NAMESPACE { 394 } 395} 396 397#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) 398#define _LIBCPP_HAS_NO_ASAN 399#endif 400 401// Allow for build-time disabling of unsigned integer sanitization 402#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) 403#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) 404#endif 405 406#elif defined(_LIBCPP_COMPILER_GCC) 407 408#define _ALIGNAS(x) __attribute__((__aligned__(x))) 409#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 410 411#define _LIBCPP_NORETURN __attribute__((noreturn)) 412 413#if _GNUC_VER >= 407 414#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) 415#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) 416#define _LIBCPP_HAS_IS_FINAL 417#endif 418 419#if defined(__GNUC__) && _GNUC_VER >= 403 420# define _LIBCPP_HAS_IS_BASE_OF 421#endif 422 423#if !__EXCEPTIONS 424#define _LIBCPP_NO_EXCEPTIONS 425#endif 426 427// constexpr was added to GCC in 4.6. 428#if _GNUC_VER < 406 429#define _LIBCPP_HAS_NO_CONSTEXPR 430// Can only use constexpr in c++11 mode. 431#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L 432#define _LIBCPP_HAS_NO_CONSTEXPR 433#endif 434 435// Determine if GCC supports relaxed constexpr 436#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L 437#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 438#endif 439 440// GCC 5 will support variable templates 441#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L 442#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 443#endif 444 445#ifndef __GXX_EXPERIMENTAL_CXX0X__ 446#define _LIBCPP_HAS_NO_DECLTYPE 447#define _LIBCPP_HAS_NO_NULLPTR 448#define _LIBCPP_HAS_NO_UNICODE_CHARS 449#define _LIBCPP_HAS_NO_VARIADICS 450#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 451#define _LIBCPP_HAS_NO_STRONG_ENUMS 452#define _LIBCPP_HAS_NO_NOEXCEPT 453 454#else // __GXX_EXPERIMENTAL_CXX0X__ 455 456#if _GNUC_VER < 403 457#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 458#endif 459 460 461#if _GNUC_VER < 404 462#define _LIBCPP_HAS_NO_DECLTYPE 463#define _LIBCPP_HAS_NO_UNICODE_CHARS 464#define _LIBCPP_HAS_NO_VARIADICS 465#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 466#endif // _GNUC_VER < 404 467 468#if _GNUC_VER < 406 469#define _LIBCPP_HAS_NO_NOEXCEPT 470#define _LIBCPP_HAS_NO_NULLPTR 471#endif 472 473#endif // __GXX_EXPERIMENTAL_CXX0X__ 474 475#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { 476#define _LIBCPP_END_NAMESPACE_STD } } 477#define _VSTD std::_LIBCPP_NAMESPACE 478 479namespace std { 480namespace _LIBCPP_NAMESPACE { 481} 482using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); 483} 484 485#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) 486#define _LIBCPP_HAS_NO_ASAN 487#endif 488 489#elif defined(_LIBCPP_COMPILER_MSVC) 490 491#define _LIBCPP_TOSTRING2(x) #x 492#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) 493#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) 494 495#if _MSC_VER < 1900 496#error "MSVC versions prior to Visual Studio 2015 are not supported" 497#endif 498 499#define _LIBCPP_HAS_IS_BASE_OF 500#define _LIBCPP_HAS_NO_CONSTEXPR 501#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR 502#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 503#if _MSC_VER <= 1800 504#define _LIBCPP_HAS_NO_UNICODE_CHARS 505#endif 506#define _LIBCPP_HAS_NO_NOEXCEPT 507#define __alignof__ __alignof 508#define _LIBCPP_NORETURN __declspec(noreturn) 509#define _ALIGNAS(x) __declspec(align(x)) 510#define _LIBCPP_HAS_NO_VARIADICS 511 512#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { 513#define _LIBCPP_END_NAMESPACE_STD } 514#define _VSTD std 515 516# define _LIBCPP_WEAK 517namespace std { 518} 519 520#define _LIBCPP_HAS_NO_ASAN 521 522#elif defined(_LIBCPP_COMPILER_IBM) 523 524#define _ALIGNAS(x) __attribute__((__aligned__(x))) 525#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 526#define _ATTRIBUTE(x) __attribute__((x)) 527#define _LIBCPP_NORETURN __attribute__((noreturn)) 528 529#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 530#define _LIBCPP_HAS_NO_NOEXCEPT 531#define _LIBCPP_HAS_NO_NULLPTR 532#define _LIBCPP_HAS_NO_UNICODE_CHARS 533#define _LIBCPP_HAS_IS_BASE_OF 534#define _LIBCPP_HAS_IS_FINAL 535#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES 536 537#if defined(_AIX) 538#define __MULTILOCALE_API 539#endif 540 541#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { 542#define _LIBCPP_END_NAMESPACE_STD } } 543#define _VSTD std::_LIBCPP_NAMESPACE 544 545namespace std { 546 inline namespace _LIBCPP_NAMESPACE { 547 } 548} 549 550#define _LIBCPP_HAS_NO_ASAN 551 552#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] 553 554#if defined(__ELF__) 555#define _LIBCPP_OBJECT_FORMAT_ELF 1 556#elif defined(__MACH__) 557#define _LIBCPP_OBJECT_FORMAT_MACHO 1 558#else 559#define _LIBCPP_OBJECT_FORMAT_COFF 1 560#endif 561 562#if defined(_LIBCPP_OBJECT_FORMAT_COFF) 563#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 564# define _LIBCPP_DLL_VIS 565# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 566# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 567# define _LIBCPP_OVERRIDABLE_FUNC_VIS 568#elif defined(_LIBCPP_BUILDING_LIBRARY) 569# define _LIBCPP_DLL_VIS __declspec(dllexport) 570# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 571# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS 572# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS 573#else 574# define _LIBCPP_DLL_VIS __declspec(dllimport) 575# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS 576# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 577# define _LIBCPP_OVERRIDABLE_FUNC_VIS 578#endif 579 580#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS 581#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS 582#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS 583#define _LIBCPP_HIDDEN 584#define _LIBCPP_TEMPLATE_VIS 585#define _LIBCPP_FUNC_VIS_ONLY 586#define _LIBCPP_ENUM_VIS 587 588#if defined(_LIBCPP_COMPILER_MSVC) 589# define _LIBCPP_INLINE_VISIBILITY __forceinline 590# define _LIBCPP_ALWAYS_INLINE __forceinline 591# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline 592#else 593# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) 594# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 595# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__)) 596#endif 597#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) 598 599#ifndef _LIBCPP_HIDDEN 600#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 601#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) 602#else 603#define _LIBCPP_HIDDEN 604#endif 605#endif 606 607#ifndef _LIBCPP_FUNC_VIS 608#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 609#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) 610#else 611#define _LIBCPP_FUNC_VIS 612#endif 613#endif 614 615#ifndef _LIBCPP_TYPE_VIS 616# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 617# if __has_attribute(__type_visibility__) 618# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) 619# else 620# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) 621# endif 622# else 623# define _LIBCPP_TYPE_VIS 624# endif 625#endif 626 627#ifndef _LIBCPP_TEMPLATE_VIS 628# define _LIBCPP_TEMPLATE_VIS _LIBCPP_TYPE_VIS 629#endif 630 631#ifndef _LIBCPP_FUNC_VIS_ONLY 632# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS 633#endif 634 635#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS 636# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS 637#endif 638 639#ifndef _LIBCPP_EXCEPTION_ABI 640#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 641#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) 642#else 643#define _LIBCPP_EXCEPTION_ABI 644#endif 645#endif 646 647#ifndef _LIBCPP_ENUM_VIS 648# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 649# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) 650# else 651# define _LIBCPP_ENUM_VIS 652# endif 653#endif 654 655#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 656# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) 657# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default"))) 658# else 659# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 660# endif 661#endif 662 663#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 664# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 665#endif 666 667#ifndef _LIBCPP_INLINE_VISIBILITY 668#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 669#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) 670#else 671#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) 672#endif 673#endif 674 675#ifndef _LIBCPP_ALWAYS_INLINE 676#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 677#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) 678#else 679#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) 680#endif 681#endif 682 683#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 684# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 685# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) 686# else 687# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__)) 688# endif 689#endif 690 691#ifndef _LIBCPP_PREFERRED_OVERLOAD 692# if __has_attribute(__enable_if__) 693# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) 694# endif 695#endif 696 697#ifndef _LIBCPP_HAS_NO_NOEXCEPT 698# define _NOEXCEPT noexcept 699# define _NOEXCEPT_(x) noexcept(x) 700#else 701# define _NOEXCEPT throw() 702# define _NOEXCEPT_(x) 703#endif 704 705#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) 706# if !defined(_LIBCPP_DEBUG) 707# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined 708# endif 709# define _NOEXCEPT_DEBUG noexcept(false) 710# define _NOEXCEPT_DEBUG_(x) noexcept(false) 711#else 712# define _NOEXCEPT_DEBUG _NOEXCEPT 713# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x) 714#endif 715 716#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS 717typedef unsigned short char16_t; 718typedef unsigned int char32_t; 719#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 720 721#ifndef __SIZEOF_INT128__ 722#define _LIBCPP_HAS_NO_INT128 723#endif 724 725#ifdef _LIBCPP_CXX03_LANG 726# if __has_extension(c_static_assert) 727# define static_assert(__b, __m) _Static_assert(__b, __m) 728# else 729extern "C++" { 730template <bool> struct __static_assert_test; 731template <> struct __static_assert_test<true> {}; 732template <unsigned> struct __static_assert_check {}; 733} 734#define static_assert(__b, __m) \ 735 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \ 736 _LIBCPP_CONCAT(__t, __LINE__) 737# endif // __has_extension(c_static_assert) 738#endif // _LIBCPP_CXX03_LANG 739 740#ifdef _LIBCPP_HAS_NO_DECLTYPE 741// GCC 4.6 provides __decltype in all standard modes. 742#if !__is_identifier(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406 743# define decltype(__x) __decltype(__x) 744#else 745# define decltype(__x) __typeof__(__x) 746#endif 747#endif 748 749#ifdef _LIBCPP_HAS_NO_CONSTEXPR 750#define _LIBCPP_CONSTEXPR 751#else 752#define _LIBCPP_CONSTEXPR constexpr 753#endif 754 755#ifdef _LIBCPP_CXX03_LANG 756#define _LIBCPP_DEFAULT {} 757#else 758#define _LIBCPP_DEFAULT = default; 759#endif 760 761#ifdef _LIBCPP_CXX03_LANG 762#define _LIBCPP_EQUAL_DELETE 763#else 764#define _LIBCPP_EQUAL_DELETE = delete 765#endif 766 767#ifdef __GNUC__ 768#define _NOALIAS __attribute__((__malloc__)) 769#else 770#define _NOALIAS 771#endif 772 773#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ 774 (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions 775# define _LIBCPP_EXPLICIT explicit 776#else 777# define _LIBCPP_EXPLICIT 778#endif 779 780#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) 781# define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE 782#endif 783 784#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 785#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx 786#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 787 __lx __v_; \ 788 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \ 789 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 790 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ 791 }; 792#else // _LIBCPP_HAS_NO_STRONG_ENUMS 793#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x 794#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 795#endif // _LIBCPP_HAS_NO_STRONG_ENUMS 796 797#ifdef _LIBCPP_DEBUG 798# if _LIBCPP_DEBUG == 0 799# define _LIBCPP_DEBUG_LEVEL 1 800# elif _LIBCPP_DEBUG == 1 801# define _LIBCPP_DEBUG_LEVEL 2 802# else 803# error Supported values for _LIBCPP_DEBUG are 0 and 1 804# endif 805# define _LIBCPP_EXTERN_TEMPLATE(...) 806#endif 807 808#ifndef _LIBCPP_EXTERN_TEMPLATE 809#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; 810#endif 811 812#ifndef _LIBCPP_EXTERN_TEMPLATE2 813#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; 814#endif 815 816#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) 817#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) 818#endif 819 820#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \ 821 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) 822#define _LIBCPP_LOCALE__L_EXTENSIONS 1 823#endif 824 825#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 826// Most unix variants have catopen. These are the specific ones that don't. 827#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) 828#define _LIBCPP_HAS_CATOPEN 1 829#endif 830#endif 831 832#ifdef __FreeBSD__ 833#define _DECLARE_C99_LDBL_MATH 1 834#endif 835 836#if defined(__APPLE__) 837# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ 838 defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) 839# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 840# endif 841# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 842# if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 843# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION 844# endif 845# endif 846#endif // defined(__APPLE__) 847 848#if defined(__APPLE__) || defined(__FreeBSD__) 849#define _LIBCPP_HAS_DEFAULTRUNELOCALE 850#endif 851 852#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 853#define _LIBCPP_WCTYPE_IS_MASK 854#endif 855 856#ifndef _LIBCPP_STD_VER 857# if __cplusplus <= 201103L 858# define _LIBCPP_STD_VER 11 859# elif __cplusplus <= 201402L 860# define _LIBCPP_STD_VER 14 861# else 862# define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification 863# endif 864#endif // _LIBCPP_STD_VER 865 866#if _LIBCPP_STD_VER > 11 867#define _LIBCPP_DEPRECATED [[deprecated]] 868#else 869#define _LIBCPP_DEPRECATED 870#endif 871 872#if _LIBCPP_STD_VER <= 11 873#define _LIBCPP_EXPLICIT_AFTER_CXX11 874#define _LIBCPP_DEPRECATED_AFTER_CXX11 875#else 876#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit 877#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] 878#endif 879 880#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 881#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr 882#else 883#define _LIBCPP_CONSTEXPR_AFTER_CXX11 884#endif 885 886#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) 887#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr 888#else 889#define _LIBCPP_CONSTEXPR_AFTER_CXX14 890#endif 891 892// FIXME: Remove all usages of this macro once compilers catch up. 893#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L) 894# define _LIBCPP_HAS_NO_INLINE_VARIABLES 895#endif 896 897#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 898# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) 899#else 900# define _LIBCPP_EXPLICIT_MOVE(x) (x) 901#endif 902 903#ifndef _LIBCPP_HAS_NO_ASAN 904_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( 905 const void *, const void *, const void *, const void *); 906#endif 907 908// Try to find out if RTTI is disabled. 909// g++ and cl.exe have RTTI on by default and define a macro when it is. 910// g++ only defines the macro in 4.3.2 and onwards. 911#if !defined(_LIBCPP_NO_RTTI) 912# if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ 913 (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) 914# define _LIBCPP_NO_RTTI 915# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) 916# define _LIBCPP_NO_RTTI 917# endif 918#endif 919 920#ifndef _LIBCPP_WEAK 921# define _LIBCPP_WEAK __attribute__((__weak__)) 922#endif 923 924// Thread API 925#if !defined(_LIBCPP_HAS_NO_THREADS) && \ 926 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 927# if defined(__FreeBSD__) || \ 928 defined(__Fuchsia__) || \ 929 defined(__NetBSD__) || \ 930 defined(__linux__) || \ 931 defined(__APPLE__) || \ 932 defined(__CloudABI__) || \ 933 defined(__sun__) 934# define _LIBCPP_HAS_THREAD_API_PTHREAD 935# elif defined(_LIBCPP_WIN32API) 936# define _LIBCPP_HAS_THREAD_API_WIN32 937# else 938# error "No thread API" 939# endif // _LIBCPP_HAS_THREAD_API 940#endif // _LIBCPP_HAS_NO_THREADS 941 942#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) 943# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ 944 _LIBCPP_HAS_NO_THREADS is not defined. 945#endif 946 947#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) 948# error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \ 949 _LIBCPP_HAS_NO_THREADS is defined. 950#endif 951 952#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) 953# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ 954 _LIBCPP_HAS_NO_THREADS is defined. 955#endif 956 957// Systems that use capability-based security (FreeBSD with Capsicum, 958// Nuxi CloudABI) may only provide local filesystem access (using *at()). 959// Functions like open(), rename(), unlink() and stat() should not be 960// used, as they attempt to access the global filesystem namespace. 961#ifdef __CloudABI__ 962#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 963#endif 964 965// CloudABI is intended for running networked services. Processes do not 966// have standard input and output channels. 967#ifdef __CloudABI__ 968#define _LIBCPP_HAS_NO_STDIN 969#define _LIBCPP_HAS_NO_STDOUT 970#endif 971 972#if defined(__BIONIC__) || defined(__CloudABI__) || \ 973 defined(_LIBCPP_HAS_MUSL_LIBC) 974#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE 975#endif 976 977// Thread-unsafe functions such as strtok() and localtime() 978// are not available. 979#ifdef __CloudABI__ 980#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS 981#endif 982 983#if __has_feature(cxx_atomic) || __has_extension(c_atomic) 984#define _LIBCPP_HAS_C_ATOMIC_IMP 985#elif _GNUC_VER > 407 986#define _LIBCPP_HAS_GCC_ATOMIC_IMP 987#endif 988 989#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ 990 || defined(_LIBCPP_HAS_NO_THREADS) 991#define _LIBCPP_HAS_NO_ATOMIC_HEADER 992#endif 993 994#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 995#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 996#endif 997 998#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \ 999 && __has_attribute(acquire_capability)) 1000#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1001#endif 1002 1003#if __has_attribute(require_constant_initialization) 1004#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) 1005#else 1006#define _LIBCPP_SAFE_STATIC 1007#endif 1008 1009#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 1010#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF 1011#endif 1012 1013#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) 1014#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) 1015#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS 1016#endif 1017#endif 1018 1019#endif // __cplusplus 1020 1021#endif // _LIBCPP_CONFIG 1022