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 # include <sys/isa_defs.h>
71 # ifdef _LITTLE_ENDIAN
72 # define _LIBCPP_LITTLE_ENDIAN 1
73 # define _LIBCPP_BIG_ENDIAN 0
75 # define _LIBCPP_LITTLE_ENDIAN 0
76 # define _LIBCPP_BIG_ENDIAN 1
80 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
82 # if __BYTE_ORDER == __LITTLE_ENDIAN
83 # define _LIBCPP_LITTLE_ENDIAN 1
84 # define _LIBCPP_BIG_ENDIAN 0
85 # elif __BYTE_ORDER == __BIG_ENDIAN
86 # define _LIBCPP_LITTLE_ENDIAN 0
87 # define _LIBCPP_BIG_ENDIAN 1
88 # else // __BYTE_ORDER == __BIG_ENDIAN
89 # error unable to determine endian
91 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
95 // only really useful for a DLL
96 #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
98 # define _LIBCPP_HIDDEN
99 # define _LIBCPP_VISIBLE __declspec(dllexport)
101 # define _LIBCPP_HIDDEN
102 # define _LIBCPP_VISIBLE __declspec(dllimport)
105 # define _LIBCPP_HIDDEN
106 # define _LIBCPP_VISIBLE
109 #ifndef _LIBCPP_INLINE_VISIBILITY
111 # define _LIBCPP_INLINE_VISIBILITY __forceinline
112 # else // MinGW GCC and Clang
113 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
117 #ifndef _LIBCPP_EXCEPTION_ABI
118 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
121 #ifndef _LIBCPP_ALWAYS_INLINE
123 # define _LIBCPP_ALWAYS_INLINE __forceinline
129 #ifndef _LIBCPP_HIDDEN
130 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
133 #ifndef _LIBCPP_VISIBLE
134 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
137 #ifndef _LIBCPP_INLINE_VISIBILITY
138 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
141 #ifndef _LIBCPP_EXCEPTION_ABI
142 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
145 #ifndef _LIBCPP_CANTTHROW
146 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
149 #ifndef _LIBCPP_ALWAYS_INLINE
150 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
153 #if defined(__clang__)
155 #if __has_feature(cxx_alignas)
156 # define _ALIGNAS_TYPE(x) alignas(x)
157 # define _ALIGNAS(x) alignas(x)
159 # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
160 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
163 #if !__has_feature(cxx_alias_templates)
164 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
167 #ifndef __GXX_EXPERIMENTAL_CXX0X__
169 #define _LIBCPP_HAS_NO_UNICODE_CHARS
171 typedef __char16_t char16_t;
172 typedef __char32_t char32_t;
176 #if !(__has_feature(cxx_exceptions))
177 #define _LIBCPP_NO_EXCEPTIONS
180 #if !(__has_feature(cxx_rtti))
181 #define _LIBCPP_NO_RTTI
184 #if !(__has_feature(cxx_strong_enums))
185 #define _LIBCPP_HAS_NO_STRONG_ENUMS
188 #if !(__has_feature(cxx_decltype))
189 #define _LIBCPP_HAS_NO_DECLTYPE
192 #if __has_feature(cxx_attributes)
193 # define _LIBCPP_NORETURN [[noreturn]]
195 # define _LIBCPP_NORETURN __attribute__ ((noreturn))
198 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
200 #if !(__has_feature(cxx_deleted_functions))
201 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
202 #endif // !(__has_feature(cxx_deleted_functions))
204 #if !(__has_feature(cxx_lambdas))
205 #define _LIBCPP_HAS_NO_LAMBDAS
208 #if !(__has_feature(cxx_nullptr))
209 #define _LIBCPP_HAS_NO_NULLPTR
212 #if !(__has_feature(cxx_rvalue_references))
213 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
216 #if !(__has_feature(cxx_static_assert))
217 #define _LIBCPP_HAS_NO_STATIC_ASSERT
220 #if !(__has_feature(cxx_auto_type))
221 #define _LIBCPP_HAS_NO_AUTO_TYPE
224 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
225 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
228 #if !(__has_feature(cxx_variadic_templates))
229 #define _LIBCPP_HAS_NO_VARIADICS
232 #if !(__has_feature(cxx_trailing_return))
233 #define _LIBCPP_HAS_NO_TRAILING_RETURN
236 #if !(__has_feature(cxx_generalized_initializers))
237 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
240 #if __has_feature(is_base_of)
241 # define _LIBCP_HAS_IS_BASE_OF
244 // Objective-C++ features (opt-in)
245 #if __has_feature(objc_arc)
246 #define _LIBCPP_HAS_OBJC_ARC
249 #if __has_feature(objc_arc_weak)
250 #define _LIBCPP_HAS_OBJC_ARC_WEAK
251 #define _LIBCPP_HAS_NO_STRONG_ENUMS
254 #if !(__has_feature(cxx_constexpr))
255 #define _LIBCPP_HAS_NO_CONSTEXPR
258 #if __FreeBSD__ && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
259 #define _LIBCPP_HAS_QUICK_EXIT
260 #define _LIBCPP_HAS_C11_FEATURES
263 #if (__has_feature(cxx_noexcept))
264 # define _NOEXCEPT noexcept
265 # define _NOEXCEPT_(x) noexcept(x)
267 # define _NOEXCEPT throw()
268 # define _NOEXCEPT_(x)
271 #if __has_feature(underlying_type)
272 # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
275 // Inline namespaces are available in Clang regardless of C++ dialect.
276 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
277 #define _LIBCPP_END_NAMESPACE_STD } }
278 #define _VSTD std::_LIBCPP_NAMESPACE
281 inline namespace _LIBCPP_NAMESPACE {
285 #elif defined(__GNUC__)
287 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
288 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
290 #define _LIBCPP_NORETURN __attribute__((noreturn))
293 #define _LIBCPP_NO_EXCEPTIONS
296 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
297 #define _LIBCPP_HAS_NO_CONSTEXPR
299 #define _NOEXCEPT throw()
300 #define _NOEXCEPT_(x)
302 #ifndef __GXX_EXPERIMENTAL_CXX0X__
304 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
305 #define _LIBCPP_HAS_NO_DECLTYPE
306 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
307 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
308 #define _LIBCPP_HAS_NO_NULLPTR
309 #define _LIBCPP_HAS_NO_STATIC_ASSERT
310 #define _LIBCPP_HAS_NO_UNICODE_CHARS
311 #define _LIBCPP_HAS_NO_VARIADICS
312 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
313 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
315 #else // __GXX_EXPERIMENTAL_CXX0X__
317 #define _LIBCPP_HAS_NO_TRAILING_RETURN
318 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
321 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
325 #define _LIBCPP_HAS_NO_STATIC_ASSERT
329 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
330 #define _LIBCPP_HAS_NO_DECLTYPE
331 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
332 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
333 #define _LIBCPP_HAS_NO_UNICODE_CHARS
334 #define _LIBCPP_HAS_NO_VARIADICS
335 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
336 #endif // _GNUC_VER < 404
339 #define _LIBCPP_HAS_NO_NULLPTR
342 #endif // __GXX_EXPERIMENTAL_CXX0X__
344 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
345 #define _LIBCPP_END_NAMESPACE_STD } }
346 #define _VSTD std::_LIBCPP_NAMESPACE
349 namespace _LIBCPP_NAMESPACE {
351 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
354 #elif defined(_MSC_VER)
356 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
357 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
358 #define _LIBCPP_HAS_NO_CONSTEXPR
359 #define _LIBCPP_HAS_NO_UNICODE_CHARS
360 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
361 #define __alignof__ __alignof
362 #define _LIBCPP_NORETURN __declspec(noreturn)
363 #define _ALIGNAS(x) __declspec(align(x))
364 #define _LIBCPP_HAS_NO_VARIADICS
366 #define _NOEXCEPT throw()
367 #define _NOEXCEPT_(x)
369 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
370 #define _LIBCPP_END_NAMESPACE_STD }
376 #endif // __clang__ || __GNUC___ || _MSC_VER
378 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
379 typedef unsigned short char16_t;
380 typedef unsigned int char32_t;
381 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
383 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
385 template <bool> struct __static_assert_test;
386 template <> struct __static_assert_test<true> {};
387 template <unsigned> struct __static_assert_check {};
388 #define static_assert(__b, __m) \
389 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
390 _LIBCPP_CONCAT(__t, __LINE__)
392 #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
394 #ifdef _LIBCPP_HAS_NO_DECLTYPE
395 #define decltype(x) __typeof__(x)
398 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
399 #define _LIBCPP_CONSTEXPR
401 #define _LIBCPP_CONSTEXPR constexpr
405 #define _NOALIAS __attribute__((malloc))
410 #ifndef __has_feature
411 #define __has_feature(__x) 0
414 #if __has_feature(cxx_explicit_conversions)
415 # define _LIBCPP_EXPLICIT explicit
417 # define _LIBCPP_EXPLICIT
420 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
421 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum __lx
422 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
424 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
425 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
426 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
428 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
429 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x
430 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
431 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
433 #ifndef _LIBCPP_EXTERN_TEMPLATE
434 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
437 #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__
438 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
441 #define _DECLARE_C99_LDBL_MATH 1
444 #if __APPLE__ || __FreeBSD__
445 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
448 #if __APPLE__ || __FreeBSD__ || __sun__
449 #define _LIBCPP_WCTYPE_IS_MASK
452 #ifdef _LIBCPP_DEBUG2
453 # if _LIBCPP_DEBUG2 == 0
454 # define _LIBCPP_DEBUG_LEVEL 1
455 # elif _LIBCPP_DEBUG2 == 1
456 # define _LIBCPP_DEBUG_LEVEL 2
458 # error Supported values for _LIBCPP_DEBUG2 are 0 and 1
462 #ifdef _LIBCPP_DEBUG2
465 # define _LIBCPP_ASSERT(x, m) ((void)0)
468 #endif // _LIBCPP_CONFIG