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 #if !_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_VISIBLE __declspec(dllexport)
107 # define _LIBCPP_HIDDEN
108 # define _LIBCPP_VISIBLE __declspec(dllimport)
111 # define _LIBCPP_HIDDEN
112 # define _LIBCPP_VISIBLE
115 #ifndef _LIBCPP_INLINE_VISIBILITY
117 # define _LIBCPP_INLINE_VISIBILITY __forceinline
118 # else // MinGW GCC and Clang
119 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
123 #ifndef _LIBCPP_EXCEPTION_ABI
124 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
127 #ifndef _LIBCPP_ALWAYS_INLINE
129 # define _LIBCPP_ALWAYS_INLINE __forceinline
135 #ifndef _LIBCPP_HIDDEN
136 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
139 #ifndef _LIBCPP_VISIBLE
140 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
143 #ifndef _LIBCPP_INLINE_VISIBILITY
144 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
147 #ifndef _LIBCPP_EXCEPTION_ABI
148 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
151 #ifndef _LIBCPP_CANTTHROW
152 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
155 #ifndef _LIBCPP_ALWAYS_INLINE
156 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
159 #if defined(__clang__)
161 #if __has_feature(cxx_alignas)
162 # define _ALIGNAS_TYPE(x) alignas(x)
163 # define _ALIGNAS(x) alignas(x)
165 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
166 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
169 #if !__has_feature(cxx_alias_templates)
170 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
173 #ifndef __GXX_EXPERIMENTAL_CXX0X__
175 #define _LIBCPP_HAS_NO_UNICODE_CHARS
177 typedef __char16_t char16_t;
178 typedef __char32_t char32_t;
182 #if !(__has_feature(cxx_exceptions))
183 #define _LIBCPP_NO_EXCEPTIONS
186 #if !(__has_feature(cxx_rtti))
187 #define _LIBCPP_NO_RTTI
190 #if !(__has_feature(cxx_strong_enums))
191 #define _LIBCPP_HAS_NO_STRONG_ENUMS
194 #if !(__has_feature(cxx_decltype))
195 #define _LIBCPP_HAS_NO_DECLTYPE
198 #if __has_feature(cxx_attributes)
199 # define _LIBCPP_NORETURN [[noreturn]]
201 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
204 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
206 #if !(__has_feature(cxx_deleted_functions))
207 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
208 #endif // !(__has_feature(cxx_deleted_functions))
210 #if !(__has_feature(cxx_lambdas))
211 #define _LIBCPP_HAS_NO_LAMBDAS
214 #if !(__has_feature(cxx_nullptr))
215 #define _LIBCPP_HAS_NO_NULLPTR
218 #if !(__has_feature(cxx_rvalue_references))
219 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
222 #if !(__has_feature(cxx_static_assert))
223 #define _LIBCPP_HAS_NO_STATIC_ASSERT
226 #if !(__has_feature(cxx_auto_type))
227 #define _LIBCPP_HAS_NO_AUTO_TYPE
230 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
231 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
234 #if !(__has_feature(cxx_variadic_templates))
235 #define _LIBCPP_HAS_NO_VARIADICS
238 #if !(__has_feature(cxx_trailing_return))
239 #define _LIBCPP_HAS_NO_TRAILING_RETURN
242 #if !(__has_feature(cxx_generalized_initializers))
243 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
246 #if __has_feature(is_base_of)
247 # define _LIBCP_HAS_IS_BASE_OF
250 // Objective-C++ features (opt-in)
251 #if __has_feature(objc_arc)
252 #define _LIBCPP_HAS_OBJC_ARC
255 #if __has_feature(objc_arc_weak)
256 #define _LIBCPP_HAS_OBJC_ARC_WEAK
257 #define _LIBCPP_HAS_NO_STRONG_ENUMS
260 #if !(__has_feature(cxx_constexpr))
261 #define _LIBCPP_HAS_NO_CONSTEXPR
264 #if __FreeBSD__ && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
265 #define _LIBCPP_HAS_QUICK_EXIT
266 #define _LIBCPP_HAS_C11_FEATURES
269 #if (__has_feature(cxx_noexcept))
270 # define _NOEXCEPT noexcept
271 # define _NOEXCEPT_(x) noexcept(x)
273 # define _NOEXCEPT throw()
274 # define _NOEXCEPT_(x)
277 #if __has_feature(underlying_type)
278 # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
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
287 inline namespace _LIBCPP_NAMESPACE {
291 #elif defined(__GNUC__)
293 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
294 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
296 #define _LIBCPP_NORETURN __attribute__((noreturn))
299 #define _LIBCPP_NO_EXCEPTIONS
302 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
303 #define _LIBCPP_HAS_NO_CONSTEXPR
305 #define _NOEXCEPT throw()
306 #define _NOEXCEPT_(x)
308 #ifndef __GXX_EXPERIMENTAL_CXX0X__
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
321 #else // __GXX_EXPERIMENTAL_CXX0X__
323 #define _LIBCPP_HAS_NO_TRAILING_RETURN
324 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
327 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
331 #define _LIBCPP_HAS_NO_STATIC_ASSERT
335 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
336 #define _LIBCPP_HAS_NO_DECLTYPE
337 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
338 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
339 #define _LIBCPP_HAS_NO_UNICODE_CHARS
340 #define _LIBCPP_HAS_NO_VARIADICS
341 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
342 #endif // _GNUC_VER < 404
345 #define _LIBCPP_HAS_NO_NULLPTR
348 #endif // __GXX_EXPERIMENTAL_CXX0X__
350 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
351 #define _LIBCPP_END_NAMESPACE_STD } }
352 #define _VSTD std::_LIBCPP_NAMESPACE
355 namespace _LIBCPP_NAMESPACE {
357 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
360 #elif defined(_MSC_VER)
362 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
363 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
364 #define _LIBCPP_HAS_NO_CONSTEXPR
365 #define _LIBCPP_HAS_NO_UNICODE_CHARS
366 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
367 #define __alignof__ __alignof
368 #define _LIBCPP_NORETURN __declspec(noreturn)
369 #define _ALIGNAS(x) __declspec(align(x))
370 #define _LIBCPP_HAS_NO_VARIADICS
372 #define _NOEXCEPT throw()
373 #define _NOEXCEPT_(x)
375 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
376 #define _LIBCPP_END_NAMESPACE_STD }
382 #endif // __clang__ || __GNUC___ || _MSC_VER
384 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
385 typedef unsigned short char16_t;
386 typedef unsigned int char32_t;
387 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
389 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
391 template <bool> struct __static_assert_test;
392 template <> struct __static_assert_test<true> {};
393 template <unsigned> struct __static_assert_check {};
394 #define static_assert(__b, __m) \
395 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
396 _LIBCPP_CONCAT(__t, __LINE__)
398 #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
400 #ifdef _LIBCPP_HAS_NO_DECLTYPE
401 #define decltype(x) __typeof__(x)
404 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
405 #define _LIBCPP_CONSTEXPR
407 #define _LIBCPP_CONSTEXPR constexpr
411 #define _NOALIAS __attribute__((malloc))
416 #ifndef __has_feature
417 #define __has_feature(__x) 0
420 #if __has_feature(cxx_explicit_conversions)
421 # define _LIBCPP_EXPLICIT explicit
423 # define _LIBCPP_EXPLICIT
426 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
427 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum __lx
428 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
430 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
431 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
432 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
434 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
435 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x
436 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
437 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
439 #ifndef _LIBCPP_EXTERN_TEMPLATE
440 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
443 #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__
444 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
447 #define _DECLARE_C99_LDBL_MATH 1
450 #if __APPLE__ || __FreeBSD__
451 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
454 #if __APPLE__ || __FreeBSD__ || __sun__
455 #define _LIBCPP_WCTYPE_IS_MASK
458 #ifdef _LIBCPP_DEBUG2
459 # if _LIBCPP_DEBUG2 == 0
460 # define _LIBCPP_DEBUG_LEVEL 1
461 # elif _LIBCPP_DEBUG2 == 1
462 # define _LIBCPP_DEBUG_LEVEL 2
464 # error Supported values for _LIBCPP_DEBUG2 are 0 and 1
468 #ifdef _LIBCPP_DEBUG2
471 # define _LIBCPP_ASSERT(x, m) ((void)0)
474 #endif // _LIBCPP_CONFIG