2 //===--------------------------- __config ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_CONFIG
12 #define _LIBCPP_CONFIG
14 #ifndef _MSC_VER // explicit macro necessary because it is only defined below in this file
15 #pragma GCC system_header
19 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
22 #define _LIBCPP_VERSION 1101
24 #define _LIBCPP_ABI_VERSION 1
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)
29 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
31 #ifdef __LITTLE_ENDIAN__
33 #define _LIBCPP_LITTLE_ENDIAN 1
34 #define _LIBCPP_BIG_ENDIAN 0
35 #endif // __LITTLE_ENDIAN__
36 #endif // __LITTLE_ENDIAN__
40 #define _LIBCPP_LITTLE_ENDIAN 0
41 #define _LIBCPP_BIG_ENDIAN 1
42 #endif // __BIG_ENDIAN__
43 #endif // __BIG_ENDIAN__
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
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
70 # if defined(__GNUC__) && _GNUC_VER >= 403
71 # define _LIBCP_HAS_IS_BASE_OF
76 # include <sys/isa_defs.h>
77 # ifdef _LITTLE_ENDIAN
78 # define _LIBCPP_LITTLE_ENDIAN 1
79 # define _LIBCPP_BIG_ENDIAN 0
81 # define _LIBCPP_LITTLE_ENDIAN 0
82 # define _LIBCPP_BIG_ENDIAN 1
86 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
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
97 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
101 // only really useful for a DLL
102 #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
104 # define _LIBCPP_HIDDEN
105 # define _LIBCPP_FUNC_VIS __declspec(dllexport)
106 # define _LIBCPP_TYPE_VIS __declspec(dllexport)
108 # define _LIBCPP_HIDDEN
109 # define _LIBCPP_FUNC_VIS __declspec(dllimport)
110 # define _LIBCPP_TYPE_VIS __declspec(dllimport)
113 # define _LIBCPP_HIDDEN
114 # define _LIBCPP_FUNC_VIS
115 # define _LIBCPP_TYPE_VIS
118 #ifndef _LIBCPP_INLINE_VISIBILITY
120 # define _LIBCPP_INLINE_VISIBILITY __forceinline
121 # else // MinGW GCC and Clang
122 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
126 #ifndef _LIBCPP_EXCEPTION_ABI
127 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
130 #ifndef _LIBCPP_ALWAYS_INLINE
132 # define _LIBCPP_ALWAYS_INLINE __forceinline
138 #ifndef _LIBCPP_HIDDEN
139 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
142 #ifndef _LIBCPP_FUNC_VIS
143 #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
146 #ifndef _LIBCPP_TYPE_VIS
147 # if __has_attribute(type_visibility)
148 # define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
150 # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
154 #ifndef _LIBCPP_INLINE_VISIBILITY
155 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
158 #ifndef _LIBCPP_EXCEPTION_ABI
159 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
162 #ifndef _LIBCPP_CANTTHROW
163 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
166 #ifndef _LIBCPP_ALWAYS_INLINE
167 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
170 #if defined(__clang__)
172 #if __has_feature(cxx_alignas)
173 # define _ALIGNAS_TYPE(x) alignas(x)
174 # define _ALIGNAS(x) alignas(x)
176 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
177 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
180 #if !__has_feature(cxx_alias_templates)
181 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
184 #ifndef __GXX_EXPERIMENTAL_CXX0X__
186 #define _LIBCPP_HAS_NO_UNICODE_CHARS
188 typedef __char16_t char16_t;
189 typedef __char32_t char32_t;
193 #if !(__has_feature(cxx_exceptions))
194 #define _LIBCPP_NO_EXCEPTIONS
197 #if !(__has_feature(cxx_rtti))
198 #define _LIBCPP_NO_RTTI
201 #if !(__has_feature(cxx_strong_enums))
202 #define _LIBCPP_HAS_NO_STRONG_ENUMS
205 #if !(__has_feature(cxx_decltype))
206 #define _LIBCPP_HAS_NO_DECLTYPE
209 #if __has_feature(cxx_attributes)
210 # define _LIBCPP_NORETURN [[noreturn]]
212 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
215 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
217 #if !(__has_feature(cxx_deleted_functions))
218 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
219 #endif // !(__has_feature(cxx_deleted_functions))
221 #if !(__has_feature(cxx_lambdas))
222 #define _LIBCPP_HAS_NO_LAMBDAS
225 #if !(__has_feature(cxx_nullptr))
226 #define _LIBCPP_HAS_NO_NULLPTR
229 #if !(__has_feature(cxx_rvalue_references))
230 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
233 #if !(__has_feature(cxx_static_assert))
234 #define _LIBCPP_HAS_NO_STATIC_ASSERT
237 #if !(__has_feature(cxx_auto_type))
238 #define _LIBCPP_HAS_NO_AUTO_TYPE
241 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
242 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
245 #if !(__has_feature(cxx_variadic_templates))
246 #define _LIBCPP_HAS_NO_VARIADICS
249 #if !(__has_feature(cxx_trailing_return))
250 #define _LIBCPP_HAS_NO_TRAILING_RETURN
253 #if !(__has_feature(cxx_generalized_initializers))
254 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
257 #if __has_feature(is_base_of)
258 # define _LIBCP_HAS_IS_BASE_OF
261 // Objective-C++ features (opt-in)
262 #if __has_feature(objc_arc)
263 #define _LIBCPP_HAS_OBJC_ARC
266 #if __has_feature(objc_arc_weak)
267 #define _LIBCPP_HAS_OBJC_ARC_WEAK
268 #define _LIBCPP_HAS_NO_STRONG_ENUMS
271 #if !(__has_feature(cxx_constexpr))
272 #define _LIBCPP_HAS_NO_CONSTEXPR
275 #if defined(__FreeBSD__) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
276 #define _LIBCPP_HAS_QUICK_EXIT
277 #define _LIBCPP_HAS_C11_FEATURES
280 #if (__has_feature(cxx_noexcept))
281 # define _NOEXCEPT noexcept
282 # define _NOEXCEPT_(x) noexcept(x)
284 # define _NOEXCEPT throw()
285 # define _NOEXCEPT_(x)
288 #if __has_feature(underlying_type)
289 # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
292 // Inline namespaces are available in Clang regardless of C++ dialect.
293 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
294 #define _LIBCPP_END_NAMESPACE_STD } }
295 #define _VSTD std::_LIBCPP_NAMESPACE
298 inline namespace _LIBCPP_NAMESPACE {
302 #elif defined(__GNUC__)
304 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
305 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
307 #define _LIBCPP_NORETURN __attribute__((noreturn))
310 #define _LIBCPP_NO_EXCEPTIONS
313 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
314 #define _LIBCPP_HAS_NO_CONSTEXPR
316 #define _NOEXCEPT throw()
317 #define _NOEXCEPT_(x)
319 #ifndef __GXX_EXPERIMENTAL_CXX0X__
321 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
322 #define _LIBCPP_HAS_NO_DECLTYPE
323 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
324 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
325 #define _LIBCPP_HAS_NO_NULLPTR
326 #define _LIBCPP_HAS_NO_STATIC_ASSERT
327 #define _LIBCPP_HAS_NO_UNICODE_CHARS
328 #define _LIBCPP_HAS_NO_VARIADICS
329 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
330 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
332 #else // __GXX_EXPERIMENTAL_CXX0X__
334 #define _LIBCPP_HAS_NO_TRAILING_RETURN
335 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
338 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
342 #define _LIBCPP_HAS_NO_STATIC_ASSERT
346 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
347 #define _LIBCPP_HAS_NO_DECLTYPE
348 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
349 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
350 #define _LIBCPP_HAS_NO_UNICODE_CHARS
351 #define _LIBCPP_HAS_NO_VARIADICS
352 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
353 #endif // _GNUC_VER < 404
356 #define _LIBCPP_HAS_NO_NULLPTR
359 #endif // __GXX_EXPERIMENTAL_CXX0X__
361 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
362 #define _LIBCPP_END_NAMESPACE_STD } }
363 #define _VSTD std::_LIBCPP_NAMESPACE
366 namespace _LIBCPP_NAMESPACE {
368 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
371 #elif defined(_MSC_VER)
373 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
374 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
375 #define _LIBCPP_HAS_NO_CONSTEXPR
376 #define _LIBCPP_HAS_NO_UNICODE_CHARS
377 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
378 #define __alignof__ __alignof
379 #define _LIBCPP_NORETURN __declspec(noreturn)
380 #define _ALIGNAS(x) __declspec(align(x))
381 #define _LIBCPP_HAS_NO_VARIADICS
383 #define _NOEXCEPT throw()
384 #define _NOEXCEPT_(x)
386 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
387 #define _LIBCPP_END_NAMESPACE_STD }
393 #endif // __clang__ || __GNUC___ || _MSC_VER
395 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
396 typedef unsigned short char16_t;
397 typedef unsigned int char32_t;
398 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
400 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
402 template <bool> struct __static_assert_test;
403 template <> struct __static_assert_test<true> {};
404 template <unsigned> struct __static_assert_check {};
405 #define static_assert(__b, __m) \
406 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
407 _LIBCPP_CONCAT(__t, __LINE__)
409 #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
411 #ifdef _LIBCPP_HAS_NO_DECLTYPE
412 #define decltype(x) __typeof__(x)
415 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
416 #define _LIBCPP_CONSTEXPR
418 #define _LIBCPP_CONSTEXPR constexpr
422 #define _NOALIAS __attribute__((malloc))
427 #ifndef __has_feature
428 #define __has_feature(__x) 0
431 #if __has_feature(cxx_explicit_conversions)
432 # define _LIBCPP_EXPLICIT explicit
434 # define _LIBCPP_EXPLICIT
437 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
438 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
439 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
441 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
442 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
443 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
445 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
446 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
447 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
448 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
450 #ifndef _LIBCPP_EXTERN_TEMPLATE
451 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
454 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__)
455 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
458 #define _DECLARE_C99_LDBL_MATH 1
461 #if defined(__APPLE__) || defined(__FreeBSD__)
462 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
465 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
466 #define _LIBCPP_WCTYPE_IS_MASK
469 #ifdef _LIBCPP_DEBUG2
470 # if _LIBCPP_DEBUG2 == 0
471 # define _LIBCPP_DEBUG_LEVEL 1
472 # elif _LIBCPP_DEBUG2 == 1
473 # define _LIBCPP_DEBUG_LEVEL 2
475 # error Supported values for _LIBCPP_DEBUG2 are 0 and 1
479 #ifdef _LIBCPP_DEBUG2
482 # define _LIBCPP_ASSERT(x, m) ((void)0)
485 #endif // _LIBCPP_CONFIG