blob: 56326af1af85264473c194357dfbdbb6561d27b3 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- __config ---------------------------------===//
3//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00005//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CONFIG
12#define _LIBCPP_CONFIG
13
Eric Fiselier60506cb2015-11-06 06:30:12 +000014#if defined(_MSC_VER) && !defined(__clang__)
15#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16#endif
17
18#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
Howard Hinnant3e519522010-05-11 19:42:16 +000019#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10 +000020#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000021
Eric Fiselier60506cb2015-11-06 06:30:12 +000022#ifdef __cplusplus
23
Howard Hinnantf543a752012-10-03 20:48:05 +000024#ifdef __GNUC__
25#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
Eric Fiselier678ad2f2015-06-13 02:18:44 +000026#else
27#define _GNUC_VER 0
Howard Hinnantf543a752012-10-03 20:48:05 +000028#endif
29
Marshall Clow258a6512016-07-18 20:27:19 +000030#define _LIBCPP_VERSION 4000
Howard Hinnant3e519522010-05-11 19:42:16 +000031
Evgeniy Stepanova66a7b32015-10-13 23:48:28 +000032#ifndef _LIBCPP_ABI_VERSION
Howard Hinnant3e519522010-05-11 19:42:16 +000033#define _LIBCPP_ABI_VERSION 1
Evgeniy Stepanova66a7b32015-10-13 23:48:28 +000034#endif
35
36#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
Eric Fiselier9e1b0b52016-09-25 03:14:13 +000037#define _LIBCPP_ABI_EXTERN_TEMPLATE_SYMBOLS_VERSION 2
Shoaib Meenai4f671372016-09-12 20:14:44 +000038// Change short string representation so that string data starts at offset 0,
Evgeniy Stepanov65da7bc2015-11-06 22:02:29 +000039// improving its alignment in some cases.
Evgeniy Stepanova66a7b32015-10-13 23:48:28 +000040#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Evgeniy Stepanov65da7bc2015-11-06 22:02:29 +000041// Fix deque iterator type in order to support incomplete types.
42#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
Eric Fiselierb88ea352015-12-30 20:57:59 +000043// Fix undefined behavior in how std::list stores it's linked nodes.
44#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
Eric Fiselierd05b10a2016-07-19 17:56:20 +000045// Fix undefined behavior in how __tree stores its end and parent nodes.
46#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
Eric Fiselier40492ba2016-07-23 20:36:55 +000047// Fix undefined behavior in how __hash_table stores it's pointer types
48#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
Eric Fiselier07b9cd32016-01-27 00:11:54 +000049#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
Eric Fiselier75d0dcf2016-02-10 20:46:23 +000050#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
Eric Fiselier48f35e02016-06-14 03:48:09 +000051#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
Eric Fiselier35b64132016-07-18 01:58:37 +000052#elif _LIBCPP_ABI_VERSION == 1
Eric Fiselier9e1b0b52016-09-25 03:14:13 +000053#define _LIBCPP_ABI_EXTERN_TEMPLATE_SYMBOLS_VERSION 1
Eric Fiselier35b64132016-07-18 01:58:37 +000054// Feature macros for disabling pre ABI v1 features. All of these options
55// are deprecated.
56#if defined(__FreeBSD__)
57#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
58#endif
59#endif
60
61#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
62#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \
63 use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead
Evgeniy Stepanova66a7b32015-10-13 23:48:28 +000064#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000065
66#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
67#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
68
69#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
70
Eric Fiseliere825d8b2015-07-10 20:26:38 +000071
72#ifndef __has_attribute
73#define __has_attribute(__x) 0
74#endif
75#ifndef __has_builtin
76#define __has_builtin(__x) 0
77#endif
Eric Fiselier749adeb2015-08-19 17:21:46 +000078#ifndef __has_extension
79#define __has_extension(__x) 0
80#endif
Eric Fiseliere825d8b2015-07-10 20:26:38 +000081#ifndef __has_feature
82#define __has_feature(__x) 0
83#endif
84// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
85// the compiler and '1' otherwise.
86#ifndef __is_identifier
87#define __is_identifier(__x) 1
88#endif
89
Dan Albertc9917092016-09-19 18:00:45 +000090// Need to detect which libc we're using if we're on Linux.
91#if defined(__linux__)
92#include <features.h>
93#if !defined(__GLIBC_PREREQ)
94#define __GLIBC_PREREQ(a, b) 0
95#endif // !defined(__GLIBC_PREREQ)
96#endif // defined(__linux__)
Eric Fiseliere825d8b2015-07-10 20:26:38 +000097
Howard Hinnant3e519522010-05-11 19:42:16 +000098#ifdef __LITTLE_ENDIAN__
99#if __LITTLE_ENDIAN__
100#define _LIBCPP_LITTLE_ENDIAN 1
101#define _LIBCPP_BIG_ENDIAN 0
Howard Hinnantb3371f62010-08-22 00:02:43 +0000102#endif // __LITTLE_ENDIAN__
103#endif // __LITTLE_ENDIAN__
Howard Hinnant3e519522010-05-11 19:42:16 +0000104
105#ifdef __BIG_ENDIAN__
106#if __BIG_ENDIAN__
107#define _LIBCPP_LITTLE_ENDIAN 0
108#define _LIBCPP_BIG_ENDIAN 1
Howard Hinnantb3371f62010-08-22 00:02:43 +0000109#endif // __BIG_ENDIAN__
110#endif // __BIG_ENDIAN__
Howard Hinnant3e519522010-05-11 19:42:16 +0000111
Dan Albert5e61cfd2015-09-16 18:10:47 +0000112#ifdef __BYTE_ORDER__
113#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
114#define _LIBCPP_LITTLE_ENDIAN 1
115#define _LIBCPP_BIG_ENDIAN 0
116#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
117#define _LIBCPP_LITTLE_ENDIAN 0
118#define _LIBCPP_BIG_ENDIAN 1
119#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
120#endif // __BYTE_ORDER__
121
David Chisnall2a072dd2010-08-11 16:27:20 +0000122#ifdef __FreeBSD__
123# include <sys/endian.h>
124# if _BYTE_ORDER == _LITTLE_ENDIAN
125# define _LIBCPP_LITTLE_ENDIAN 1
126# define _LIBCPP_BIG_ENDIAN 0
Howard Hinnantb3371f62010-08-22 00:02:43 +0000127# else // _BYTE_ORDER == _LITTLE_ENDIAN
David Chisnall2a072dd2010-08-11 16:27:20 +0000128# define _LIBCPP_LITTLE_ENDIAN 0
129# define _LIBCPP_BIG_ENDIAN 1
Howard Hinnantb3371f62010-08-22 00:02:43 +0000130# endif // _BYTE_ORDER == _LITTLE_ENDIAN
Howard Hinnantf8b24cf2012-11-26 21:18:17 +0000131# ifndef __LONG_LONG_SUPPORTED
132# define _LIBCPP_HAS_NO_LONG_LONG
133# endif // __LONG_LONG_SUPPORTED
Howard Hinnantb3371f62010-08-22 00:02:43 +0000134#endif // __FreeBSD__
David Chisnall2a072dd2010-08-11 16:27:20 +0000135
Joerg Sonnenberger50544e72013-05-17 21:17:34 +0000136#ifdef __NetBSD__
137# include <sys/endian.h>
138# if _BYTE_ORDER == _LITTLE_ENDIAN
139# define _LIBCPP_LITTLE_ENDIAN 1
140# define _LIBCPP_BIG_ENDIAN 0
141# else // _BYTE_ORDER == _LITTLE_ENDIAN
142# define _LIBCPP_LITTLE_ENDIAN 0
143# define _LIBCPP_BIG_ENDIAN 1
144# endif // _BYTE_ORDER == _LITTLE_ENDIAN
145# define _LIBCPP_HAS_QUICK_EXIT
146#endif // __NetBSD__
147
Howard Hinnant3e714642011-05-13 17:16:06 +0000148#ifdef _WIN32
149# define _LIBCPP_LITTLE_ENDIAN 1
150# define _LIBCPP_BIG_ENDIAN 0
Eric Fiselieree187e22015-06-13 07:08:02 +0000151// Compiler intrinsics (MSVC)
152#if defined(_MSC_VER) && _MSC_VER >= 1400
Howard Hinnant0be8f642013-08-01 18:17:34 +0000153# define _LIBCPP_HAS_IS_BASE_OF
Howard Hinnant3c78ca02011-09-22 19:10:18 +0000154# endif
Howard Hinnant0be8f642013-08-01 18:17:34 +0000155# if defined(_MSC_VER) && !defined(__clang__)
156# define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
Howard Hinnant80b84d42013-10-04 21:14:44 +0000157# define _LIBCPP_TOSTRING2(x) #x
158# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
159# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
Howard Hinnant0be8f642013-08-01 18:17:34 +0000160# endif
Howard Hinnant5f878d42013-09-17 01:34:47 +0000161# // If mingw not explicitly detected, assume using MS C runtime only.
162# ifndef __MINGW32__
163# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
164# endif
Howard Hinnant3e714642011-05-13 17:16:06 +0000165#endif // _WIN32
166
David Chisnall14c25b82012-02-29 13:05:08 +0000167#ifdef __sun__
168# include <sys/isa_defs.h>
169# ifdef _LITTLE_ENDIAN
170# define _LIBCPP_LITTLE_ENDIAN 1
171# define _LIBCPP_BIG_ENDIAN 0
172# else
173# define _LIBCPP_LITTLE_ENDIAN 0
174# define _LIBCPP_BIG_ENDIAN 1
175# endif
176#endif // __sun__
177
Ed Schouten17f5dbe2015-03-10 07:46:06 +0000178#if defined(__CloudABI__)
179 // Certain architectures provide arc4random(). Prefer using
180 // arc4random() over /dev/{u,}random to make it possible to obtain
181 // random data even when using sandboxing mechanisms such as chroots,
182 // Capsicum, etc.
183# define _LIBCPP_USING_ARC4_RANDOM
184#elif defined(__native_client__)
JF Bastien57148cb2014-12-01 19:19:55 +0000185 // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
186 // including accesses to the special files under /dev. C++11's
187 // std::random_device is instead exposed through a NaCl syscall.
188# define _LIBCPP_USING_NACL_RANDOM
Ed Schouten17f5dbe2015-03-10 07:46:06 +0000189#elif defined(_WIN32)
190# define _LIBCPP_USING_WIN32_RANDOM
191#else
192# define _LIBCPP_USING_DEV_RANDOM
193#endif
JF Bastien57148cb2014-12-01 19:19:55 +0000194
Howard Hinnant3e519522010-05-11 19:42:16 +0000195#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
Howard Hinnant128ba712010-05-24 17:49:41 +0000196# include <endian.h>
197# if __BYTE_ORDER == __LITTLE_ENDIAN
198# define _LIBCPP_LITTLE_ENDIAN 1
199# define _LIBCPP_BIG_ENDIAN 0
200# elif __BYTE_ORDER == __BIG_ENDIAN
201# define _LIBCPP_LITTLE_ENDIAN 0
202# define _LIBCPP_BIG_ENDIAN 1
Howard Hinnantb3371f62010-08-22 00:02:43 +0000203# else // __BYTE_ORDER == __BIG_ENDIAN
Howard Hinnant128ba712010-05-24 17:49:41 +0000204# error unable to determine endian
205# endif
Howard Hinnantb3371f62010-08-22 00:02:43 +0000206#endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
Howard Hinnant3e519522010-05-11 19:42:16 +0000207
Evgeniy Stepanov3e58a6a2016-02-10 21:53:28 +0000208#if __has_attribute(__no_sanitize__)
209#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
210#else
211#define _LIBCPP_NO_CFI
212#endif
213
Howard Hinnanteb269252010-08-10 20:48:29 +0000214#if defined(__clang__)
215
Evgeniy Stepanova66a7b32015-10-13 23:48:28 +0000216// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
217// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
218#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
219 !defined(__arm__)) || \
220 defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
221#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
Tim Northoverc3a57e92014-03-30 11:34:22 +0000222#endif
223
Howard Hinnant073458b2011-10-17 20:05:10 +0000224#if __has_feature(cxx_alignas)
Howard Hinnantbf33f5b2012-05-31 19:31:14 +0000225# define _ALIGNAS_TYPE(x) alignas(x)
Howard Hinnant073458b2011-10-17 20:05:10 +0000226# define _ALIGNAS(x) alignas(x)
227#else
Howard Hinnant78b40152012-05-31 20:14:00 +0000228# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
Howard Hinnant073458b2011-10-17 20:05:10 +0000229# define _ALIGNAS(x) __attribute__((__aligned__(x)))
230#endif
231
Howard Hinnant411d1bc2011-05-26 19:07:54 +0000232#if !__has_feature(cxx_alias_templates)
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000233#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnant411d1bc2011-05-26 19:07:54 +0000234#endif
Howard Hinnant01fd3102010-09-07 20:31:18 +0000235
Marshall Clow31be78b2014-02-22 15:13:48 +0000236#if __cplusplus < 201103L
Howard Hinnantd8e79222010-09-16 23:27:26 +0000237typedef __char16_t char16_t;
238typedef __char32_t char32_t;
Howard Hinnant01fd3102010-09-07 20:31:18 +0000239#endif
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000240
Weiming Zhaod69a6d22016-04-21 05:28:18 +0000241#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
Howard Hinnanteb269252010-08-10 20:48:29 +0000242#define _LIBCPP_NO_EXCEPTIONS
243#endif
244
Howard Hinnant54b409f2010-08-11 17:04:31 +0000245#if !(__has_feature(cxx_rtti))
246#define _LIBCPP_NO_RTTI
247#endif
248
Howard Hinnant75689c12011-12-02 19:36:40 +0000249#if !(__has_feature(cxx_strong_enums))
250#define _LIBCPP_HAS_NO_STRONG_ENUMS
251#endif
252
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000253#if !(__has_feature(cxx_decltype))
254#define _LIBCPP_HAS_NO_DECLTYPE
255#endif
256
Howard Hinnant400b2442011-05-26 17:07:32 +0000257#if __has_feature(cxx_attributes)
Richard Smith535a86c2012-07-26 02:04:22 +0000258# define _LIBCPP_NORETURN [[noreturn]]
Howard Hinnant400b2442011-05-26 17:07:32 +0000259#else
Richard Smith535a86c2012-07-26 02:04:22 +0000260# define _LIBCPP_NORETURN __attribute__ ((noreturn))
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000261#endif
262
Eric Fiselier7a608aa2015-12-23 08:20:26 +0000263#if !(__has_feature(cxx_default_function_template_args))
264#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
265#endif
266
Howard Hinnantda9ca0b2013-05-02 20:18:43 +0000267#if !(__has_feature(cxx_defaulted_functions))
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000268#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
Howard Hinnantda9ca0b2013-05-02 20:18:43 +0000269#endif // !(__has_feature(cxx_defaulted_functions))
Howard Hinnant73873902010-09-29 18:13:54 +0000270
271#if !(__has_feature(cxx_deleted_functions))
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000272#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
273#endif // !(__has_feature(cxx_deleted_functions))
274
275#if !(__has_feature(cxx_lambdas))
276#define _LIBCPP_HAS_NO_LAMBDAS
277#endif
278
279#if !(__has_feature(cxx_nullptr))
280#define _LIBCPP_HAS_NO_NULLPTR
281#endif
282
283#if !(__has_feature(cxx_rvalue_references))
284#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
285#endif
286
287#if !(__has_feature(cxx_static_assert))
288#define _LIBCPP_HAS_NO_STATIC_ASSERT
289#endif
290
291#if !(__has_feature(cxx_auto_type))
292#define _LIBCPP_HAS_NO_AUTO_TYPE
Howard Hinnant89bdcd72011-07-29 21:35:53 +0000293#endif
294
Howard Hinnant2425d532011-07-31 17:10:44 +0000295#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
Howard Hinnant08ad63b2011-05-11 20:19:40 +0000296#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000297#endif
298
299#if !(__has_feature(cxx_variadic_templates))
300#define _LIBCPP_HAS_NO_VARIADICS
301#endif
Howard Hinnanteb269252010-08-10 20:48:29 +0000302
Howard Hinnantc4931c42010-11-16 21:10:23 +0000303#if !(__has_feature(cxx_trailing_return))
304#define _LIBCPP_HAS_NO_TRAILING_RETURN
305#endif
306
Howard Hinnant54976f22011-08-12 21:56:02 +0000307#if !(__has_feature(cxx_generalized_initializers))
308#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
309#endif
310
Howard Hinnant3c78ca02011-09-22 19:10:18 +0000311#if __has_feature(is_base_of)
Howard Hinnant0be8f642013-08-01 18:17:34 +0000312# define _LIBCPP_HAS_IS_BASE_OF
Howard Hinnant3c78ca02011-09-22 19:10:18 +0000313#endif
314
Eric Fiselieree187e22015-06-13 07:08:02 +0000315#if __has_feature(is_final)
316# define _LIBCPP_HAS_IS_FINAL
317#endif
318
Douglas Gregor64ec1012011-06-22 22:17:44 +0000319// Objective-C++ features (opt-in)
320#if __has_feature(objc_arc)
321#define _LIBCPP_HAS_OBJC_ARC
322#endif
323
324#if __has_feature(objc_arc_weak)
325#define _LIBCPP_HAS_OBJC_ARC_WEAK
Howard Hinnant75689c12011-12-02 19:36:40 +0000326#define _LIBCPP_HAS_NO_STRONG_ENUMS
Douglas Gregor64ec1012011-06-22 22:17:44 +0000327#endif
328
Howard Hinnantdb3e9972010-09-06 19:10:31 +0000329#if !(__has_feature(cxx_constexpr))
330#define _LIBCPP_HAS_NO_CONSTEXPR
331#endif
332
Eric Fiselier371aac12014-07-17 05:16:18 +0000333#if !(__has_feature(cxx_relaxed_constexpr))
334#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
335#endif
336
Marshall Clow2d832d22015-03-17 15:30:22 +0000337#if !(__has_feature(cxx_variable_templates))
338#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
339#endif
340
David Blaikief13dbe42013-05-13 21:53:44 +0000341#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
342#if defined(__FreeBSD__)
David Chisnall5f13d662012-03-14 14:10:37 +0000343#define _LIBCPP_HAS_QUICK_EXIT
Howard Hinnant7ba81602012-10-13 18:03:53 +0000344#define _LIBCPP_HAS_C11_FEATURES
David Blaikief13dbe42013-05-13 21:53:44 +0000345#elif defined(__linux__)
Vasileios Kalintiris8c58e922015-11-09 10:21:04 +0000346#if !defined(_LIBCPP_HAS_MUSL_LIBC)
Dan Albertc9917092016-09-19 18:00:45 +0000347#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
David Blaikief13dbe42013-05-13 21:53:44 +0000348#define _LIBCPP_HAS_QUICK_EXIT
349#endif
350#if __GLIBC_PREREQ(2, 17)
351#define _LIBCPP_HAS_C11_FEATURES
352#endif
Vasileios Kalintiris8c58e922015-11-09 10:21:04 +0000353#else // defined(_LIBCPP_HAS_MUSL_LIBC)
354#define _LIBCPP_HAS_QUICK_EXIT
355#define _LIBCPP_HAS_C11_FEATURES
David Blaikief13dbe42013-05-13 21:53:44 +0000356#endif
Vasileios Kalintiris8c58e922015-11-09 10:21:04 +0000357#endif // __linux__
David Chisnall5f13d662012-03-14 14:10:37 +0000358#endif
359
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000360#if !(__has_feature(cxx_noexcept))
361#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnant08ad63b2011-05-11 20:19:40 +0000362#endif
363
Alexis Hunt397d7872011-07-18 18:37:21 +0000364#if __has_feature(underlying_type)
Marshall Clow157a8f92014-06-26 01:07:56 +0000365# define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
366#endif
367
368#if __has_feature(is_literal)
369# define _LIBCPP_IS_LITERAL(T) __is_literal(T)
Alexis Hunt397d7872011-07-18 18:37:21 +0000370#endif
371
Howard Hinnant073458b2011-10-17 20:05:10 +0000372// Inline namespaces are available in Clang regardless of C++ dialect.
373#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
374#define _LIBCPP_END_NAMESPACE_STD } }
375#define _VSTD std::_LIBCPP_NAMESPACE
376
377namespace std {
378 inline namespace _LIBCPP_NAMESPACE {
379 }
380}
Howard Hinnanteb269252010-08-10 20:48:29 +0000381
Marshall Clow91c71dd2014-04-14 15:44:57 +0000382#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
383#define _LIBCPP_HAS_NO_ASAN
384#endif
385
Marshall Clow7087a512016-01-12 00:38:04 +0000386// Allow for build-time disabling of unsigned integer sanitization
Jonathan Roelofs8dfe5042016-01-13 23:27:08 +0000387#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
Saleem Abdulrasool38fc9fe2016-02-09 04:05:37 +0000388#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
Marshall Clow7087a512016-01-12 00:38:04 +0000389#endif
390
Howard Hinnanteb269252010-08-10 20:48:29 +0000391#elif defined(__GNUC__)
392
Howard Hinnant073458b2011-10-17 20:05:10 +0000393#define _ALIGNAS(x) __attribute__((__aligned__(x)))
Howard Hinnanta3b7a802012-08-19 17:14:47 +0000394#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
Howard Hinnant073458b2011-10-17 20:05:10 +0000395
Richard Smith535a86c2012-07-26 02:04:22 +0000396#define _LIBCPP_NORETURN __attribute__((noreturn))
Howard Hinnantf5c91472011-05-31 13:13:49 +0000397
Marshall Clow157a8f92014-06-26 01:07:56 +0000398#if _GNUC_VER >= 407
399#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
400#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
Eric Fiselieree187e22015-06-13 07:08:02 +0000401#define _LIBCPP_HAS_IS_FINAL
402#endif
403
404#if defined(__GNUC__) && _GNUC_VER >= 403
405# define _LIBCPP_HAS_IS_BASE_OF
Marshall Clow157a8f92014-06-26 01:07:56 +0000406#endif
407
Howard Hinnanteb269252010-08-10 20:48:29 +0000408#if !__EXCEPTIONS
409#define _LIBCPP_NO_EXCEPTIONS
410#endif
411
Nico Weber1d1b46c2014-06-04 15:46:56 +0000412// constexpr was added to GCC in 4.6.
413#if _GNUC_VER < 406
Howard Hinnantdb3e9972010-09-06 19:10:31 +0000414#define _LIBCPP_HAS_NO_CONSTEXPR
Nico Weber1d1b46c2014-06-04 15:46:56 +0000415// Can only use constexpr in c++11 mode.
416#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
417#define _LIBCPP_HAS_NO_CONSTEXPR
418#endif
Howard Hinnanteb269252010-08-10 20:48:29 +0000419
Marshall Clow1c452672015-10-20 07:37:11 +0000420// Determine if GCC supports relaxed constexpr
421#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
Eric Fiselier371aac12014-07-17 05:16:18 +0000422#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clow1c452672015-10-20 07:37:11 +0000423#endif
424
Marshall Clow2d832d22015-03-17 15:30:22 +0000425// GCC 5 will support variable templates
Eric Fiselier831c1122015-12-15 00:32:21 +0000426#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
Marshall Clow2d832d22015-03-17 15:30:22 +0000427#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Eric Fiselier831c1122015-12-15 00:32:21 +0000428#endif
Eric Fiselier371aac12014-07-17 05:16:18 +0000429
Howard Hinnanteb269252010-08-10 20:48:29 +0000430#ifndef __GXX_EXPERIMENTAL_CXX0X__
431
432#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
433#define _LIBCPP_HAS_NO_DECLTYPE
Eric Fiselier7a608aa2015-12-23 08:20:26 +0000434#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
Howard Hinnanteb269252010-08-10 20:48:29 +0000435#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
436#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
437#define _LIBCPP_HAS_NO_NULLPTR
438#define _LIBCPP_HAS_NO_STATIC_ASSERT
439#define _LIBCPP_HAS_NO_UNICODE_CHARS
440#define _LIBCPP_HAS_NO_VARIADICS
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000441#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
Logan Chienca839212013-12-14 06:44:09 +0000442#define _LIBCPP_HAS_NO_STRONG_ENUMS
Eric Fiselierfcd02212016-02-11 11:59:44 +0000443#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000444#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnanteb269252010-08-10 20:48:29 +0000445
Howard Hinnantb3371f62010-08-22 00:02:43 +0000446#else // __GXX_EXPERIMENTAL_CXX0X__
Howard Hinnanteb269252010-08-10 20:48:29 +0000447
Howard Hinnantf543a752012-10-03 20:48:05 +0000448#if _GNUC_VER < 403
Eric Fiselier7a608aa2015-12-23 08:20:26 +0000449#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
Howard Hinnant7609c9b2010-09-04 23:28:19 +0000450#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant3e519522010-05-11 19:42:16 +0000451#define _LIBCPP_HAS_NO_STATIC_ASSERT
452#endif
453
Eric Fiselier7a608aa2015-12-23 08:20:26 +0000454
Howard Hinnantf543a752012-10-03 20:48:05 +0000455#if _GNUC_VER < 404
Howard Hinnanteb269252010-08-10 20:48:29 +0000456#define _LIBCPP_HAS_NO_DECLTYPE
Howard Hinnanteb269252010-08-10 20:48:29 +0000457#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Eric Fiselier831c1122015-12-15 00:32:21 +0000458#define _LIBCPP_HAS_NO_TRAILING_RETURN
Howard Hinnanteb269252010-08-10 20:48:29 +0000459#define _LIBCPP_HAS_NO_UNICODE_CHARS
460#define _LIBCPP_HAS_NO_VARIADICS
Howard Hinnant54976f22011-08-12 21:56:02 +0000461#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantf543a752012-10-03 20:48:05 +0000462#endif // _GNUC_VER < 404
Howard Hinnant3e519522010-05-11 19:42:16 +0000463
Howard Hinnantf543a752012-10-03 20:48:05 +0000464#if _GNUC_VER < 406
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000465#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnanteb269252010-08-10 20:48:29 +0000466#define _LIBCPP_HAS_NO_NULLPTR
Eric Fiselierfcd02212016-02-11 11:59:44 +0000467#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnant3e519522010-05-11 19:42:16 +0000468#endif
469
Yaron Kerene050d662013-11-22 09:22:12 +0000470#if _GNUC_VER < 407
471#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
472#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
473#endif
474
Howard Hinnantb3371f62010-08-22 00:02:43 +0000475#endif // __GXX_EXPERIMENTAL_CXX0X__
Howard Hinnanteb269252010-08-10 20:48:29 +0000476
Howard Hinnant3e519522010-05-11 19:42:16 +0000477#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
478#define _LIBCPP_END_NAMESPACE_STD } }
Howard Hinnantce48a112011-06-30 21:18:19 +0000479#define _VSTD std::_LIBCPP_NAMESPACE
Howard Hinnant3e519522010-05-11 19:42:16 +0000480
481namespace std {
482namespace _LIBCPP_NAMESPACE {
483}
484using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
485}
486
Marshall Clow91c71dd2014-04-14 15:44:57 +0000487#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
488#define _LIBCPP_HAS_NO_ASAN
489#endif
490
Howard Hinnant0be8f642013-08-01 18:17:34 +0000491#elif defined(_LIBCPP_MSVC)
Howard Hinnant073458b2011-10-17 20:05:10 +0000492
Howard Hinnante4383372011-10-22 20:59:45 +0000493#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnant073458b2011-10-17 20:05:10 +0000494#define _LIBCPP_HAS_NO_CONSTEXPR
Eric Fiselier371aac12014-07-17 05:16:18 +0000495#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
Marshall Clow2d832d22015-03-17 15:30:22 +0000496#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnant073458b2011-10-17 20:05:10 +0000497#define _LIBCPP_HAS_NO_UNICODE_CHARS
498#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnantc9d3ae42013-08-24 21:31:37 +0000499#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000500#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnant073458b2011-10-17 20:05:10 +0000501#define __alignof__ __alignof
Richard Smith535a86c2012-07-26 02:04:22 +0000502#define _LIBCPP_NORETURN __declspec(noreturn)
Howard Hinnant073458b2011-10-17 20:05:10 +0000503#define _ALIGNAS(x) __declspec(align(x))
504#define _LIBCPP_HAS_NO_VARIADICS
505
Howard Hinnant073458b2011-10-17 20:05:10 +0000506#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
507#define _LIBCPP_END_NAMESPACE_STD }
508#define _VSTD std
509
Howard Hinnanta942f2f2013-10-04 23:56:37 +0000510# define _LIBCPP_WEAK
Howard Hinnant073458b2011-10-17 20:05:10 +0000511namespace std {
512}
513
Marshall Clow91c71dd2014-04-14 15:44:57 +0000514#define _LIBCPP_HAS_NO_ASAN
515
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000516#elif defined(__IBMCPP__)
517
518#define _ALIGNAS(x) __attribute__((__aligned__(x)))
519#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
520#define _ATTRIBUTE(x) __attribute__((x))
521#define _LIBCPP_NORETURN __attribute__((noreturn))
522
Eric Fiselier7a608aa2015-12-23 08:20:26 +0000523#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000524#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
525#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000526#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000527#define _LIBCPP_HAS_NO_NOEXCEPT
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000528#define _LIBCPP_HAS_NO_NULLPTR
529#define _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000530#define _LIBCPP_HAS_IS_BASE_OF
Eric Fiselieree187e22015-06-13 07:08:02 +0000531#define _LIBCPP_HAS_IS_FINAL
Marshall Clow2d832d22015-03-17 15:30:22 +0000532#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Howard Hinnant5d1a7012013-08-14 18:00:20 +0000533
534#if defined(_AIX)
535#define __MULTILOCALE_API
536#endif
537
538#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
539#define _LIBCPP_END_NAMESPACE_STD } }
540#define _VSTD std::_LIBCPP_NAMESPACE
541
542namespace std {
543 inline namespace _LIBCPP_NAMESPACE {
544 }
545}
546
Marshall Clow91c71dd2014-04-14 15:44:57 +0000547#define _LIBCPP_HAS_NO_ASAN
548
Marshall Clowa8896362014-01-06 15:23:02 +0000549#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
Howard Hinnant3e519522010-05-11 19:42:16 +0000550
Eric Fiselier49e29672016-09-15 22:27:07 +0000551
552#ifdef _WIN32
553// only really useful for a DLL. _LIBCPP_DLL should be a compiler builtin define ideally...
554#if defined(_LIBCPP_DLL) && defined(cxx_EXPORTS)
555# define _LIBCPP_DLL_VIS __declspec(dllexport)
Shoaib Meenai190994e2016-09-19 18:29:07 +0000556# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
557# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
Eric Fiselier49e29672016-09-15 22:27:07 +0000558#elif defined(_LIBCPP_DLL)
559# define _LIBCPP_DLL_VIS __declspec(dllimport)
Shoaib Meenai190994e2016-09-19 18:29:07 +0000560# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
561# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Eric Fiselier49e29672016-09-15 22:27:07 +0000562#else
563# define _LIBCPP_DLL_VIS
Shoaib Meenai190994e2016-09-19 18:29:07 +0000564# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
565# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
Eric Fiselier49e29672016-09-15 22:27:07 +0000566#endif
567#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
568#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS
569#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS
Eric Fiselier49e29672016-09-15 22:27:07 +0000570#define _LIBCPP_HIDDEN
571#define _LIBCPP_TYPE_VIS_ONLY
572#define _LIBCPP_FUNC_VIS_ONLY
573#define _LIBCPP_ENUM_VIS
Shoaib Meenai3b339382016-09-16 19:12:54 +0000574#if defined(_LIBCPP_MSVC)
575# define _LIBCPP_INLINE_VISIBILITY __forceinline
576# define _LIBCPP_ALWAYS_INLINE __forceinline
577# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
578#else
579# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
580# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
581# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
582#endif
Eric Fiselier49e29672016-09-15 22:27:07 +0000583#endif // _WIN32
584
585#ifndef _LIBCPP_HIDDEN
586#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
587#endif
588
589#ifndef _LIBCPP_FUNC_VIS
590#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
591#endif
592
593#ifndef _LIBCPP_TYPE_VIS
594# if __has_attribute(__type_visibility__)
595# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
596# else
597# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
598# endif
599#endif
600
601#ifndef _LIBCPP_TYPE_VIS_ONLY
602# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
603#endif
604
605#ifndef _LIBCPP_FUNC_VIS_ONLY
606# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
607#endif
608
609#ifndef _LIBCPP_EXCEPTION_ABI
610#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
611#endif
612
613#ifndef _LIBCPP_ENUM_VIS
614# if __has_attribute(__type_visibility__)
615# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
616# else
617# define _LIBCPP_ENUM_VIS
618# endif
619#endif
620
621#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
622# if __has_attribute(__type_visibility__)
623# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
624# else
625# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
626# endif
627#endif
628
Shoaib Meenai190994e2016-09-19 18:29:07 +0000629#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
630# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
631#endif
632
Eric Fiselier49e29672016-09-15 22:27:07 +0000633#ifndef _LIBCPP_INLINE_VISIBILITY
Eric Fiselier9e1b0b52016-09-25 03:14:13 +0000634# if __has_attribute(__internal_linkage__)
635# define _LIBCPP_INLINE_VISIBILITY __attribute__((__internal_linkage__, __always_inline__))
636# else
637# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
638# endif
Eric Fiselier49e29672016-09-15 22:27:07 +0000639#endif
640
641#ifndef _LIBCPP_ALWAYS_INLINE
Eric Fiselier9e1b0b52016-09-25 03:14:13 +0000642# if __has_attribute(__internal_linkage__)
643# define _LIBCPP_ALWAYS_INLINE __attribute__((__internal_linkage__, __always_inline__))
644# else
645# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
646# endif
Eric Fiselier49e29672016-09-15 22:27:07 +0000647#endif
648
Eric Fiselierf8f31c42016-09-16 00:00:48 +0000649#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
650# ifdef _LIBCPP_BUILDING_LIBRARY
651# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
652# else
653# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
654# endif
655#endif
656
Eric Fiselier49e29672016-09-15 22:27:07 +0000657#ifndef _LIBCPP_PREFERRED_OVERLOAD
658# if __has_attribute(__enable_if__)
659# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
660# endif
661#endif
662
Eric Fiselier8dcfcf72015-12-15 22:16:47 +0000663#ifndef _LIBCPP_HAS_NO_NOEXCEPT
664# define _NOEXCEPT noexcept
665# define _NOEXCEPT_(x) noexcept(x)
666#else
667# define _NOEXCEPT throw()
668# define _NOEXCEPT_(x)
669#endif
670
Howard Hinnant3e519522010-05-11 19:42:16 +0000671#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnanteb269252010-08-10 20:48:29 +0000672typedef unsigned short char16_t;
673typedef unsigned int char32_t;
Howard Hinnantb3371f62010-08-22 00:02:43 +0000674#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Howard Hinnant3e519522010-05-11 19:42:16 +0000675
Stephan Tolksdorfe180eca2014-03-26 19:45:52 +0000676#ifndef __SIZEOF_INT128__
677#define _LIBCPP_HAS_NO_INT128
678#endif
679
Howard Hinnant3e519522010-05-11 19:42:16 +0000680#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
681
Richard Smithf157e472015-10-13 23:12:22 +0000682extern "C++" {
Howard Hinnant3e519522010-05-11 19:42:16 +0000683template <bool> struct __static_assert_test;
684template <> struct __static_assert_test<true> {};
685template <unsigned> struct __static_assert_check {};
Richard Smithf157e472015-10-13 23:12:22 +0000686}
Howard Hinnant3e519522010-05-11 19:42:16 +0000687#define static_assert(__b, __m) \
688 typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
689 _LIBCPP_CONCAT(__t, __LINE__)
690
Howard Hinnantb3371f62010-08-22 00:02:43 +0000691#endif // _LIBCPP_HAS_NO_STATIC_ASSERT
Howard Hinnant3e519522010-05-11 19:42:16 +0000692
693#ifdef _LIBCPP_HAS_NO_DECLTYPE
Eric Fiseliere825d8b2015-07-10 20:26:38 +0000694// GCC 4.6 provides __decltype in all standard modes.
695#if !__is_identifier(__decltype) || _GNUC_VER >= 406
Eric Fiselierf8177542015-06-13 06:27:17 +0000696# define decltype(__x) __decltype(__x)
697#else
698# define decltype(__x) __typeof__(__x)
699#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000700#endif
701
Howard Hinnantdb3e9972010-09-06 19:10:31 +0000702#ifdef _LIBCPP_HAS_NO_CONSTEXPR
Howard Hinnant788c9972012-04-02 00:40:41 +0000703#define _LIBCPP_CONSTEXPR
704#else
705#define _LIBCPP_CONSTEXPR constexpr
Howard Hinnantdb3e9972010-09-06 19:10:31 +0000706#endif
707
Howard Hinnantda9ca0b2013-05-02 20:18:43 +0000708#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
709#define _LIBCPP_DEFAULT {}
710#else
711#define _LIBCPP_DEFAULT = default;
712#endif
713
Eric Fiselier5e3ea4d2016-03-31 02:15:15 +0000714#ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
715#define _LIBCPP_EQUAL_DELETE
716#else
717#define _LIBCPP_EQUAL_DELETE = delete
718#endif
719
Nuno Lopes6317bfb2012-06-28 16:47:34 +0000720#ifdef __GNUC__
Joerg Sonnenberger21883e92013-04-29 19:52:08 +0000721#define _NOALIAS __attribute__((__malloc__))
Nuno Lopes6317bfb2012-06-28 16:47:34 +0000722#else
723#define _NOALIAS
724#endif
725
Eric Fiselierf6ac5652016-08-29 20:43:38 +0000726#ifdef __GNUC__
727#define _LIBCPP_MAY_ALIAS __attribute__((__may_alias__))
728#else
729#define _LIBCPP_MAY_ALIAS
730#endif
731
Marshall Clow028875a2013-11-19 19:16:03 +0000732#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
Howard Hinnantf2f2d8b2012-02-21 21:46:43 +0000733# define _LIBCPP_EXPLICIT explicit
734#else
735# define _LIBCPP_EXPLICIT
736#endif
737
Richard Smithff0aff32014-06-04 19:54:15 +0000738#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
739# define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
740#endif
741
Howard Hinnant75689c12011-12-02 19:36:40 +0000742#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
Howard Hinnant6e412562013-03-06 23:30:19 +0000743#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
Howard Hinnant75689c12011-12-02 19:36:40 +0000744#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
Howard Hinnant54d333a2012-10-30 19:06:59 +0000745 __lx __v_; \
746 _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
747 _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
Howard Hinnant75689c12011-12-02 19:36:40 +0000748 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
749 };
750#else // _LIBCPP_HAS_NO_STRONG_ENUMS
Eric Fiselier49e29672016-09-15 22:27:07 +0000751#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
Howard Hinnant75689c12011-12-02 19:36:40 +0000752#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
753#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
754
Howard Hinnant145afa12013-08-23 20:10:18 +0000755#ifdef _LIBCPP_DEBUG
756# if _LIBCPP_DEBUG == 0
Howard Hinnantfc88dbd2013-08-23 17:37:05 +0000757# define _LIBCPP_DEBUG_LEVEL 1
Howard Hinnant145afa12013-08-23 20:10:18 +0000758# elif _LIBCPP_DEBUG == 1
Howard Hinnantfc88dbd2013-08-23 17:37:05 +0000759# define _LIBCPP_DEBUG_LEVEL 2
760# else
Howard Hinnant145afa12013-08-23 20:10:18 +0000761# error Supported values for _LIBCPP_DEBUG are 0 and 1
Howard Hinnantfc88dbd2013-08-23 17:37:05 +0000762# endif
763# define _LIBCPP_EXTERN_TEMPLATE(...)
764#endif
765
Howard Hinnantcd47cbc2012-11-06 21:08:48 +0000766#ifndef _LIBCPP_EXTERN_TEMPLATE
Justin Bognerd2308ea2014-08-15 17:58:56 +0000767#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
Howard Hinnantcd47cbc2012-11-06 21:08:48 +0000768#endif
769
Howard Hinnantfc88dbd2013-08-23 17:37:05 +0000770#ifndef _LIBCPP_EXTERN_TEMPLATE2
771#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
772#endif
773
Tim Northover4b9a5052014-03-30 14:59:12 +0000774#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
Tim Northover0090e652014-03-30 11:34:26 +0000775#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
776#endif
777
Ed Schouten510b6ab2015-03-10 09:26:38 +0000778#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
779 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
Alexis Hunt4084c9e2011-07-15 05:40:33 +0000780#define _LIBCPP_LOCALE__L_EXTENSIONS 1
781#endif
Yaron Keren21a697b82013-12-20 13:19:45 +0000782
Ben Craigd3261122016-02-10 13:47:25 +0000783#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
784// Most unix variants have catopen. These are the specific ones that don't.
Dan Albertc9917092016-09-19 18:00:45 +0000785#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
Ed Schouten12e01262015-03-11 16:39:36 +0000786#define _LIBCPP_HAS_CATOPEN 1
787#endif
Ben Craigd3261122016-02-10 13:47:25 +0000788#endif
Ed Schouten12e01262015-03-11 16:39:36 +0000789
Marshall Clow69e76f82013-03-18 19:34:07 +0000790#ifdef __FreeBSD__
David Chisnall5e8e0442011-11-13 17:15:33 +0000791#define _DECLARE_C99_LDBL_MATH 1
792#endif
Alexis Hunt4084c9e2011-07-15 05:40:33 +0000793
Marshall Clow69e76f82013-03-18 19:34:07 +0000794#if defined(__APPLE__) || defined(__FreeBSD__)
Howard Hinnant9978e372011-09-28 23:39:33 +0000795#define _LIBCPP_HAS_DEFAULTRUNELOCALE
Alexis Huntf0235192011-07-09 01:09:31 +0000796#endif
797
Marshall Clow69e76f82013-03-18 19:34:07 +0000798#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
Alexis Hunt00818922011-07-09 03:40:04 +0000799#define _LIBCPP_WCTYPE_IS_MASK
800#endif
801
Howard Hinnant81aa5cb2013-05-07 20:16:13 +0000802#ifndef _LIBCPP_STD_VER
803# if __cplusplus <= 201103L
804# define _LIBCPP_STD_VER 11
Marshall Clowc3699142014-06-06 22:31:09 +0000805# elif __cplusplus <= 201402L
806# define _LIBCPP_STD_VER 14
Howard Hinnant81aa5cb2013-05-07 20:16:13 +0000807# else
Eric Fiselier68436a92016-06-27 01:02:43 +0000808# define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
Howard Hinnant81aa5cb2013-05-07 20:16:13 +0000809# endif
810#endif // _LIBCPP_STD_VER
811
Marshall Clow8392ab22013-09-28 18:35:31 +0000812#if _LIBCPP_STD_VER > 11
813#define _LIBCPP_DEPRECATED [[deprecated]]
814#else
815#define _LIBCPP_DEPRECATED
816#endif
817
Marshall Clowf20d2672013-07-15 14:57:19 +0000818#if _LIBCPP_STD_VER <= 11
Marshall Clow7988106b2013-08-27 20:18:59 +0000819#define _LIBCPP_EXPLICIT_AFTER_CXX11
Marshall Clow8392ab22013-09-28 18:35:31 +0000820#define _LIBCPP_DEPRECATED_AFTER_CXX11
Marshall Clowf20d2672013-07-15 14:57:19 +0000821#else
Marshall Clow7988106b2013-08-27 20:18:59 +0000822#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
Marshall Clow8392ab22013-09-28 18:35:31 +0000823#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
Marshall Clowf20d2672013-07-15 14:57:19 +0000824#endif
825
Eric Fiselier371aac12014-07-17 05:16:18 +0000826#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
827#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
828#else
829#define _LIBCPP_CONSTEXPR_AFTER_CXX11
830#endif
831
Eric Fiseliera58d4302016-03-17 03:30:56 +0000832#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
833#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
834#else
835#define _LIBCPP_CONSTEXPR_AFTER_CXX14
836#endif
837
Dimitry Andric251c6292015-08-19 06:43:33 +0000838#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
839# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
840#else
841# define _LIBCPP_EXPLICIT_MOVE(x) (x)
842#endif
843
Marshall Clow5c520bd2014-05-08 14:14:06 +0000844#ifndef _LIBCPP_HAS_NO_ASAN
845extern "C" void __sanitizer_annotate_contiguous_container(
846 const void *, const void *, const void *, const void *);
847#endif
848
Howard Hinnantf7a8c4f2013-10-04 21:24:21 +0000849// Try to find out if RTTI is disabled.
850// g++ and cl.exe have RTTI on by default and define a macro when it is.
851// g++ only defines the macro in 4.3.2 and onwards.
852#if !defined(_LIBCPP_NO_RTTI)
Marshall Clow286a74e2015-09-22 21:58:30 +0000853# if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
Alexey Volkove46ca712014-09-03 14:30:39 +0000854 (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
Howard Hinnantf7a8c4f2013-10-04 21:24:21 +0000855# define _LIBCPP_NO_RTTI
856# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
857# define _LIBCPP_NO_RTTI
858# endif
859#endif
860
Howard Hinnanta942f2f2013-10-04 23:56:37 +0000861#ifndef _LIBCPP_WEAK
862# define _LIBCPP_WEAK __attribute__((__weak__))
863#endif
864
Asiri Rathnayakec7e42392016-05-06 14:06:29 +0000865// Thread API
Asiri Rathnayake8c2bf452016-09-11 21:46:40 +0000866#if !defined(_LIBCPP_HAS_NO_THREADS) && \
867 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
868 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
Asiri Rathnayakec7e42392016-05-06 14:06:29 +0000869# if defined(__FreeBSD__) || \
870 defined(__NetBSD__) || \
871 defined(__linux__) || \
872 defined(__APPLE__) || \
Eric Fiselierb06c0122016-05-07 17:05:46 +0000873 defined(__CloudABI__) || \
874 defined(__sun__)
Ben Craigb9599b12016-05-25 17:40:09 +0000875# define _LIBCPP_HAS_THREAD_API_PTHREAD
Asiri Rathnayakec7e42392016-05-06 14:06:29 +0000876# else
877# error "No thread API"
Ben Craigb9599b12016-05-25 17:40:09 +0000878# endif // _LIBCPP_HAS_THREAD_API
Asiri Rathnayakec7e42392016-05-06 14:06:29 +0000879#endif // _LIBCPP_HAS_NO_THREADS
880
Ben Craigb9599b12016-05-25 17:40:09 +0000881#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
882# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \
883 _LIBCPP_HAS_NO_THREADS is not defined.
884#endif
Asiri Rathnayakec7e42392016-05-06 14:06:29 +0000885
Asiri Rathnayake8c2bf452016-09-11 21:46:40 +0000886#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
887# error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
888 _LIBCPP_HAS_NO_THREADS is defined.
889#endif
890
Eric Fiselier2050bed2014-12-06 20:09:11 +0000891#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
892# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
893 _LIBCPP_HAS_NO_THREADS is defined.
894#endif
895
Ed Schouten97fdea62015-03-12 15:44:39 +0000896// Systems that use capability-based security (FreeBSD with Capsicum,
897// Nuxi CloudABI) may only provide local filesystem access (using *at()).
898// Functions like open(), rename(), unlink() and stat() should not be
899// used, as they attempt to access the global filesystem namespace.
900#ifdef __CloudABI__
901#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
902#endif
903
Ed Schoutenf4ac8842015-03-26 14:35:46 +0000904// CloudABI is intended for running networked services. Processes do not
905// have standard input and output channels.
906#ifdef __CloudABI__
907#define _LIBCPP_HAS_NO_STDIN
908#define _LIBCPP_HAS_NO_STDOUT
909#endif
910
Dan Albertc9917092016-09-19 18:00:45 +0000911#if defined(__BIONIC__) || defined(__CloudABI__) || \
912 defined(_LIBCPP_HAS_MUSL_LIBC)
Dan Albert900086d2015-03-11 00:51:06 +0000913#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
914#endif
915
Ed Schoutene0cf3b92015-06-24 08:44:38 +0000916// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
917// are not available.
918#ifdef __CloudABI__
919#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
920#endif
921
Eric Fiselier927a11e2015-09-22 03:15:35 +0000922#if __has_feature(cxx_atomic) || __has_extension(c_atomic)
Eric Fiselier749adeb2015-08-19 17:21:46 +0000923#define _LIBCPP_HAS_C_ATOMIC_IMP
924#elif _GNUC_VER > 407
925#define _LIBCPP_HAS_GCC_ATOMIC_IMP
926#endif
927
928#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
929 || defined(_LIBCPP_HAS_NO_THREADS)
930#define _LIBCPP_HAS_NO_ATOMIC_HEADER
931#endif
932
Marshall Clowec880422016-01-11 19:27:10 +0000933#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
934#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
Eric Fiselierfcd02212016-02-11 11:59:44 +0000935#endif
936
937#if __cplusplus < 201103L
938#define _LIBCPP_CXX03_LANG
939#else
Eric Fiselier3d30c322016-06-14 14:34:19 +0000940#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
Eric Fiselierfcd02212016-02-11 11:59:44 +0000941#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
942#endif
943#endif
Marshall Clowec880422016-01-11 19:27:10 +0000944
Eric Fiselier7865b2e2016-03-16 02:30:06 +0000945#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
946 && __has_attribute(acquire_capability))
947#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
948#endif
949
Eric Fiselier4efaa302016-09-03 00:11:33 +0000950#if __has_attribute(require_constant_initialization)
951#define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
952#else
953#define _LIBCPP_SAFE_STATIC
954#endif
955
Eric Fiselier60506cb2015-11-06 06:30:12 +0000956#endif // __cplusplus
957
Eric Fiselier749adeb2015-08-19 17:21:46 +0000958#endif // _LIBCPP_CONFIG