1// -*- C++ -*-
2//===--------------------------- __config ---------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CONFIG
12#define _LIBCPP_CONFIG
13
14#if !_MSC_VER // explicit macro necessary because it is only defined below in this file
15#pragma GCC system_header
16#endif
17
18#define _LIBCPP_VERSION 1001
19
20#define _LIBCPP_ABI_VERSION 1
21
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)
24
25#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
26
27#ifdef __LITTLE_ENDIAN__
28#if __LITTLE_ENDIAN__
29#define _LIBCPP_LITTLE_ENDIAN 1
30#define _LIBCPP_BIG_ENDIAN    0
31#endif  // __LITTLE_ENDIAN__
32#endif  // __LITTLE_ENDIAN__
33
34#ifdef __BIG_ENDIAN__
35#if __BIG_ENDIAN__
36#define _LIBCPP_LITTLE_ENDIAN 0
37#define _LIBCPP_BIG_ENDIAN    1
38#endif  // __BIG_ENDIAN__
39#endif  // __BIG_ENDIAN__
40
41#ifdef __FreeBSD__
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
50#endif  // __FreeBSD__
51
52#ifdef _WIN32
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
58#  endif
59#endif  // _WIN32
60
61#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
62# include <endian.h>
63# if __BYTE_ORDER == __LITTLE_ENDIAN
64#  define _LIBCPP_LITTLE_ENDIAN 1
65#  define _LIBCPP_BIG_ENDIAN    0
66# elif __BYTE_ORDER == __BIG_ENDIAN
67#  define _LIBCPP_LITTLE_ENDIAN 0
68#  define _LIBCPP_BIG_ENDIAN    1
69# else  // __BYTE_ORDER == __BIG_ENDIAN
70#  error unable to determine endian
71# endif
72#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
73
74#if _WIN32
75
76// only really useful for a DLL
77#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
78# ifdef cxx_EXPORTS
79#  define _LIBCPP_HIDDEN
80#  define _LIBCPP_VISIBLE __declspec(dllexport)
81# else
82#  define _LIBCPP_HIDDEN
83#  define _LIBCPP_VISIBLE __declspec(dllimport)
84# endif
85#else
86# define _LIBCPP_HIDDEN
87# define _LIBCPP_VISIBLE
88#endif
89
90#ifndef _LIBCPP_INLINE_VISIBILITY
91# if _MSC_VER
92#  define _LIBCPP_INLINE_VISIBILITY __forceinline
93# else // MinGW GCC and Clang
94#  define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
95# endif
96#endif
97
98#ifndef _LIBCPP_EXCEPTION_ABI
99#define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
100#endif
101
102#ifndef _LIBCPP_ALWAYS_INLINE
103# if _MSC_VER
104#  define _LIBCPP_ALWAYS_INLINE __forceinline
105# endif
106#endif
107
108#endif // _WIN32
109
110#ifndef _LIBCPP_HIDDEN
111#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
112#endif
113
114#ifndef _LIBCPP_VISIBLE
115#define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
116#endif
117
118#ifndef _LIBCPP_INLINE_VISIBILITY
119#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
120#endif
121
122#ifndef _LIBCPP_EXCEPTION_ABI
123#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
124#endif
125
126#ifndef _LIBCPP_CANTTHROW
127#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
128#endif
129
130#ifndef _LIBCPP_ALWAYS_INLINE
131#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
132#endif
133
134#if defined(__clang__)
135
136#if __has_feature(cxx_alignas)
137#  define _ALIGNAS(x) alignas(x)
138#else
139#  define _ALIGNAS(x) __attribute__((__aligned__(x)))
140#endif
141
142#if !__has_feature(cxx_alias_templates)
143#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
144#endif
145
146#ifndef __GXX_EXPERIMENTAL_CXX0X__
147#ifdef __linux__
148#define _LIBCPP_HAS_NO_UNICODE_CHARS
149#else
150typedef __char16_t char16_t;
151typedef __char32_t char32_t;
152#endif
153#endif
154
155#if !(__has_feature(cxx_exceptions))
156#define _LIBCPP_NO_EXCEPTIONS
157#endif
158
159#if !(__has_feature(cxx_rtti))
160#define _LIBCPP_NO_RTTI
161#endif
162
163#if !(__has_feature(cxx_strong_enums))
164#define _LIBCPP_HAS_NO_STRONG_ENUMS
165#endif
166
167#if !(__has_feature(cxx_decltype))
168#define _LIBCPP_HAS_NO_DECLTYPE
169#endif
170
171#if __has_feature(cxx_attributes)
172#  define _ATTRIBUTE(x) [[x]]
173#else
174#  define _ATTRIBUTE(x) __attribute__ ((x))
175#endif
176
177#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
178
179#if !(__has_feature(cxx_deleted_functions))
180#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
181#endif  // !(__has_feature(cxx_deleted_functions))
182
183#if !(__has_feature(cxx_lambdas))
184#define _LIBCPP_HAS_NO_LAMBDAS
185#endif
186
187#if !(__has_feature(cxx_nullptr))
188#define _LIBCPP_HAS_NO_NULLPTR
189#endif
190
191#if !(__has_feature(cxx_rvalue_references))
192#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
193#endif
194
195#if !(__has_feature(cxx_static_assert))
196#define _LIBCPP_HAS_NO_STATIC_ASSERT
197#endif
198
199#if !(__has_feature(cxx_auto_type))
200#define _LIBCPP_HAS_NO_AUTO_TYPE
201#endif
202
203#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
204#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
205#endif
206
207#if !(__has_feature(cxx_variadic_templates))
208#define _LIBCPP_HAS_NO_VARIADICS
209#endif
210
211#if !(__has_feature(cxx_trailing_return))
212#define _LIBCPP_HAS_NO_TRAILING_RETURN
213#endif
214
215#if !(__has_feature(cxx_generalized_initializers))
216#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
217#endif
218
219#if __has_feature(is_base_of)
220#  define _LIBCP_HAS_IS_BASE_OF
221#endif
222
223// Objective-C++ features (opt-in)
224#if __has_feature(objc_arc)
225#define _LIBCPP_HAS_OBJC_ARC
226#endif
227
228#if __has_feature(objc_arc_weak)
229#define _LIBCPP_HAS_OBJC_ARC_WEAK
230#define _LIBCPP_HAS_NO_STRONG_ENUMS
231#endif
232
233#if !(__has_feature(cxx_constexpr))
234#define _LIBCPP_HAS_NO_CONSTEXPR
235#endif
236
237#if (__has_feature(cxx_noexcept))
238#  define _NOEXCEPT noexcept
239#  define _NOEXCEPT_(x) noexcept(x)
240#else
241#  define _NOEXCEPT throw()
242#  define _NOEXCEPT_(x)
243#endif
244
245#if __has_feature(underlying_type)
246#  define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
247#endif
248
249// Inline namespaces are available in Clang regardless of C++ dialect.
250#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
251#define _LIBCPP_END_NAMESPACE_STD  } }
252#define _VSTD std::_LIBCPP_NAMESPACE
253
254namespace std {
255  inline namespace _LIBCPP_NAMESPACE {
256  }
257}
258
259#elif defined(__GNUC__)
260
261#define _ALIGNAS(x) __attribute__((__aligned__(x)))
262
263#define _ATTRIBUTE(x) __attribute__((x))
264
265#if !__EXCEPTIONS
266#define _LIBCPP_NO_EXCEPTIONS
267#endif
268
269#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
270#define _LIBCPP_HAS_NO_CONSTEXPR
271
272#define _NOEXCEPT throw()
273#define _NOEXCEPT_(x)
274
275#ifndef __GXX_EXPERIMENTAL_CXX0X__
276
277#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
278#define _LIBCPP_HAS_NO_DECLTYPE
279#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
280#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
281#define _LIBCPP_HAS_NO_NULLPTR
282#define _LIBCPP_HAS_NO_STATIC_ASSERT
283#define _LIBCPP_HAS_NO_UNICODE_CHARS
284#define _LIBCPP_HAS_NO_VARIADICS
285#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
286#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
287
288#else  // __GXX_EXPERIMENTAL_CXX0X__
289
290#define _LIBCPP_HAS_NO_TRAILING_RETURN
291#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
292
293#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
294#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
295#endif
296
297#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
298#define _LIBCPP_HAS_NO_STATIC_ASSERT
299#endif
300
301#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
302#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
303#define _LIBCPP_HAS_NO_DECLTYPE
304#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
305#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
306#define _LIBCPP_HAS_NO_UNICODE_CHARS
307#define _LIBCPP_HAS_NO_VARIADICS
308#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
309#endif  // !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
310
311#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6)
312#define _LIBCPP_HAS_NO_NULLPTR
313#endif
314
315#endif  // __GXX_EXPERIMENTAL_CXX0X__
316
317#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
318#define _LIBCPP_END_NAMESPACE_STD  } }
319#define _VSTD std::_LIBCPP_NAMESPACE
320
321namespace std {
322namespace _LIBCPP_NAMESPACE {
323}
324using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
325}
326
327#elif defined(_MSC_VER)
328
329#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
330#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
331#define _LIBCPP_HAS_NO_CONSTEXPR
332#define _LIBCPP_HAS_NO_UNICODE_CHARS
333#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
334#define __alignof__ __alignof
335#define _ATTRIBUTE __declspec
336#define _ALIGNAS(x) __declspec(align(x))
337#define _LIBCPP_HAS_NO_VARIADICS
338
339#define _NOEXCEPT throw()
340#define _NOEXCEPT_(x)
341
342#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
343#define _LIBCPP_END_NAMESPACE_STD  }
344#define _VSTD std
345
346namespace std {
347}
348
349#endif // __clang__ || __GNUC___ || _MSC_VER
350
351#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
352typedef unsigned short char16_t;
353typedef unsigned int   char32_t;
354#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
355
356#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
357
358template <bool> struct __static_assert_test;
359template <> struct __static_assert_test<true> {};
360template <unsigned> struct __static_assert_check {};
361#define static_assert(__b, __m) \
362    typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
363    _LIBCPP_CONCAT(__t, __LINE__)
364
365#endif  // _LIBCPP_HAS_NO_STATIC_ASSERT
366
367#ifdef _LIBCPP_HAS_NO_DECLTYPE
368#define decltype(x) __typeof__(x)
369#endif
370
371#ifdef _LIBCPP_HAS_NO_CONSTEXPR
372#define constexpr const
373#endif
374
375#ifndef __has_feature
376#define __has_feature(__x) 0
377#endif
378
379#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
380#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum _
381#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
382    _ __v_; \
383    _LIBCPP_ALWAYS_INLINE x(_ __v) : __v_(__v) {} \
384    _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
385    };
386#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
387#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_VISIBLE x
388#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
389#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
390
391#if __APPLE__ || __FreeBSD__ || _WIN32
392#define _LIBCPP_LOCALE__L_EXTENSIONS 1
393#endif
394#if __FreeBSD__
395#define _DECLARE_C99_LDBL_MATH 1
396#endif
397
398#if __APPLE__ || __FreeBSD__
399#define _LIBCPP_HAS_DEFAULTRUNELOCALE
400#endif
401
402#if __APPLE__ || __FreeBSD__
403#define _LIBCPP_WCTYPE_IS_MASK
404#endif
405
406#ifdef _LIBCPP_DEBUG2
407#   if _LIBCPP_DEBUG2 == 0
408#       define _LIBCPP_DEBUG_LEVEL 1
409#   elif _LIBCPP_DEBUG2 == 1
410#       define _LIBCPP_DEBUG_LEVEL 2
411#   else
412#       error Supported values for _LIBCPP_DEBUG2 are 0 and 1
413#   endif
414#endif
415
416#ifdef _LIBCPP_DEBUG2
417#   include <__debug>
418#else
419#   define _LIBCPP_ASSERT(x, m) ((void)0)
420#endif
421
422#endif  // _LIBCPP_CONFIG
423