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
18 #define _LIBCPP_VERSION 1001
20 #define _LIBCPP_ABI_VERSION 1
22 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
23 #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
25 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
27 #ifdef __LITTLE_ENDIAN__
29 #define _LIBCPP_LITTLE_ENDIAN 1
30 #define _LIBCPP_BIG_ENDIAN 0
31 #endif // __LITTLE_ENDIAN__
32 #endif // __LITTLE_ENDIAN__
36 #define _LIBCPP_LITTLE_ENDIAN 0
37 #define _LIBCPP_BIG_ENDIAN 1
38 #endif // __BIG_ENDIAN__
39 #endif // __BIG_ENDIAN__
42 # include <sys/endian.h>
43 # if _BYTE_ORDER == _LITTLE_ENDIAN
44 # define _LIBCPP_LITTLE_ENDIAN 1
45 # define _LIBCPP_BIG_ENDIAN 0
46 # else // _BYTE_ORDER == _LITTLE_ENDIAN
47 # define _LIBCPP_LITTLE_ENDIAN 0
48 # define _LIBCPP_BIG_ENDIAN 1
49 # endif // _BYTE_ORDER == _LITTLE_ENDIAN
53 # define _LIBCPP_LITTLE_ENDIAN 1
54 # define _LIBCPP_BIG_ENDIAN 0
55 // Compiler intrinsics (GCC or MSVC)
56 # if (defined(_MSC_VER) && _MSC_VER >= 1400) || (__GNUC__ >= 4 && __GNUC_MINOR__ > 3)
57 # define _LIBCP_HAS_IS_BASE_OF
62 # include <sys/isa_defs.h>
63 # ifdef _LITTLE_ENDIAN
64 # define _LIBCPP_LITTLE_ENDIAN 1
65 # define _LIBCPP_BIG_ENDIAN 0
67 # define _LIBCPP_LITTLE_ENDIAN 0
68 # define _LIBCPP_BIG_ENDIAN 1
72 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
74 # if __BYTE_ORDER == __LITTLE_ENDIAN
75 # define _LIBCPP_LITTLE_ENDIAN 1
76 # define _LIBCPP_BIG_ENDIAN 0
77 # elif __BYTE_ORDER == __BIG_ENDIAN
78 # define _LIBCPP_LITTLE_ENDIAN 0
79 # define _LIBCPP_BIG_ENDIAN 1
80 # else // __BYTE_ORDER == __BIG_ENDIAN
81 # error unable to determine endian
83 #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
87 // only really useful for a DLL
88 #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
90 # define _LIBCPP_HIDDEN
91 # define _LIBCPP_VISIBLE __declspec(dllexport)
93 # define _LIBCPP_HIDDEN
94 # define _LIBCPP_VISIBLE __declspec(dllimport)
97 # define _LIBCPP_HIDDEN
98 # define _LIBCPP_VISIBLE
101 #ifndef _LIBCPP_INLINE_VISIBILITY
103 # define _LIBCPP_INLINE_VISIBILITY __forceinline
104 # else // MinGW GCC and Clang
105 # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
109 #ifndef _LIBCPP_EXCEPTION_ABI
110 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
113 #ifndef _LIBCPP_ALWAYS_INLINE
115 # define _LIBCPP_ALWAYS_INLINE __forceinline
121 #ifndef _LIBCPP_HIDDEN
122 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
125 #ifndef _LIBCPP_VISIBLE
126 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
129 #ifndef _LIBCPP_INLINE_VISIBILITY
130 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
133 #ifndef _LIBCPP_EXCEPTION_ABI
134 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
137 #ifndef _LIBCPP_CANTTHROW
138 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
141 #ifndef _LIBCPP_ALWAYS_INLINE
142 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
145 #if defined(__clang__)
147 #if __has_feature(cxx_alignas)
148 # define _ALIGNAS(x) alignas(x)
150 # define _ALIGNAS(x) __attribute__((__aligned__(x)))
153 #if !__has_feature(cxx_alias_templates)
154 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
157 #ifndef __GXX_EXPERIMENTAL_CXX0X__
159 #define _LIBCPP_HAS_NO_UNICODE_CHARS
161 typedef __char16_t char16_t;
162 typedef __char32_t char32_t;
166 #if !(__has_feature(cxx_exceptions))
167 #define _LIBCPP_NO_EXCEPTIONS
170 #if !(__has_feature(cxx_rtti))
171 #define _LIBCPP_NO_RTTI
174 #if !(__has_feature(cxx_strong_enums))
175 #define _LIBCPP_HAS_NO_STRONG_ENUMS
178 #if !(__has_feature(cxx_decltype))
179 #define _LIBCPP_HAS_NO_DECLTYPE
182 #if __has_feature(cxx_attributes)
183 # define _ATTRIBUTE(x) [[x]]
185 # define _ATTRIBUTE(x) __attribute__ ((x))
188 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
190 #if !(__has_feature(cxx_deleted_functions))
191 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
192 #endif // !(__has_feature(cxx_deleted_functions))
194 #if !(__has_feature(cxx_lambdas))
195 #define _LIBCPP_HAS_NO_LAMBDAS
198 #if !(__has_feature(cxx_nullptr))
199 #define _LIBCPP_HAS_NO_NULLPTR
202 #if !(__has_feature(cxx_rvalue_references))
203 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
206 #if !(__has_feature(cxx_static_assert))
207 #define _LIBCPP_HAS_NO_STATIC_ASSERT
210 #if !(__has_feature(cxx_auto_type))
211 #define _LIBCPP_HAS_NO_AUTO_TYPE
214 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
215 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
218 #if !(__has_feature(cxx_variadic_templates))
219 #define _LIBCPP_HAS_NO_VARIADICS
222 #if !(__has_feature(cxx_trailing_return))
223 #define _LIBCPP_HAS_NO_TRAILING_RETURN
226 #if !(__has_feature(cxx_generalized_initializers))
227 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
230 #if __has_feature(is_base_of)
231 # define _LIBCP_HAS_IS_BASE_OF
234 // Objective-C++ features (opt-in)
235 #if __has_feature(objc_arc)
236 #define _LIBCPP_HAS_OBJC_ARC
239 #if __has_feature(objc_arc_weak)
240 #define _LIBCPP_HAS_OBJC_ARC_WEAK
241 #define _LIBCPP_HAS_NO_STRONG_ENUMS
244 #if !(__has_feature(cxx_constexpr))
245 #define _LIBCPP_HAS_NO_CONSTEXPR
249 #define _LIBCPP_HAS_QUICK_EXIT
252 #if (__has_feature(cxx_noexcept))
253 # define _NOEXCEPT noexcept
254 # define _NOEXCEPT_(x) noexcept(x)
256 # define _NOEXCEPT throw()
257 # define _NOEXCEPT_(x)
260 #if __has_feature(underlying_type)
261 # define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
264 // Inline namespaces are available in Clang regardless of C++ dialect.
265 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
266 #define _LIBCPP_END_NAMESPACE_STD } }
267 #define _VSTD std::_LIBCPP_NAMESPACE
270 inline namespace _LIBCPP_NAMESPACE {
274 #elif defined(__GNUC__)
276 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
278 #define _ATTRIBUTE(x) __attribute__((x))
281 #define _LIBCPP_NO_EXCEPTIONS
284 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
285 #define _LIBCPP_HAS_NO_CONSTEXPR
287 #define _NOEXCEPT throw()
288 #define _NOEXCEPT_(x)
290 #ifndef __GXX_EXPERIMENTAL_CXX0X__
292 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
293 #define _LIBCPP_HAS_NO_DECLTYPE
294 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
295 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
296 #define _LIBCPP_HAS_NO_NULLPTR
297 #define _LIBCPP_HAS_NO_STATIC_ASSERT
298 #define _LIBCPP_HAS_NO_UNICODE_CHARS
299 #define _LIBCPP_HAS_NO_VARIADICS
300 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
301 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
303 #else // __GXX_EXPERIMENTAL_CXX0X__
305 #define _LIBCPP_HAS_NO_TRAILING_RETURN
306 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
308 #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
309 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
312 #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
313 #define _LIBCPP_HAS_NO_STATIC_ASSERT
316 #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
317 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
318 #define _LIBCPP_HAS_NO_DECLTYPE
319 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
320 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
321 #define _LIBCPP_HAS_NO_UNICODE_CHARS
322 #define _LIBCPP_HAS_NO_VARIADICS
323 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
324 #endif // !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
326 #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6)
327 #define _LIBCPP_HAS_NO_NULLPTR
330 #endif // __GXX_EXPERIMENTAL_CXX0X__
332 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
333 #define _LIBCPP_END_NAMESPACE_STD } }
334 #define _VSTD std::_LIBCPP_NAMESPACE
337 namespace _LIBCPP_NAMESPACE {
339 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
342 #elif defined(_MSC_VER)
344 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
345 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
346 #define _LIBCPP_HAS_NO_CONSTEXPR
347 #define _LIBCPP_HAS_NO_UNICODE_CHARS
348 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
349 #define __alignof__ __alignof
350 #define _ATTRIBUTE __declspec
351 #define _ALIGNAS(x) __declspec(align(x))
352 #define _LIBCPP_HAS_NO_VARIADICS
354 #define _NOEXCEPT throw()
355 #define _NOEXCEPT_(x)
357 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
358 #define _LIBCPP_END_NAMESPACE_STD }
364 #endif // __clang__ || __GNUC___ || _MSC_VER
366 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
367 typedef unsigned short char16_t;
368 typedef unsigned int char32_t;
369 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
371 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
373 template <bool> struct __static_assert_test;
374 template <> struct __static_assert_test<true> {};
375 template <unsigned> struct __static_assert_check {};
376 #define static_assert(__b, __m) \
377 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
378 _LIBCPP_CONCAT(__t, __LINE__)
380 #endif // _LIBCPP_HAS_NO_STATIC_ASSERT
382 #ifdef _LIBCPP_HAS_NO_DECLTYPE
383 #define decltype(x) __typeof__(x)
386 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
387 #define _LIBCPP_CONSTEXPR
389 #define _LIBCPP_CONSTEXPR constexpr
392 #ifndef __has_feature
393 #define __has_feature(__x) 0
396 #if __has_feature(cxx_explicit_conversions)
397 # define _LIBCPP_EXPLICIT explicit
399 # define _LIBCPP_EXPLICIT
402 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
403 #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum _
404 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
406 _LIBCPP_ALWAYS_INLINE x(_ __v) : __v_(__v) {} \
407 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
409 #else // _LIBCPP_HAS_NO_STRONG_ENUMS
410 #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x
411 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
412 #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
414 #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__
415 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
418 #define _DECLARE_C99_LDBL_MATH 1
421 #if __APPLE__ || __FreeBSD__
422 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
425 #if __APPLE__ || __FreeBSD__ || __sun__
426 #define _LIBCPP_WCTYPE_IS_MASK
429 #ifdef _LIBCPP_DEBUG2
430 # if _LIBCPP_DEBUG2 == 0
431 # define _LIBCPP_DEBUG_LEVEL 1
432 # elif _LIBCPP_DEBUG2 == 1
433 # define _LIBCPP_DEBUG_LEVEL 2
435 # error Supported values for _LIBCPP_DEBUG2 are 0 and 1
439 #ifdef _LIBCPP_DEBUG2
442 # define _LIBCPP_ASSERT(x, m) ((void)0)
445 #endif // _LIBCPP_CONFIG