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
57 # define _LIBCPP_LITTLE_ENDIAN 1
58 # define _LIBCPP_BIG_ENDIAN 0
59 // Compiler intrinsics (GCC or MSVC)
60 # if (defined(_MSC_VER) && _MSC_VER >= 1400) \
61 || (defined(__GNUC__) && _GNUC_VER > 403)
62 # define _LIBCP_HAS_IS_BASE_OF
67 # include <sys/isa_defs.h>
68 # ifdef _LITTLE_ENDIAN
69 # define _LIBCPP_LITTLE_ENDIAN 1
70 # define _LIBCPP_BIG_ENDIAN 0
72 # define _LIBCPP_LITTLE_ENDIAN 0
73 # define _LIBCPP_BIG_ENDIAN 1
77 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
79 # if __BYTE_ORDER == __LITTLE_ENDIAN
80 # define _LIBCPP_LITTLE_ENDIAN 1
81 # define _LIBCPP_BIG_ENDIAN 0
82 # elif __BYTE_ORDER == __BIG_ENDIAN
83 # define _LIBCPP_LITTLE_ENDIAN 0
84 # define _LIBCPP_BIG_ENDIAN 1
85 # else // __BYTE_ORDER == __BIG_ENDIAN
86 # error unable to determine endian
88 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
92 // only really useful for a DLL
93 #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
95 # define _LIBCPP_HIDDEN
96 # define _LIBCPP_VISIBLE __declspec(dllexport)
98 # define _LIBCPP_HIDDEN
99 # define _LIBCPP_VISIBLE __declspec(dllimport)
102 # define _LIBCPP_HIDDEN
103 # define _LIBCPP_VISIBLE
106 #ifndef _LIBCPP_INLINE_VISIBILITY
108 # define _LIBCPP_INLINE_VISIBILITY __forceinline
109 # else // MinGW GCC and Clang
110 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
114 #ifndef _LIBCPP_EXCEPTION_ABI
115 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
118 #ifndef _LIBCPP_ALWAYS_INLINE
120 # define _LIBCPP_ALWAYS_INLINE __forceinline
126 #ifndef _LIBCPP_HIDDEN
127 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
130 #ifndef _LIBCPP_VISIBLE
131 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
134 #ifndef _LIBCPP_INLINE_VISIBILITY
135 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
138 #ifndef _LIBCPP_EXCEPTION_ABI
139 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
142 #ifndef _LIBCPP_CANTTHROW
143 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
146 #ifndef _LIBCPP_ALWAYS_INLINE
147 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
150 #if defined(__clang__)
152 #if __has_feature(cxx_alignas)
153 # define _ALIGNAS_TYPE(x) alignas(x)
154 # define _ALIGNAS(x) alignas(x)
156 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
157 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
160 #if !__has_feature(cxx_alias_templates)
161 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
164 #ifndef __GXX_EXPERIMENTAL_CXX0X__
166 #define _LIBCPP_HAS_NO_UNICODE_CHARS
168 typedef __char16_t char16_t;
169 typedef __char32_t char32_t;
173 #if !(__has_feature(cxx_exceptions))
174 #define _LIBCPP_NO_EXCEPTIONS
177 #if !(__has_feature(cxx_rtti))
178 #define _LIBCPP_NO_RTTI
181 #if !(__has_feature(cxx_strong_enums))
182 #define _LIBCPP_HAS_NO_STRONG_ENUMS
185 #if !(__has_feature(cxx_decltype))
186 #define _LIBCPP_HAS_NO_DECLTYPE
189 #if __has_feature(cxx_attributes)
190 # define _LIBCPP_NORETURN [[noreturn]]
192 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
195 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
197 #if !(__has_feature(cxx_deleted_functions))
198 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
199 #endif // !(__has_feature(cxx_deleted_functions))
201 #if !(__has_feature(cxx_lambdas))
202 #define _LIBCPP_HAS_NO_LAMBDAS
205 #if !(__has_feature(cxx_nullptr))
206 #define _LIBCPP_HAS_NO_NULLPTR
209 #if !(__has_feature(cxx_rvalue_references))
210 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
213 #if !(__has_feature(cxx_static_assert))
214 #define _LIBCPP_HAS_NO_STATIC_ASSERT
217 #if !(__has_feature(cxx_auto_type))
218 #define _LIBCPP_HAS_NO_AUTO_TYPE
221 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
222 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
225 #if !(__has_feature(cxx_variadic_templates))
226 #define _LIBCPP_HAS_NO_VARIADICS
229 #if !(__has_feature(cxx_trailing_return))
230 #define _LIBCPP_HAS_NO_TRAILING_RETURN
233 #if !(__has_feature(cxx_generalized_initializers))
234 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
237 #if __has_feature(is_base_of)
238 # define _LIBCP_HAS_IS_BASE_OF
241 // Objective-C++ features (opt-in)
242 #if __has_feature(objc_arc)
243 #define _LIBCPP_HAS_OBJC_ARC
246 #if __has_feature(objc_arc_weak)
247 #define _LIBCPP_HAS_OBJC_ARC_WEAK
248 #define _LIBCPP_HAS_NO_STRONG_ENUMS
251 #if !(__has_feature(cxx_constexpr))
252 #define _LIBCPP_HAS_NO_CONSTEXPR
255 #if __FreeBSD__ && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
256 #define _LIBCPP_HAS_QUICK_EXIT
257 #define _LIBCPP_HAS_C11_FEATURES
260 #if (__has_feature(cxx_noexcept))
261 # define _NOEXCEPT noexcept
262 # define _NOEXCEPT_(x) noexcept(x)
264 # define _NOEXCEPT throw()
265 # define _NOEXCEPT_(x)
268 #if __has_feature(underlying_type)
269 # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
272 // Inline namespaces are available in Clang regardless of C++ dialect.
273 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
274 #define _LIBCPP_END_NAMESPACE_STD } }
275 #define _VSTD std::_LIBCPP_NAMESPACE
278 inline namespace _LIBCPP_NAMESPACE {
282 #elif defined(__GNUC__)
284 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
285 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
287 #define _LIBCPP_NORETURN __attribute__((noreturn))
290 #define _LIBCPP_NO_EXCEPTIONS
293 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
294 #define _LIBCPP_HAS_NO_CONSTEXPR
296 #define _NOEXCEPT throw()
297 #define _NOEXCEPT_(x)
299 #ifndef __GXX_EXPERIMENTAL_CXX0X__
301 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
302 #define _LIBCPP_HAS_NO_DECLTYPE
303 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
304 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
305 #define _LIBCPP_HAS_NO_NULLPTR
306 #define _LIBCPP_HAS_NO_STATIC_ASSERT
307 #define _LIBCPP_HAS_NO_UNICODE_CHARS
308 #define _LIBCPP_HAS_NO_VARIADICS
309 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
310 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
312 #else // __GXX_EXPERIMENTAL_CXX0X__
314 #define _LIBCPP_HAS_NO_TRAILING_RETURN
315 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
318 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
322 #define _LIBCPP_HAS_NO_STATIC_ASSERT
326 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
327 #define _LIBCPP_HAS_NO_DECLTYPE
328 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
329 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
330 #define _LIBCPP_HAS_NO_UNICODE_CHARS
331 #define _LIBCPP_HAS_NO_VARIADICS
332 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
333 #endif // _GNUC_VER < 404
336 #define _LIBCPP_HAS_NO_NULLPTR
339 #endif // __GXX_EXPERIMENTAL_CXX0X__
341 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
342 #define _LIBCPP_END_NAMESPACE_STD } }
343 #define _VSTD std::_LIBCPP_NAMESPACE
346 namespace _LIBCPP_NAMESPACE {
348 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
351 #elif defined(_MSC_VER)
353 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
354 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
355 #define _LIBCPP_HAS_NO_CONSTEXPR
356 #define _LIBCPP_HAS_NO_UNICODE_CHARS
357 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
358 #define __alignof__ __alignof
359 #define _LIBCPP_NORETURN __declspec(noreturn)
360 #define _ALIGNAS(x) __declspec(align(x))
361 #define _LIBCPP_HAS_NO_VARIADICS
363 #define _NOEXCEPT throw()
364 #define _NOEXCEPT_(x)
366 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
367 #define _LIBCPP_END_NAMESPACE_STD }
373 #endif // __clang__ || __GNUC___ || _MSC_VER
375 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
376 typedef unsigned short char16_t;
377 typedef unsigned int char32_t;
378 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
380 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
382 template <bool> struct __static_assert_test;
383 template <> struct __static_assert_test<true> {};
384 template <unsigned> struct __static_assert_check {};
385 #define static_assert(__b, __m) \
386 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
387 _LIBCPP_CONCAT(__t, __LINE__)
389 #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
391 #ifdef _LIBCPP_HAS_NO_DECLTYPE
392 #define decltype(x) __typeof__(x)
395 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
396 #define _LIBCPP_CONSTEXPR
398 #define _LIBCPP_CONSTEXPR constexpr
402 #define _NOALIAS __attribute__((malloc))
407 #ifndef __has_feature
408 #define __has_feature(__x) 0
411 #if __has_feature(cxx_explicit_conversions)
412 # define _LIBCPP_EXPLICIT explicit
414 # define _LIBCPP_EXPLICIT
417 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
418 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum __lx
419 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
421 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
422 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
423 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
425 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
426 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x
427 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
428 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
430 #ifndef _LIBCPP_EXTERN_TEMPLATE
431 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
434 #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__
435 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
438 #define _DECLARE_C99_LDBL_MATH 1
441 #if __APPLE__ || __FreeBSD__
442 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
445 #if __APPLE__ || __FreeBSD__ || __sun__
446 #define _LIBCPP_WCTYPE_IS_MASK
449 #ifdef _LIBCPP_DEBUG2
450 # if _LIBCPP_DEBUG2 == 0
451 # define _LIBCPP_DEBUG_LEVEL 1
452 # elif _LIBCPP_DEBUG2 == 1
453 # define _LIBCPP_DEBUG_LEVEL 2
455 # error Supported values for _LIBCPP_DEBUG2 are 0 and 1
459 #ifdef _LIBCPP_DEBUG2
462 # define _LIBCPP_ASSERT(x, m) ((void)0)
465 #endif // _LIBCPP_CONFIG