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#ifndef _MSC_VER // explicit macro necessary because it is only defined below in this file 15#pragma GCC system_header 16#endif 17 18#ifdef __GNUC__ 19#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) 20#endif 21 22#define _LIBCPP_VERSION 1101 23 24#define _LIBCPP_ABI_VERSION 1 25 26#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y 27#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) 28 29#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) 30 31#ifdef __LITTLE_ENDIAN__ 32#if __LITTLE_ENDIAN__ 33#define _LIBCPP_LITTLE_ENDIAN 1 34#define _LIBCPP_BIG_ENDIAN 0 35#endif // __LITTLE_ENDIAN__ 36#endif // __LITTLE_ENDIAN__ 37 38#ifdef __BIG_ENDIAN__ 39#if __BIG_ENDIAN__ 40#define _LIBCPP_LITTLE_ENDIAN 0 41#define _LIBCPP_BIG_ENDIAN 1 42#endif // __BIG_ENDIAN__ 43#endif // __BIG_ENDIAN__ 44 45#ifdef __FreeBSD__ 46# include <sys/endian.h> 47# if _BYTE_ORDER == _LITTLE_ENDIAN 48# define _LIBCPP_LITTLE_ENDIAN 1 49# define _LIBCPP_BIG_ENDIAN 0 50# else // _BYTE_ORDER == _LITTLE_ENDIAN 51# define _LIBCPP_LITTLE_ENDIAN 0 52# define _LIBCPP_BIG_ENDIAN 1 53# endif // _BYTE_ORDER == _LITTLE_ENDIAN 54# ifndef __LONG_LONG_SUPPORTED 55# define _LIBCPP_HAS_NO_LONG_LONG 56# endif // __LONG_LONG_SUPPORTED 57#endif // __FreeBSD__ 58 59#ifdef _WIN32 60# define _LIBCPP_LITTLE_ENDIAN 1 61# define _LIBCPP_BIG_ENDIAN 0 62// Compiler intrinsics (GCC or MSVC) 63# if (defined(_MSC_VER) && _MSC_VER >= 1400) \ 64 || (defined(__GNUC__) && _GNUC_VER > 403) 65# define _LIBCP_HAS_IS_BASE_OF 66# endif 67#endif // _WIN32 68 69#ifdef __linux__ 70# if defined(__GNUC__) && _GNUC_VER >= 403 71# define _LIBCP_HAS_IS_BASE_OF 72# endif 73#endif 74 75#ifdef __sun__ 76# include <sys/isa_defs.h> 77# ifdef _LITTLE_ENDIAN 78# define _LIBCPP_LITTLE_ENDIAN 1 79# define _LIBCPP_BIG_ENDIAN 0 80# else 81# define _LIBCPP_LITTLE_ENDIAN 0 82# define _LIBCPP_BIG_ENDIAN 1 83# endif 84#endif // __sun__ 85 86#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) 87# include <endian.h> 88# if __BYTE_ORDER == __LITTLE_ENDIAN 89# define _LIBCPP_LITTLE_ENDIAN 1 90# define _LIBCPP_BIG_ENDIAN 0 91# elif __BYTE_ORDER == __BIG_ENDIAN 92# define _LIBCPP_LITTLE_ENDIAN 0 93# define _LIBCPP_BIG_ENDIAN 1 94# else // __BYTE_ORDER == __BIG_ENDIAN 95# error unable to determine endian 96# endif 97#endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) 98 99#ifdef _WIN32 100 101// only really useful for a DLL 102#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally... 103# ifdef cxx_EXPORTS 104# define _LIBCPP_HIDDEN 105# define _LIBCPP_FUNC_VIS __declspec(dllexport) 106# define _LIBCPP_TYPE_VIS __declspec(dllexport) 107# else 108# define _LIBCPP_HIDDEN 109# define _LIBCPP_FUNC_VIS __declspec(dllimport) 110# define _LIBCPP_TYPE_VIS __declspec(dllimport) 111# endif 112#else 113# define _LIBCPP_HIDDEN 114# define _LIBCPP_FUNC_VIS 115# define _LIBCPP_TYPE_VIS 116#endif 117 118#ifndef _LIBCPP_INLINE_VISIBILITY 119# ifdef _MSC_VER 120# define _LIBCPP_INLINE_VISIBILITY __forceinline 121# else // MinGW GCC and Clang 122# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) 123# endif 124#endif 125 126#ifndef _LIBCPP_EXCEPTION_ABI 127#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS 128#endif 129 130#ifndef _LIBCPP_ALWAYS_INLINE 131# ifdef _MSC_VER 132# define _LIBCPP_ALWAYS_INLINE __forceinline 133# endif 134#endif 135 136#endif // _WIN32 137 138#ifndef __has_attribute 139#define __has_attribute(__x) 0 140#endif 141 142#ifndef _LIBCPP_HIDDEN 143#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) 144#endif 145 146#ifndef _LIBCPP_FUNC_VIS 147#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) 148#endif 149 150#ifndef _LIBCPP_TYPE_VIS 151# if __has_attribute(type_visibility) 152# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) 153# else 154# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) 155# endif 156#endif 157 158#ifndef _LIBCPP_INLINE_VISIBILITY 159#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) 160#endif 161 162#ifndef _LIBCPP_EXCEPTION_ABI 163#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS 164#endif 165 166#ifndef _LIBCPP_CANTTHROW 167#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) 168#endif 169 170#ifndef _LIBCPP_ALWAYS_INLINE 171#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) 172#endif 173 174#if defined(__clang__) 175 176#if __has_feature(cxx_alignas) 177# define _ALIGNAS_TYPE(x) alignas(x) 178# define _ALIGNAS(x) alignas(x) 179#else 180# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 181# define _ALIGNAS(x) __attribute__((__aligned__(x))) 182#endif 183 184#if !__has_feature(cxx_alias_templates) 185#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 186#endif 187 188#ifndef __GXX_EXPERIMENTAL_CXX0X__ 189#ifdef __linux__ 190#define _LIBCPP_HAS_NO_UNICODE_CHARS 191#else 192typedef __char16_t char16_t; 193typedef __char32_t char32_t; 194#endif 195#endif 196 197#if !(__has_feature(cxx_exceptions)) 198#define _LIBCPP_NO_EXCEPTIONS 199#endif 200 201#if !(__has_feature(cxx_rtti)) 202#define _LIBCPP_NO_RTTI 203#endif 204 205#if !(__has_feature(cxx_strong_enums)) 206#define _LIBCPP_HAS_NO_STRONG_ENUMS 207#endif 208 209#if !(__has_feature(cxx_decltype)) 210#define _LIBCPP_HAS_NO_DECLTYPE 211#endif 212 213#if __has_feature(cxx_attributes) 214# define _LIBCPP_NORETURN [[noreturn]] 215#else 216# define _LIBCPP_NORETURN __attribute__ ((noreturn)) 217#endif 218 219#if !(__has_feature(cxx_defaulted_functions)) 220#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 221#endif // !(__has_feature(cxx_defaulted_functions)) 222 223#if !(__has_feature(cxx_deleted_functions)) 224#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 225#endif // !(__has_feature(cxx_deleted_functions)) 226 227#if !(__has_feature(cxx_lambdas)) 228#define _LIBCPP_HAS_NO_LAMBDAS 229#endif 230 231#if !(__has_feature(cxx_nullptr)) 232#define _LIBCPP_HAS_NO_NULLPTR 233#endif 234 235#if !(__has_feature(cxx_rvalue_references)) 236#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 237#endif 238 239#if !(__has_feature(cxx_static_assert)) 240#define _LIBCPP_HAS_NO_STATIC_ASSERT 241#endif 242 243#if !(__has_feature(cxx_auto_type)) 244#define _LIBCPP_HAS_NO_AUTO_TYPE 245#endif 246 247#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return) 248#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 249#endif 250 251#if !(__has_feature(cxx_variadic_templates)) 252#define _LIBCPP_HAS_NO_VARIADICS 253#endif 254 255#if !(__has_feature(cxx_trailing_return)) 256#define _LIBCPP_HAS_NO_TRAILING_RETURN 257#endif 258 259#if !(__has_feature(cxx_generalized_initializers)) 260#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 261#endif 262 263#if __has_feature(is_base_of) 264# define _LIBCP_HAS_IS_BASE_OF 265#endif 266 267// Objective-C++ features (opt-in) 268#if __has_feature(objc_arc) 269#define _LIBCPP_HAS_OBJC_ARC 270#endif 271 272#if __has_feature(objc_arc_weak) 273#define _LIBCPP_HAS_OBJC_ARC_WEAK 274#define _LIBCPP_HAS_NO_STRONG_ENUMS 275#endif 276 277#if !(__has_feature(cxx_constexpr)) 278#define _LIBCPP_HAS_NO_CONSTEXPR 279#endif 280 281#if ( defined(__FreeBSD__) || defined(__linux__) ) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L) 282#define _LIBCPP_HAS_QUICK_EXIT 283#define _LIBCPP_HAS_C11_FEATURES 284#endif 285 286#if (__has_feature(cxx_noexcept)) 287# define _NOEXCEPT noexcept 288# define _NOEXCEPT_(x) noexcept(x) 289#else 290# define _NOEXCEPT throw() 291# define _NOEXCEPT_(x) 292#endif 293 294#if __has_feature(underlying_type) 295# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T) 296#endif 297 298// Inline namespaces are available in Clang regardless of C++ dialect. 299#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { 300#define _LIBCPP_END_NAMESPACE_STD } } 301#define _VSTD std::_LIBCPP_NAMESPACE 302 303namespace std { 304 inline namespace _LIBCPP_NAMESPACE { 305 } 306} 307 308#elif defined(__GNUC__) 309 310#define _ALIGNAS(x) __attribute__((__aligned__(x))) 311#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 312 313#define _LIBCPP_NORETURN __attribute__((noreturn)) 314 315#if !__EXCEPTIONS 316#define _LIBCPP_NO_EXCEPTIONS 317#endif 318 319#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 320#define _LIBCPP_HAS_NO_CONSTEXPR 321 322#define _NOEXCEPT throw() 323#define _NOEXCEPT_(x) 324 325#ifndef __GXX_EXPERIMENTAL_CXX0X__ 326 327#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 328#define _LIBCPP_HAS_NO_DECLTYPE 329#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 330#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 331#define _LIBCPP_HAS_NO_NULLPTR 332#define _LIBCPP_HAS_NO_STATIC_ASSERT 333#define _LIBCPP_HAS_NO_UNICODE_CHARS 334#define _LIBCPP_HAS_NO_VARIADICS 335#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 336#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS 337 338#else // __GXX_EXPERIMENTAL_CXX0X__ 339 340#define _LIBCPP_HAS_NO_TRAILING_RETURN 341#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS 342 343#if _GNUC_VER < 403 344#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 345#endif 346 347#if _GNUC_VER < 403 348#define _LIBCPP_HAS_NO_STATIC_ASSERT 349#endif 350 351#if _GNUC_VER < 404 352#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 353#define _LIBCPP_HAS_NO_DECLTYPE 354#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 355#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 356#define _LIBCPP_HAS_NO_UNICODE_CHARS 357#define _LIBCPP_HAS_NO_VARIADICS 358#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 359#endif // _GNUC_VER < 404 360 361#if _GNUC_VER < 406 362#define _LIBCPP_HAS_NO_NULLPTR 363#endif 364 365#endif // __GXX_EXPERIMENTAL_CXX0X__ 366 367#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { 368#define _LIBCPP_END_NAMESPACE_STD } } 369#define _VSTD std::_LIBCPP_NAMESPACE 370 371namespace std { 372namespace _LIBCPP_NAMESPACE { 373} 374using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); 375} 376 377#elif defined(_MSC_VER) 378 379#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 380#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 381#define _LIBCPP_HAS_NO_CONSTEXPR 382#define _LIBCPP_HAS_NO_UNICODE_CHARS 383#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 384#define __alignof__ __alignof 385#define _LIBCPP_NORETURN __declspec(noreturn) 386#define _ALIGNAS(x) __declspec(align(x)) 387#define _LIBCPP_HAS_NO_VARIADICS 388 389#define _NOEXCEPT throw() 390#define _NOEXCEPT_(x) 391 392#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { 393#define _LIBCPP_END_NAMESPACE_STD } 394#define _VSTD std 395 396namespace std { 397} 398 399#endif // __clang__ || __GNUC___ || _MSC_VER 400 401#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS 402typedef unsigned short char16_t; 403typedef unsigned int char32_t; 404#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 405 406#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT 407 408template <bool> struct __static_assert_test; 409template <> struct __static_assert_test<true> {}; 410template <unsigned> struct __static_assert_check {}; 411#define static_assert(__b, __m) \ 412 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \ 413 _LIBCPP_CONCAT(__t, __LINE__) 414 415#endif // _LIBCPP_HAS_NO_STATIC_ASSERT 416 417#ifdef _LIBCPP_HAS_NO_DECLTYPE 418#define decltype(x) __typeof__(x) 419#endif 420 421#ifdef _LIBCPP_HAS_NO_CONSTEXPR 422#define _LIBCPP_CONSTEXPR 423#else 424#define _LIBCPP_CONSTEXPR constexpr 425#endif 426 427#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 428#define _LIBCPP_DEFAULT {} 429#else 430#define _LIBCPP_DEFAULT = default; 431#endif 432 433#ifdef __GNUC__ 434#define _NOALIAS __attribute__((__malloc__)) 435#else 436#define _NOALIAS 437#endif 438 439#ifndef __has_feature 440#define __has_feature(__x) 0 441#endif 442 443#if __has_feature(cxx_explicit_conversions) 444# define _LIBCPP_EXPLICIT explicit 445#else 446# define _LIBCPP_EXPLICIT 447#endif 448 449#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 450#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx 451#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 452 __lx __v_; \ 453 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \ 454 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 455 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ 456 }; 457#else // _LIBCPP_HAS_NO_STRONG_ENUMS 458#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x 459#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 460#endif // _LIBCPP_HAS_NO_STRONG_ENUMS 461 462#ifndef _LIBCPP_EXTERN_TEMPLATE 463#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; 464#endif 465 466#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) 467#define _LIBCPP_LOCALE__L_EXTENSIONS 1 468#endif 469#ifdef __FreeBSD__ 470#define _DECLARE_C99_LDBL_MATH 1 471#endif 472 473#if defined(__APPLE__) || defined(__FreeBSD__) 474#define _LIBCPP_HAS_DEFAULTRUNELOCALE 475#endif 476 477#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) 478#define _LIBCPP_WCTYPE_IS_MASK 479#endif 480 481#ifdef _LIBCPP_DEBUG2 482# if _LIBCPP_DEBUG2 == 0 483# define _LIBCPP_DEBUG_LEVEL 1 484# elif _LIBCPP_DEBUG2 == 1 485# define _LIBCPP_DEBUG_LEVEL 2 486# else 487# error Supported values for _LIBCPP_DEBUG2 are 0 and 1 488# endif 489#endif 490 491#ifndef _LIBCPP_STD_VER 492# if __cplusplus <= 201103L 493# define _LIBCPP_STD_VER 11 494# else 495# define _LIBCPP_STD_VER 13 // current year, or date of c++14 ratification 496# endif 497#endif // _LIBCPP_STD_VER 498 499#ifdef _LIBCPP_DEBUG2 500# include <__debug> 501#else 502# define _LIBCPP_ASSERT(x, m) ((void)0) 503#endif 504 505#endif // _LIBCPP_CONFIG 506