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 !_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#if _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_VISIBLE __declspec(dllexport) 106# else 107# define _LIBCPP_HIDDEN 108# define _LIBCPP_VISIBLE __declspec(dllimport) 109# endif 110#else 111# define _LIBCPP_HIDDEN 112# define _LIBCPP_VISIBLE 113#endif 114 115#ifndef _LIBCPP_INLINE_VISIBILITY 116# if _MSC_VER 117# define _LIBCPP_INLINE_VISIBILITY __forceinline 118# else // MinGW GCC and Clang 119# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) 120# endif 121#endif 122 123#ifndef _LIBCPP_EXCEPTION_ABI 124#define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE 125#endif 126 127#ifndef _LIBCPP_ALWAYS_INLINE 128# if _MSC_VER 129# define _LIBCPP_ALWAYS_INLINE __forceinline 130# endif 131#endif 132 133#endif // _WIN32 134 135#ifndef _LIBCPP_HIDDEN 136#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) 137#endif 138 139#ifndef _LIBCPP_VISIBLE 140#define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default"))) 141#endif 142 143#ifndef _LIBCPP_INLINE_VISIBILITY 144#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) 145#endif 146 147#ifndef _LIBCPP_EXCEPTION_ABI 148#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) 149#endif 150 151#ifndef _LIBCPP_CANTTHROW 152#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) 153#endif 154 155#ifndef _LIBCPP_ALWAYS_INLINE 156#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) 157#endif 158 159#if defined(__clang__) 160 161#if __has_feature(cxx_alignas) 162# define _ALIGNAS_TYPE(x) alignas(x) 163# define _ALIGNAS(x) alignas(x) 164#else 165# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 166# define _ALIGNAS(x) __attribute__((__aligned__(x))) 167#endif 168 169#if !__has_feature(cxx_alias_templates) 170#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 171#endif 172 173#ifndef __GXX_EXPERIMENTAL_CXX0X__ 174#ifdef __linux__ 175#define _LIBCPP_HAS_NO_UNICODE_CHARS 176#else 177typedef __char16_t char16_t; 178typedef __char32_t char32_t; 179#endif 180#endif 181 182#if !(__has_feature(cxx_exceptions)) 183#define _LIBCPP_NO_EXCEPTIONS 184#endif 185 186#if !(__has_feature(cxx_rtti)) 187#define _LIBCPP_NO_RTTI 188#endif 189 190#if !(__has_feature(cxx_strong_enums)) 191#define _LIBCPP_HAS_NO_STRONG_ENUMS 192#endif 193 194#if !(__has_feature(cxx_decltype)) 195#define _LIBCPP_HAS_NO_DECLTYPE 196#endif 197 198#if __has_feature(cxx_attributes) 199# define _LIBCPP_NORETURN [[noreturn]] 200#else 201# define _LIBCPP_NORETURN __attribute__ ((noreturn)) 202#endif 203 204#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 205 206#if !(__has_feature(cxx_deleted_functions)) 207#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 208#endif // !(__has_feature(cxx_deleted_functions)) 209 210#if !(__has_feature(cxx_lambdas)) 211#define _LIBCPP_HAS_NO_LAMBDAS 212#endif 213 214#if !(__has_feature(cxx_nullptr)) 215#define _LIBCPP_HAS_NO_NULLPTR 216#endif 217 218#if !(__has_feature(cxx_rvalue_references)) 219#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 220#endif 221 222#if !(__has_feature(cxx_static_assert)) 223#define _LIBCPP_HAS_NO_STATIC_ASSERT 224#endif 225 226#if !(__has_feature(cxx_auto_type)) 227#define _LIBCPP_HAS_NO_AUTO_TYPE 228#endif 229 230#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return) 231#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 232#endif 233 234#if !(__has_feature(cxx_variadic_templates)) 235#define _LIBCPP_HAS_NO_VARIADICS 236#endif 237 238#if !(__has_feature(cxx_trailing_return)) 239#define _LIBCPP_HAS_NO_TRAILING_RETURN 240#endif 241 242#if !(__has_feature(cxx_generalized_initializers)) 243#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 244#endif 245 246#if __has_feature(is_base_of) 247# define _LIBCP_HAS_IS_BASE_OF 248#endif 249 250// Objective-C++ features (opt-in) 251#if __has_feature(objc_arc) 252#define _LIBCPP_HAS_OBJC_ARC 253#endif 254 255#if __has_feature(objc_arc_weak) 256#define _LIBCPP_HAS_OBJC_ARC_WEAK 257#define _LIBCPP_HAS_NO_STRONG_ENUMS 258#endif 259 260#if !(__has_feature(cxx_constexpr)) 261#define _LIBCPP_HAS_NO_CONSTEXPR 262#endif 263 264#if __FreeBSD__ && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L) 265#define _LIBCPP_HAS_QUICK_EXIT 266#define _LIBCPP_HAS_C11_FEATURES 267#endif 268 269#if (__has_feature(cxx_noexcept)) 270# define _NOEXCEPT noexcept 271# define _NOEXCEPT_(x) noexcept(x) 272#else 273# define _NOEXCEPT throw() 274# define _NOEXCEPT_(x) 275#endif 276 277#if __has_feature(underlying_type) 278# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T) 279#endif 280 281// Inline namespaces are available in Clang regardless of C++ dialect. 282#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { 283#define _LIBCPP_END_NAMESPACE_STD } } 284#define _VSTD std::_LIBCPP_NAMESPACE 285 286namespace std { 287 inline namespace _LIBCPP_NAMESPACE { 288 } 289} 290 291#elif defined(__GNUC__) 292 293#define _ALIGNAS(x) __attribute__((__aligned__(x))) 294#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) 295 296#define _LIBCPP_NORETURN __attribute__((noreturn)) 297 298#if !__EXCEPTIONS 299#define _LIBCPP_NO_EXCEPTIONS 300#endif 301 302#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 303#define _LIBCPP_HAS_NO_CONSTEXPR 304 305#define _NOEXCEPT throw() 306#define _NOEXCEPT_(x) 307 308#ifndef __GXX_EXPERIMENTAL_CXX0X__ 309 310#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 311#define _LIBCPP_HAS_NO_DECLTYPE 312#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 313#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 314#define _LIBCPP_HAS_NO_NULLPTR 315#define _LIBCPP_HAS_NO_STATIC_ASSERT 316#define _LIBCPP_HAS_NO_UNICODE_CHARS 317#define _LIBCPP_HAS_NO_VARIADICS 318#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 319#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS 320 321#else // __GXX_EXPERIMENTAL_CXX0X__ 322 323#define _LIBCPP_HAS_NO_TRAILING_RETURN 324#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS 325 326#if _GNUC_VER < 403 327#define _LIBCPP_HAS_NO_RVALUE_REFERENCES 328#endif 329 330#if _GNUC_VER < 403 331#define _LIBCPP_HAS_NO_STATIC_ASSERT 332#endif 333 334#if _GNUC_VER < 407 335#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 336#endif 337 338#if _GNUC_VER < 404 339#define _LIBCPP_HAS_NO_ADVANCED_SFINAE 340#define _LIBCPP_HAS_NO_DECLTYPE 341#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 342#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 343#define _LIBCPP_HAS_NO_UNICODE_CHARS 344#define _LIBCPP_HAS_NO_VARIADICS 345#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 346#endif // _GNUC_VER < 404 347 348#if _GNUC_VER < 406 349#define _LIBCPP_HAS_NO_NULLPTR 350#endif 351 352#endif // __GXX_EXPERIMENTAL_CXX0X__ 353 354#if _GNUC_VER > 403 355#define _LIBCP_HAS_IS_BASE_OF 356#endif 357 358#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE { 359#define _LIBCPP_END_NAMESPACE_STD } } 360#define _VSTD std::_LIBCPP_NAMESPACE 361 362namespace std { 363namespace _LIBCPP_NAMESPACE { 364} 365using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); 366} 367 368#elif defined(_MSC_VER) 369 370#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES 371#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 372#define _LIBCPP_HAS_NO_CONSTEXPR 373#define _LIBCPP_HAS_NO_UNICODE_CHARS 374#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS 375#define __alignof__ __alignof 376#define _LIBCPP_NORETURN __declspec(noreturn) 377#define _ALIGNAS(x) __declspec(align(x)) 378#define _LIBCPP_HAS_NO_VARIADICS 379 380#define _NOEXCEPT throw() 381#define _NOEXCEPT_(x) 382 383#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { 384#define _LIBCPP_END_NAMESPACE_STD } 385#define _VSTD std 386 387namespace std { 388} 389 390#endif // __clang__ || __GNUC___ || _MSC_VER 391 392#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS 393typedef unsigned short char16_t; 394typedef unsigned int char32_t; 395#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 396 397#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT 398 399template <bool> struct __static_assert_test; 400template <> struct __static_assert_test<true> {}; 401template <unsigned> struct __static_assert_check {}; 402#define static_assert(__b, __m) \ 403 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \ 404 _LIBCPP_CONCAT(__t, __LINE__) 405 406#endif // _LIBCPP_HAS_NO_STATIC_ASSERT 407 408#ifdef _LIBCPP_HAS_NO_DECLTYPE 409#define decltype(x) __typeof__(x) 410#endif 411 412#ifdef _LIBCPP_HAS_NO_CONSTEXPR 413#define _LIBCPP_CONSTEXPR 414#else 415#define _LIBCPP_CONSTEXPR constexpr 416#endif 417 418#ifdef __GNUC__ 419#define _NOALIAS __attribute__((malloc)) 420#else 421#define _NOALIAS 422#endif 423 424#ifndef __has_feature 425#define __has_feature(__x) 0 426#endif 427 428#if __has_feature(cxx_explicit_conversions) 429# define _LIBCPP_EXPLICIT explicit 430#else 431# define _LIBCPP_EXPLICIT 432#endif 433 434#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 435#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum __lx 436#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ 437 __lx __v_; \ 438 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \ 439 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ 440 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ 441 }; 442#else // _LIBCPP_HAS_NO_STRONG_ENUMS 443#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x 444#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) 445#endif // _LIBCPP_HAS_NO_STRONG_ENUMS 446 447#ifndef _LIBCPP_EXTERN_TEMPLATE 448#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; 449#endif 450 451#if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__ 452#define _LIBCPP_LOCALE__L_EXTENSIONS 1 453#endif 454#if __FreeBSD__ 455#define _DECLARE_C99_LDBL_MATH 1 456#endif 457 458#if __APPLE__ || __FreeBSD__ 459#define _LIBCPP_HAS_DEFAULTRUNELOCALE 460#endif 461 462#if __APPLE__ || __FreeBSD__ || __sun__ 463#define _LIBCPP_WCTYPE_IS_MASK 464#endif 465 466#ifdef _LIBCPP_DEBUG2 467# if _LIBCPP_DEBUG2 == 0 468# define _LIBCPP_DEBUG_LEVEL 1 469# elif _LIBCPP_DEBUG2 == 1 470# define _LIBCPP_DEBUG_LEVEL 2 471# else 472# error Supported values for _LIBCPP_DEBUG2 are 0 and 1 473# endif 474#endif 475 476#ifdef _LIBCPP_DEBUG2 477# include <__debug> 478#else 479# define _LIBCPP_ASSERT(x, m) ((void)0) 480#endif 481 482#endif // _LIBCPP_CONFIG 483