]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/libc++/include/__config
MFC r243572:
[FreeBSD/stable/9.git] / contrib / libc++ / include / __config
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 #ifdef __GNUC__
19 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
20 #endif
21
22 #define _LIBCPP_VERSION 1101
23
24 #define _LIBCPP_ABI_VERSION 1
25
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)
28
29 #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
30
31 #ifdef __LITTLE_ENDIAN__
32 #if __LITTLE_ENDIAN__
33 #define _LIBCPP_LITTLE_ENDIAN 1
34 #define _LIBCPP_BIG_ENDIAN    0
35 #endif  // __LITTLE_ENDIAN__
36 #endif  // __LITTLE_ENDIAN__
37
38 #ifdef __BIG_ENDIAN__
39 #if __BIG_ENDIAN__
40 #define _LIBCPP_LITTLE_ENDIAN 0
41 #define _LIBCPP_BIG_ENDIAN    1
42 #endif  // __BIG_ENDIAN__
43 #endif  // __BIG_ENDIAN__
44
45 #ifdef __FreeBSD__
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
57 #endif  // __FreeBSD__
58
59 #ifdef _WIN32
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
66 #  endif
67 #endif  // _WIN32
68
69 #ifdef __sun__
70 # include <sys/isa_defs.h>
71 # ifdef _LITTLE_ENDIAN
72 #   define _LIBCPP_LITTLE_ENDIAN 1
73 #   define _LIBCPP_BIG_ENDIAN    0
74 # else
75 #   define _LIBCPP_LITTLE_ENDIAN 0
76 #   define _LIBCPP_BIG_ENDIAN    1
77 # endif
78 #endif // __sun__
79
80 #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
81 # include <endian.h>
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
90 # endif
91 #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
92
93 #if _WIN32
94
95 // only really useful for a DLL
96 #ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
97 # ifdef cxx_EXPORTS
98 #  define _LIBCPP_HIDDEN
99 #  define _LIBCPP_VISIBLE __declspec(dllexport)
100 # else
101 #  define _LIBCPP_HIDDEN
102 #  define _LIBCPP_VISIBLE __declspec(dllimport)
103 # endif
104 #else
105 # define _LIBCPP_HIDDEN
106 # define _LIBCPP_VISIBLE
107 #endif
108
109 #ifndef _LIBCPP_INLINE_VISIBILITY
110 # if _MSC_VER
111 #  define _LIBCPP_INLINE_VISIBILITY __forceinline
112 # else // MinGW GCC and Clang
113 #  define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
114 # endif
115 #endif
116
117 #ifndef _LIBCPP_EXCEPTION_ABI
118 #define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBLE
119 #endif
120
121 #ifndef _LIBCPP_ALWAYS_INLINE
122 # if _MSC_VER
123 #  define _LIBCPP_ALWAYS_INLINE __forceinline
124 # endif
125 #endif
126
127 #endif // _WIN32
128
129 #ifndef _LIBCPP_HIDDEN
130 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
131 #endif
132
133 #ifndef _LIBCPP_VISIBLE
134 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
135 #endif
136
137 #ifndef _LIBCPP_INLINE_VISIBILITY
138 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
139 #endif
140
141 #ifndef _LIBCPP_EXCEPTION_ABI
142 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
143 #endif
144
145 #ifndef _LIBCPP_CANTTHROW
146 #define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
147 #endif
148
149 #ifndef _LIBCPP_ALWAYS_INLINE
150 #define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
151 #endif
152
153 #if defined(__clang__)
154
155 #if __has_feature(cxx_alignas)
156 #  define _ALIGNAS_TYPE(x) alignas(x)
157 #  define _ALIGNAS(x) alignas(x)
158 #else
159 #  define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
160 #  define _ALIGNAS(x) __attribute__((__aligned__(x)))
161 #endif
162
163 #if !__has_feature(cxx_alias_templates)
164 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
165 #endif
166
167 #ifndef __GXX_EXPERIMENTAL_CXX0X__
168 #ifdef __linux__
169 #define _LIBCPP_HAS_NO_UNICODE_CHARS
170 #else
171 typedef __char16_t char16_t;
172 typedef __char32_t char32_t;
173 #endif
174 #endif
175
176 #if !(__has_feature(cxx_exceptions))
177 #define _LIBCPP_NO_EXCEPTIONS
178 #endif
179
180 #if !(__has_feature(cxx_rtti))
181 #define _LIBCPP_NO_RTTI
182 #endif
183
184 #if !(__has_feature(cxx_strong_enums))
185 #define _LIBCPP_HAS_NO_STRONG_ENUMS
186 #endif
187
188 #if !(__has_feature(cxx_decltype))
189 #define _LIBCPP_HAS_NO_DECLTYPE
190 #endif
191
192 #if __has_feature(cxx_attributes)
193 #  define _LIBCPP_NORETURN [[noreturn]]
194 #else
195 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
196 #endif
197
198 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
199
200 #if !(__has_feature(cxx_deleted_functions))
201 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
202 #endif  // !(__has_feature(cxx_deleted_functions))
203
204 #if !(__has_feature(cxx_lambdas))
205 #define _LIBCPP_HAS_NO_LAMBDAS
206 #endif
207
208 #if !(__has_feature(cxx_nullptr))
209 #define _LIBCPP_HAS_NO_NULLPTR
210 #endif
211
212 #if !(__has_feature(cxx_rvalue_references))
213 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
214 #endif
215
216 #if !(__has_feature(cxx_static_assert))
217 #define _LIBCPP_HAS_NO_STATIC_ASSERT
218 #endif
219
220 #if !(__has_feature(cxx_auto_type))
221 #define _LIBCPP_HAS_NO_AUTO_TYPE
222 #endif
223
224 #if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
225 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
226 #endif
227
228 #if !(__has_feature(cxx_variadic_templates))
229 #define _LIBCPP_HAS_NO_VARIADICS
230 #endif
231
232 #if !(__has_feature(cxx_trailing_return))
233 #define _LIBCPP_HAS_NO_TRAILING_RETURN
234 #endif
235
236 #if !(__has_feature(cxx_generalized_initializers))
237 #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
238 #endif
239
240 #if __has_feature(is_base_of)
241 #  define _LIBCP_HAS_IS_BASE_OF
242 #endif
243
244 // Objective-C++ features (opt-in)
245 #if __has_feature(objc_arc)
246 #define _LIBCPP_HAS_OBJC_ARC
247 #endif
248
249 #if __has_feature(objc_arc_weak)
250 #define _LIBCPP_HAS_OBJC_ARC_WEAK
251 #define _LIBCPP_HAS_NO_STRONG_ENUMS
252 #endif
253
254 #if !(__has_feature(cxx_constexpr))
255 #define _LIBCPP_HAS_NO_CONSTEXPR
256 #endif
257
258 #if __FreeBSD__ && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
259 #define _LIBCPP_HAS_QUICK_EXIT
260 #define _LIBCPP_HAS_C11_FEATURES
261 #endif
262
263 #if (__has_feature(cxx_noexcept))
264 #  define _NOEXCEPT noexcept
265 #  define _NOEXCEPT_(x) noexcept(x)
266 #else
267 #  define _NOEXCEPT throw()
268 #  define _NOEXCEPT_(x)
269 #endif
270
271 #if __has_feature(underlying_type)
272 #  define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
273 #endif
274
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
279
280 namespace std {
281   inline namespace _LIBCPP_NAMESPACE {
282   }
283 }
284
285 #elif defined(__GNUC__)
286
287 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
288 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
289
290 #define _LIBCPP_NORETURN __attribute__((noreturn))
291
292 #if !__EXCEPTIONS
293 #define _LIBCPP_NO_EXCEPTIONS
294 #endif
295
296 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
297 #define _LIBCPP_HAS_NO_CONSTEXPR
298
299 #define _NOEXCEPT throw()
300 #define _NOEXCEPT_(x)
301
302 #ifndef __GXX_EXPERIMENTAL_CXX0X__
303
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
314
315 #else  // __GXX_EXPERIMENTAL_CXX0X__
316
317 #define _LIBCPP_HAS_NO_TRAILING_RETURN
318 #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
319
320 #if _GNUC_VER < 403
321 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
322 #endif
323
324 #if _GNUC_VER < 403
325 #define _LIBCPP_HAS_NO_STATIC_ASSERT
326 #endif
327
328 #if _GNUC_VER < 404
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
337
338 #if _GNUC_VER < 406
339 #define _LIBCPP_HAS_NO_NULLPTR
340 #endif
341
342 #endif  // __GXX_EXPERIMENTAL_CXX0X__
343
344 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
345 #define _LIBCPP_END_NAMESPACE_STD  } }
346 #define _VSTD std::_LIBCPP_NAMESPACE
347
348 namespace std {
349 namespace _LIBCPP_NAMESPACE {
350 }
351 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
352 }
353
354 #elif defined(_MSC_VER)
355
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
365
366 #define _NOEXCEPT throw()
367 #define _NOEXCEPT_(x)
368
369 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
370 #define _LIBCPP_END_NAMESPACE_STD  }
371 #define _VSTD std
372
373 namespace std {
374 }
375
376 #endif // __clang__ || __GNUC___ || _MSC_VER
377
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
382
383 #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
384
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__)
391
392 #endif  // _LIBCPP_HAS_NO_STATIC_ASSERT
393
394 #ifdef _LIBCPP_HAS_NO_DECLTYPE
395 #define decltype(x) __typeof__(x)
396 #endif
397
398 #ifdef _LIBCPP_HAS_NO_CONSTEXPR
399 #define _LIBCPP_CONSTEXPR
400 #else
401 #define _LIBCPP_CONSTEXPR constexpr
402 #endif
403
404 #ifdef __GNUC__
405 #define _NOALIAS __attribute__((malloc))
406 #else
407 #define _NOALIAS
408 #endif
409
410 #ifndef __has_feature
411 #define __has_feature(__x) 0
412 #endif
413
414 #if __has_feature(cxx_explicit_conversions)
415 #   define _LIBCPP_EXPLICIT explicit
416 #else
417 #   define _LIBCPP_EXPLICIT
418 #endif
419
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) \
423     __lx __v_; \
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_;} \
427     };
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
432
433 #ifndef _LIBCPP_EXTERN_TEMPLATE
434 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
435 #endif
436
437 #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__
438 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
439 #endif
440 #if __FreeBSD__
441 #define _DECLARE_C99_LDBL_MATH 1
442 #endif
443
444 #if __APPLE__ || __FreeBSD__
445 #define _LIBCPP_HAS_DEFAULTRUNELOCALE
446 #endif
447
448 #if __APPLE__ || __FreeBSD__ || __sun__
449 #define _LIBCPP_WCTYPE_IS_MASK
450 #endif
451
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
457 #   else
458 #       error Supported values for _LIBCPP_DEBUG2 are 0 and 1
459 #   endif
460 #endif
461
462 #ifdef _LIBCPP_DEBUG2
463 #   include <__debug>
464 #else
465 #   define _LIBCPP_ASSERT(x, m) ((void)0)
466 #endif
467
468 #endif  // _LIBCPP_CONFIG