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