Implement resolutions of LWG 2399, 2400 and 2401.
[gcc.git] / libstdc++-v3 / include / bits / c++config
1 // Predefined symbols and macros -*- C++ -*-
2
3 // Copyright (C) 1997-2014 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24
25 /** @file bits/c++config.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{iosfwd}
28 */
29
30 #ifndef _GLIBCXX_CXX_CONFIG_H
31 #define _GLIBCXX_CXX_CONFIG_H 1
32
33 // The current version of the C++ library in compressed ISO date format.
34 #define __GLIBCXX__
35
36 // Macros for various attributes.
37 // _GLIBCXX_PURE
38 // _GLIBCXX_CONST
39 // _GLIBCXX_NORETURN
40 // _GLIBCXX_NOTHROW
41 // _GLIBCXX_VISIBILITY
42 #ifndef _GLIBCXX_PURE
43 # define _GLIBCXX_PURE __attribute__ ((__pure__))
44 #endif
45
46 #ifndef _GLIBCXX_CONST
47 # define _GLIBCXX_CONST __attribute__ ((__const__))
48 #endif
49
50 #ifndef _GLIBCXX_NORETURN
51 # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
52 #endif
53
54 // See below for C++
55 #ifndef _GLIBCXX_NOTHROW
56 # ifndef __cplusplus
57 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
58 # endif
59 #endif
60
61 // Macros for visibility attributes.
62 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
63 // _GLIBCXX_VISIBILITY
64 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
65
66 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
67 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
68 #else
69 // If this is not supplied by the OS-specific or CPU-specific
70 // headers included below, it will be defined to an empty default.
71 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
72 #endif
73
74 // Macros for deprecated attributes.
75 // _GLIBCXX_USE_DEPRECATED
76 // _GLIBCXX_DEPRECATED
77 #ifndef _GLIBCXX_USE_DEPRECATED
78 # define _GLIBCXX_USE_DEPRECATED 1
79 #endif
80
81 #if defined(__DEPRECATED) && (__cplusplus >= 201103L)
82 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
83 #else
84 # define _GLIBCXX_DEPRECATED
85 #endif
86
87 // Macros for ABI tag attributes.
88 #ifndef _GLIBCXX_ABI_TAG_CXX11
89 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
90 #endif
91
92
93 #if __cplusplus
94
95 // Macro for constexpr, to support in mixed 03/0x mode.
96 #ifndef _GLIBCXX_CONSTEXPR
97 # if __cplusplus >= 201103L
98 # define _GLIBCXX_CONSTEXPR constexpr
99 # define _GLIBCXX_USE_CONSTEXPR constexpr
100 # else
101 # define _GLIBCXX_CONSTEXPR
102 # define _GLIBCXX_USE_CONSTEXPR const
103 # endif
104 #endif
105
106 // Macro for noexcept, to support in mixed 03/0x mode.
107 #ifndef _GLIBCXX_NOEXCEPT
108 # if __cplusplus >= 201103L
109 # define _GLIBCXX_NOEXCEPT noexcept
110 # define _GLIBCXX_USE_NOEXCEPT noexcept
111 # define _GLIBCXX_THROW(_EXC)
112 # else
113 # define _GLIBCXX_NOEXCEPT
114 # define _GLIBCXX_USE_NOEXCEPT throw()
115 # define _GLIBCXX_THROW(_EXC) throw(_EXC)
116 # endif
117 #endif
118
119 #ifndef _GLIBCXX_NOTHROW
120 # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
121 #endif
122
123 #ifndef _GLIBCXX_THROW_OR_ABORT
124 # if __EXCEPTIONS
125 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
126 # else
127 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
128 # endif
129 #endif
130
131 // Macro for extern template, ie controling template linkage via use
132 // of extern keyword on template declaration. As documented in the g++
133 // manual, it inhibits all implicit instantiations and is used
134 // throughout the library to avoid multiple weak definitions for
135 // required types that are already explicitly instantiated in the
136 // library binary. This substantially reduces the binary size of
137 // resulting executables.
138 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
139 // templates only in basic_string, thus activating its debug-mode
140 // checks even at -O0.
141 #define _GLIBCXX_EXTERN_TEMPLATE
142
143 /*
144 Outline of libstdc++ namespaces.
145
146 namespace std
147 {
148 namespace __debug { }
149 namespace __parallel { }
150 namespace __profile { }
151 namespace __cxx1998 { }
152
153 namespace __detail { }
154
155 namespace rel_ops { }
156
157 namespace tr1
158 {
159 namespace placeholders { }
160 namespace regex_constants { }
161 namespace __detail { }
162 }
163
164 namespace tr2 { }
165
166 namespace decimal { }
167
168 namespace chrono { }
169 namespace placeholders { }
170 namespace regex_constants { }
171 namespace this_thread { }
172
173 namespace experimental { }
174 }
175
176 namespace abi { }
177
178 namespace __gnu_cxx
179 {
180 namespace __detail { }
181 }
182
183 For full details see:
184 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
185 */
186 namespace std
187 {
188 typedef __SIZE_TYPE__ size_t;
189 typedef __PTRDIFF_TYPE__ ptrdiff_t;
190
191 #if __cplusplus >= 201103L
192 typedef decltype(nullptr) nullptr_t;
193 #endif
194 }
195
196 // Use abi_tag("cxx11")
197 #ifndef _GLIBCXX_USE_CXX11_ABI
198 #define _GLIBCXX_USE_CXX11_ABI
199 #endif
200
201 #if _GLIBCXX_USE_CXX11_ABI
202 # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
203 #else
204 # define _GLIBCXX_DEFAULT_ABI_TAG
205 #endif
206
207
208 // Defined if inline namespaces are used for versioning.
209 #define _GLIBCXX_INLINE_VERSION
210
211 // Inline namespace for symbol versioning.
212 #if _GLIBCXX_INLINE_VERSION
213
214 namespace std
215 {
216 inline namespace __7 { }
217
218 namespace rel_ops { inline namespace __7 { } }
219
220 namespace tr1
221 {
222 inline namespace __7 { }
223 namespace placeholders { inline namespace __7 { } }
224 namespace regex_constants { inline namespace __7 { } }
225 namespace __detail { inline namespace __7 { } }
226 }
227
228 namespace tr2
229 { inline namespace __7 { } }
230
231 namespace decimal { inline namespace __7 { } }
232
233 namespace chrono { inline namespace __7 { } }
234 namespace placeholders { inline namespace __7 { } }
235 namespace regex_constants { inline namespace __7 { } }
236 namespace this_thread { inline namespace __7 { } }
237
238 namespace experimental { inline namespace __7 { } }
239
240 namespace __detail { inline namespace __7 { } }
241 }
242
243 namespace __gnu_cxx
244 {
245 inline namespace __7 { }
246 namespace __detail { inline namespace __7 { } }
247 }
248 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 {
249 # define _GLIBCXX_END_NAMESPACE_VERSION }
250 #else
251 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
252 # define _GLIBCXX_END_NAMESPACE_VERSION
253 #endif
254
255
256 // Inline namespaces for special modes: debug, parallel, profile.
257 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
258 || defined(_GLIBCXX_PROFILE)
259 namespace std
260 {
261 // Non-inline namespace for components replaced by alternates in active mode.
262 namespace __cxx1998
263 {
264 #if _GLIBCXX_INLINE_VERSION
265 inline namespace __7 { }
266 #endif
267 }
268
269 // Inline namespace for debug mode.
270 # ifdef _GLIBCXX_DEBUG
271 inline namespace __debug { }
272 # endif
273
274 // Inline namespaces for parallel mode.
275 # ifdef _GLIBCXX_PARALLEL
276 inline namespace __parallel { }
277 # endif
278
279 // Inline namespaces for profile mode
280 # ifdef _GLIBCXX_PROFILE
281 inline namespace __profile { }
282 # endif
283 }
284
285 // Check for invalid usage and unsupported mixed-mode use.
286 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
287 # error illegal use of multiple inlined namespaces
288 # endif
289 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
290 # error illegal use of multiple inlined namespaces
291 # endif
292 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
293 # error illegal use of multiple inlined namespaces
294 # endif
295
296 // Check for invalid use due to lack for weak symbols.
297 # if __NO_INLINE__ && !__GXX_WEAK__
298 # warning currently using inlined namespace mode which may fail \
299 without inlining due to lack of weak symbols
300 # endif
301 #endif
302
303 // Macros for namespace scope. Either namespace std:: or the name
304 // of some nested namespace within it corresponding to the active mode.
305 // _GLIBCXX_STD_A
306 // _GLIBCXX_STD_C
307 //
308 // Macros for opening/closing conditional namespaces.
309 // _GLIBCXX_BEGIN_NAMESPACE_ALGO
310 // _GLIBCXX_END_NAMESPACE_ALGO
311 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
312 // _GLIBCXX_END_NAMESPACE_CONTAINER
313 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
314 # define _GLIBCXX_STD_C __cxx1998
315 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
316 namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION
317 # define _GLIBCXX_END_NAMESPACE_CONTAINER \
318 _GLIBCXX_END_NAMESPACE_VERSION }
319 # undef _GLIBCXX_EXTERN_TEMPLATE
320 # define _GLIBCXX_EXTERN_TEMPLATE -1
321 #endif
322
323 #ifdef _GLIBCXX_PARALLEL
324 # define _GLIBCXX_STD_A __cxx1998
325 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
326 namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION
327 # define _GLIBCXX_END_NAMESPACE_ALGO \
328 _GLIBCXX_END_NAMESPACE_VERSION }
329 #endif
330
331 #ifndef _GLIBCXX_STD_A
332 # define _GLIBCXX_STD_A std
333 #endif
334
335 #ifndef _GLIBCXX_STD_C
336 # define _GLIBCXX_STD_C std
337 #endif
338
339 #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO
340 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO
341 #endif
342
343 #ifndef _GLIBCXX_END_NAMESPACE_ALGO
344 # define _GLIBCXX_END_NAMESPACE_ALGO
345 #endif
346
347 #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
348 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
349 #endif
350
351 #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER
352 # define _GLIBCXX_END_NAMESPACE_CONTAINER
353 #endif
354
355 // GLIBCXX_ABI Deprecated
356 // Define if compatibility should be provided for -mlong-double-64.
357 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
358
359 // Inline namespace for long double 128 mode.
360 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
361 namespace std
362 {
363 inline namespace __gnu_cxx_ldbl128 { }
364 }
365 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
366 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
367 # define _GLIBCXX_END_NAMESPACE_LDBL }
368 #else
369 # define _GLIBCXX_NAMESPACE_LDBL
370 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL
371 # define _GLIBCXX_END_NAMESPACE_LDBL
372 #endif
373
374 // Assert.
375 #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
376 # define __glibcxx_assert(_Condition)
377 #else
378 namespace std
379 {
380 // Avoid the use of assert, because we're trying to keep the <cassert>
381 // include out of the mix.
382 inline void
383 __replacement_assert(const char* __file, int __line,
384 const char* __function, const char* __condition)
385 {
386 __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
387 __function, __condition);
388 __builtin_abort();
389 }
390 }
391 #define __glibcxx_assert(_Condition) \
392 do \
393 { \
394 if (! (_Condition)) \
395 std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
396 #_Condition); \
397 } while (false)
398 #endif
399
400 // Macros for race detectors.
401 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
402 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
403 // atomic (lock-free) synchronization to race detectors:
404 // the race detector will infer a happens-before arc from the former to the
405 // latter when they share the same argument pointer.
406 //
407 // The most frequent use case for these macros (and the only case in the
408 // current implementation of the library) is atomic reference counting:
409 // void _M_remove_reference()
410 // {
411 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
412 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
413 // {
414 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
415 // _M_destroy(__a);
416 // }
417 // }
418 // The annotations in this example tell the race detector that all memory
419 // accesses occurred when the refcount was positive do not race with
420 // memory accesses which occurred after the refcount became zero.
421 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
422 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
423 #endif
424 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
425 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
426 #endif
427
428 // Macros for C linkage: define extern "C" linkage only when using C++.
429 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
430 # define _GLIBCXX_END_EXTERN_C }
431
432 #else // !__cplusplus
433 # define _GLIBCXX_BEGIN_EXTERN_C
434 # define _GLIBCXX_END_EXTERN_C
435 #endif
436
437
438 // First includes.
439
440 // Pick up any OS-specific definitions.
441 #include <bits/os_defines.h>
442
443 // Pick up any CPU-specific definitions.
444 #include <bits/cpu_defines.h>
445
446 // If platform uses neither visibility nor psuedo-visibility,
447 // specify empty default for namespace annotation macros.
448 #ifndef _GLIBCXX_PSEUDO_VISIBILITY
449 # define _GLIBCXX_PSEUDO_VISIBILITY(V)
450 #endif
451
452 // Certain function definitions that are meant to be overridable from
453 // user code are decorated with this macro. For some targets, this
454 // macro causes these definitions to be weak.
455 #ifndef _GLIBCXX_WEAK_DEFINITION
456 # define _GLIBCXX_WEAK_DEFINITION
457 #endif
458
459
460 // The remainder of the prewritten config is automatic; all the
461 // user hooks are listed above.
462
463 // Create a boolean flag to be used to determine if --fast-math is set.
464 #ifdef __FAST_MATH__
465 # define _GLIBCXX_FAST_MATH 1
466 #else
467 # define _GLIBCXX_FAST_MATH 0
468 #endif
469
470 // This marks string literals in header files to be extracted for eventual
471 // translation. It is primarily used for messages in thrown exceptions; see
472 // src/functexcept.cc. We use __N because the more traditional _N is used
473 // for something else under certain OSes (see BADNAMES).
474 #define __N(msgid) (msgid)
475
476 // For example, <windows.h> is known to #define min and max as macros...
477 #undef min
478 #undef max
479
480 // End of prewritten config; the settings discovered at configure time follow.