1 // Predefined symbols and macros -*- C++ -*-
3 // Copyright (C) 1997-2023 Free Software Foundation, Inc.
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)
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.
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.
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/>.
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{version}
30 #ifndef _GLIBCXX_CXX_CONFIG_H
31 #define _GLIBCXX_CXX_CONFIG_H 1
33 #pragma GCC system_header
35 // The major release number for the GCC release the C++ library belongs to.
36 #define _GLIBCXX_RELEASE
38 // The datestamp of the C++ library in compressed ISO date format.
41 // Macros for various attributes.
46 // _GLIBCXX_VISIBILITY
48 # define _GLIBCXX_PURE __attribute__ ((__pure__))
51 #ifndef _GLIBCXX_CONST
52 # define _GLIBCXX_CONST __attribute__ ((__const__))
55 #ifndef _GLIBCXX_NORETURN
56 # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
60 #ifndef _GLIBCXX_NOTHROW
62 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
66 // Macros for visibility attributes.
67 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
68 // _GLIBCXX_VISIBILITY
69 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
71 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
72 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
74 // If this is not supplied by the OS-specific or CPU-specific
75 // headers included below, it will be defined to an empty default.
76 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
79 // Macros for deprecated attributes.
80 // _GLIBCXX_USE_DEPRECATED
81 // _GLIBCXX_DEPRECATED
82 // _GLIBCXX_DEPRECATED_SUGGEST( string-literal )
83 // _GLIBCXX11_DEPRECATED
84 // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal )
85 // _GLIBCXX14_DEPRECATED
86 // _GLIBCXX14_DEPRECATED_SUGGEST( string-literal )
87 // _GLIBCXX17_DEPRECATED
88 // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal )
89 // _GLIBCXX20_DEPRECATED
90 // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal )
91 // _GLIBCXX23_DEPRECATED
92 // _GLIBCXX23_DEPRECATED_SUGGEST( string-literal )
93 #ifndef _GLIBCXX_USE_DEPRECATED
94 # define _GLIBCXX_USE_DEPRECATED 1
97 #if defined(__DEPRECATED)
98 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
99 # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \
100 __attribute__ ((__deprecated__ ("use '" ALT "' instead")))
102 # define _GLIBCXX_DEPRECATED
103 # define _GLIBCXX_DEPRECATED_SUGGEST(ALT)
106 #if defined(__DEPRECATED) && (__cplusplus >= 201103L)
107 # define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED
108 # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
110 # define _GLIBCXX11_DEPRECATED
111 # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT)
114 #if defined(__DEPRECATED) && (__cplusplus >= 201402L)
115 # define _GLIBCXX14_DEPRECATED _GLIBCXX_DEPRECATED
116 # define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
118 # define _GLIBCXX14_DEPRECATED
119 # define _GLIBCXX14_DEPRECATED_SUGGEST(ALT)
122 #if defined(__DEPRECATED) && (__cplusplus >= 201703L)
123 # define _GLIBCXX17_DEPRECATED [[__deprecated__]]
124 # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
126 # define _GLIBCXX17_DEPRECATED
127 # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT)
130 #if defined(__DEPRECATED) && (__cplusplus >= 202002L)
131 # define _GLIBCXX20_DEPRECATED [[__deprecated__]]
132 # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
134 # define _GLIBCXX20_DEPRECATED
135 # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT)
138 #if defined(__DEPRECATED) && (__cplusplus >= 202100L)
139 # define _GLIBCXX23_DEPRECATED [[__deprecated__]]
140 # define _GLIBCXX23_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
142 # define _GLIBCXX23_DEPRECATED
143 # define _GLIBCXX23_DEPRECATED_SUGGEST(ALT)
146 // Macros for ABI tag attributes.
147 #ifndef _GLIBCXX_ABI_TAG_CXX11
148 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
151 // Macro to warn about unused results.
152 #if __cplusplus >= 201703L
153 # define _GLIBCXX_NODISCARD [[__nodiscard__]]
155 # define _GLIBCXX_NODISCARD
162 // Macro for constexpr, to support in mixed 03/0x mode.
163 #ifndef _GLIBCXX_CONSTEXPR
164 # if __cplusplus >= 201103L
165 # define _GLIBCXX_CONSTEXPR constexpr
166 # define _GLIBCXX_USE_CONSTEXPR constexpr
168 # define _GLIBCXX_CONSTEXPR
169 # define _GLIBCXX_USE_CONSTEXPR const
173 #ifndef _GLIBCXX14_CONSTEXPR
174 # if __cplusplus >= 201402L
175 # define _GLIBCXX14_CONSTEXPR constexpr
177 # define _GLIBCXX14_CONSTEXPR
181 #ifndef _GLIBCXX17_CONSTEXPR
182 # if __cplusplus >= 201703L
183 # define _GLIBCXX17_CONSTEXPR constexpr
185 # define _GLIBCXX17_CONSTEXPR
189 #ifndef _GLIBCXX20_CONSTEXPR
190 # if __cplusplus >= 202002L
191 # define _GLIBCXX20_CONSTEXPR constexpr
193 # define _GLIBCXX20_CONSTEXPR
197 #ifndef _GLIBCXX23_CONSTEXPR
198 # if __cplusplus >= 202100L
199 # define _GLIBCXX23_CONSTEXPR constexpr
201 # define _GLIBCXX23_CONSTEXPR
205 #ifndef _GLIBCXX17_INLINE
206 # if __cplusplus >= 201703L
207 # define _GLIBCXX17_INLINE inline
209 # define _GLIBCXX17_INLINE
213 // Macro for noexcept, to support in mixed 03/0x mode.
214 #ifndef _GLIBCXX_NOEXCEPT
215 # if __cplusplus >= 201103L
216 # define _GLIBCXX_NOEXCEPT noexcept
217 # define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__)
218 # define _GLIBCXX_USE_NOEXCEPT noexcept
219 # define _GLIBCXX_THROW(_EXC)
221 # define _GLIBCXX_NOEXCEPT
222 # define _GLIBCXX_NOEXCEPT_IF(...)
223 # define _GLIBCXX_USE_NOEXCEPT throw()
224 # define _GLIBCXX_THROW(_EXC) throw(_EXC)
228 #ifndef _GLIBCXX_NOTHROW
229 # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
232 #ifndef _GLIBCXX_THROW_OR_ABORT
233 # if __cpp_exceptions
234 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
236 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
240 #if __cpp_noexcept_function_type
241 #define _GLIBCXX_NOEXCEPT_PARM , bool _NE
242 #define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE)
244 #define _GLIBCXX_NOEXCEPT_PARM
245 #define _GLIBCXX_NOEXCEPT_QUAL
248 // Macro for extern template, ie controlling template linkage via use
249 // of extern keyword on template declaration. As documented in the g++
250 // manual, it inhibits all implicit instantiations and is used
251 // throughout the library to avoid multiple weak definitions for
252 // required types that are already explicitly instantiated in the
253 // library binary. This substantially reduces the binary size of
254 // resulting executables.
255 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
256 // templates only in basic_string, thus activating its debug-mode
257 // checks even at -O0.
258 #define _GLIBCXX_EXTERN_TEMPLATE
261 Outline of libstdc++ namespaces.
265 namespace __debug { }
266 namespace __parallel { }
267 namespace __cxx1998 { }
270 namespace __variant { } // C++17
273 namespace rel_ops { }
277 namespace placeholders { }
278 namespace regex_constants { }
279 namespace __detail { }
284 namespace decimal { }
286 namespace chrono { } // C++11
287 namespace placeholders { } // C++11
288 namespace regex_constants { } // C++11
289 namespace this_thread { } // C++11
290 inline namespace literals { // C++14
291 inline namespace chrono_literals { } // C++14
292 inline namespace complex_literals { } // C++14
293 inline namespace string_literals { } // C++14
294 inline namespace string_view_literals { } // C++17
302 namespace __detail { }
305 For full details see:
306 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
310 typedef __SIZE_TYPE__ size_t;
311 typedef __PTRDIFF_TYPE__ ptrdiff_t;
313 #if __cplusplus >= 201103L
314 typedef decltype(nullptr) nullptr_t;
317 #pragma GCC visibility push(default)
318 // This allows the library to terminate without including all of <exception>
319 // and without making the declaration of std::terminate visible to users.
320 extern "C++" __attribute__ ((__noreturn__, __always_inline__))
321 inline void __terminate() _GLIBCXX_USE_NOEXCEPT
323 void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__,__cold__));
326 #pragma GCC visibility pop
329 #define _GLIBCXX_USE_DUAL_ABI
331 #if ! _GLIBCXX_USE_DUAL_ABI
332 // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
333 # undef _GLIBCXX_USE_CXX11_ABI
336 #ifndef _GLIBCXX_USE_CXX11_ABI
337 #define _GLIBCXX_USE_CXX11_ABI
340 #if _GLIBCXX_USE_CXX11_ABI
343 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
347 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
349 # define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
350 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
351 # define _GLIBCXX_END_NAMESPACE_CXX11 }
352 # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
354 # define _GLIBCXX_NAMESPACE_CXX11
355 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11
356 # define _GLIBCXX_END_NAMESPACE_CXX11
357 # define _GLIBCXX_DEFAULT_ABI_TAG
360 // Non-zero if inline namespaces are used for versioning the entire library.
361 #define _GLIBCXX_INLINE_VERSION
363 #if _GLIBCXX_INLINE_VERSION
364 // Inline namespace for symbol versioning of (nearly) everything in std.
365 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
366 # define _GLIBCXX_END_NAMESPACE_VERSION }
367 // Unused when everything in std is versioned anyway.
368 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)
369 # define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X)
373 inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
374 #if __cplusplus >= 201402L
375 inline namespace literals {
376 inline namespace chrono_literals { }
377 inline namespace complex_literals { }
378 inline namespace string_literals { }
379 #if __cplusplus > 201402L
380 inline namespace string_view_literals { }
384 _GLIBCXX_END_NAMESPACE_VERSION
389 inline _GLIBCXX_BEGIN_NAMESPACE_VERSION
390 _GLIBCXX_END_NAMESPACE_VERSION
395 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
396 # define _GLIBCXX_END_NAMESPACE_VERSION
397 // Used to version individual components, e.g. std::_V2::error_category.
398 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) inline namespace X {
399 # define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) } // inline namespace X
402 // In the case that we don't have a hosted environment, we can't provide the
403 // debugging mode. Instead, we do our best and downgrade to assertions.
404 #if defined(_GLIBCXX_DEBUG) && !__STDC_HOSTED__
405 #undef _GLIBCXX_DEBUG
406 #define _GLIBCXX_ASSERTIONS 1
409 // Inline namespaces for special modes: debug, parallel.
410 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL)
413 _GLIBCXX_BEGIN_NAMESPACE_VERSION
415 // Non-inline namespace for components replaced by alternates in active mode.
418 # if _GLIBCXX_USE_CXX11_ABI
419 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
423 _GLIBCXX_END_NAMESPACE_VERSION
425 // Inline namespace for debug mode.
426 # ifdef _GLIBCXX_DEBUG
427 inline namespace __debug { }
430 // Inline namespaces for parallel mode.
431 # ifdef _GLIBCXX_PARALLEL
432 inline namespace __parallel { }
436 // Check for invalid usage and unsupported mixed-mode use.
437 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
438 # error illegal use of multiple inlined namespaces
441 // Check for invalid use due to lack for weak symbols.
442 # if __NO_INLINE__ && !__GXX_WEAK__
443 # warning currently using inlined namespace mode which may fail \
444 without inlining due to lack of weak symbols
448 // Macros for namespace scope. Either namespace std:: or the name
449 // of some nested namespace within it corresponding to the active mode.
453 // Macros for opening/closing conditional namespaces.
454 // _GLIBCXX_BEGIN_NAMESPACE_ALGO
455 // _GLIBCXX_END_NAMESPACE_ALGO
456 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
457 // _GLIBCXX_END_NAMESPACE_CONTAINER
458 #if defined(_GLIBCXX_DEBUG)
459 # define _GLIBCXX_STD_C __cxx1998
460 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
461 namespace _GLIBCXX_STD_C {
462 # define _GLIBCXX_END_NAMESPACE_CONTAINER }
464 # define _GLIBCXX_STD_C std
465 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
466 # define _GLIBCXX_END_NAMESPACE_CONTAINER
469 #ifdef _GLIBCXX_PARALLEL
470 # define _GLIBCXX_STD_A __cxx1998
471 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
472 namespace _GLIBCXX_STD_A {
473 # define _GLIBCXX_END_NAMESPACE_ALGO }
475 # define _GLIBCXX_STD_A std
476 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO
477 # define _GLIBCXX_END_NAMESPACE_ALGO
480 // GLIBCXX_ABI Deprecated
481 // Define if compatibility should be provided for -mlong-double-64.
482 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
484 // Define if compatibility should be provided for alternative 128-bit long
485 // double formats. Not possible for Clang until __ibm128 is supported.
487 #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
490 // Inline namespaces for long double 128 modes.
491 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
492 && defined __LONG_DOUBLE_IEEE128__
495 // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE.
496 inline namespace __gnu_cxx_ieee128 { }
497 inline namespace __gnu_cxx11_ieee128 { }
499 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128::
500 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 {
501 # define _GLIBCXX_END_NAMESPACE_LDBL }
502 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128::
503 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 {
504 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 }
506 #else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128
508 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
511 inline namespace __gnu_cxx_ldbl128 { }
513 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
514 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
515 # define _GLIBCXX_END_NAMESPACE_LDBL }
517 # define _GLIBCXX_NAMESPACE_LDBL
518 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL
519 # define _GLIBCXX_END_NAMESPACE_LDBL
522 #if _GLIBCXX_USE_CXX11_ABI
523 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11
524 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
525 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11
527 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL
528 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL
529 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
532 #endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128
536 #pragma GCC visibility push(default)
537 // Internal version of std::is_constant_evaluated().
538 // This can be used without checking if the compiler supports the feature.
539 // The macro _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED can be used to check if
540 // the compiler support is present to make this function work as expected.
541 __attribute__((__always_inline__))
542 _GLIBCXX_CONSTEXPR inline bool
543 __is_constant_evaluated() _GLIBCXX_NOEXCEPT
545 #if __cpp_if_consteval >= 202106L
546 # define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1
547 if consteval { return true; } else { return false; }
548 #elif __cplusplus >= 201103L && __has_builtin(__builtin_is_constant_evaluated)
549 # define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1
550 return __builtin_is_constant_evaluated();
555 #pragma GCC visibility pop
558 // Debug Mode implies checking assertions.
559 #if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS)
560 # define _GLIBCXX_ASSERTIONS 1
563 // Disable std::string explicit instantiation declarations in order to assert.
564 #ifdef _GLIBCXX_ASSERTIONS
565 # undef _GLIBCXX_EXTERN_TEMPLATE
566 # define _GLIBCXX_EXTERN_TEMPLATE -1
569 #undef _GLIBCXX_VERBOSE_ASSERT
572 #ifdef _GLIBCXX_VERBOSE_ASSERT
575 #pragma GCC visibility push(default)
576 // Don't use <cassert> because this should be unaffected by NDEBUG.
577 extern "C++" _GLIBCXX_NORETURN
579 __glibcxx_assert_fail /* Called when a precondition violation is detected. */
580 (const char* __file, int __line, const char* __function,
581 const char* __condition)
583 #pragma GCC visibility pop
585 # define _GLIBCXX_ASSERT_FAIL(_Condition) \
586 std::__glibcxx_assert_fail(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
588 #else // ! VERBOSE_ASSERT
589 # define _GLIBCXX_ASSERT_FAIL(_Condition) __builtin_abort()
592 #if defined(_GLIBCXX_ASSERTIONS)
593 // Enable runtime assertion checks, and also check in constant expressions.
594 # define __glibcxx_assert(cond) \
596 if (__builtin_expect(!bool(cond), false)) \
597 _GLIBCXX_ASSERT_FAIL(cond); \
599 #elif _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
600 // Only check assertions during constant evaluation.
603 __attribute__((__always_inline__,__visibility__("default")))
605 __glibcxx_assert_fail()
608 # define __glibcxx_assert(cond) \
610 if (std::__is_constant_evaluated()) \
611 if (__builtin_expect(!bool(cond), false)) \
612 std::__glibcxx_assert_fail(); \
615 // Don't check any assertions.
616 # define __glibcxx_assert(cond)
619 // Macro indicating that TSAN is in use.
620 #if __SANITIZE_THREAD__
621 # define _GLIBCXX_TSAN 1
622 #elif defined __has_feature
623 # if __has_feature(thread_sanitizer)
624 # define _GLIBCXX_TSAN 1
628 // Macros for race detectors.
629 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
630 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
631 // atomic (lock-free) synchronization to race detectors:
632 // the race detector will infer a happens-before arc from the former to the
633 // latter when they share the same argument pointer.
635 // The most frequent use case for these macros (and the only case in the
636 // current implementation of the library) is atomic reference counting:
637 // void _M_remove_reference()
639 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
640 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
642 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
646 // The annotations in this example tell the race detector that all memory
647 // accesses occurred when the refcount was positive do not race with
648 // memory accesses which occurred after the refcount became zero.
649 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
650 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
652 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
653 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
656 // Macros for C linkage: define extern "C" linkage only when using C++.
657 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
658 # define _GLIBCXX_END_EXTERN_C }
660 #define _GLIBCXX_USE_ALLOCATOR_NEW
662 #ifdef __SIZEOF_INT128__
663 #if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__
664 // If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined
665 // unless the compiler is in strict mode. If it's not defined and the strict
666 // macro is not defined, something is wrong.
667 #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported"
671 #else // !__cplusplus
672 # define _GLIBCXX_BEGIN_EXTERN_C
673 # define _GLIBCXX_END_EXTERN_C
679 // Pick up any OS-specific definitions.
680 #include <bits/os_defines.h>
682 // Pick up any CPU-specific definitions.
683 #include <bits/cpu_defines.h>
685 // If platform uses neither visibility nor psuedo-visibility,
686 // specify empty default for namespace annotation macros.
687 #ifndef _GLIBCXX_PSEUDO_VISIBILITY
688 # define _GLIBCXX_PSEUDO_VISIBILITY(V)
691 // Certain function definitions that are meant to be overridable from
692 // user code are decorated with this macro. For some targets, this
693 // macro causes these definitions to be weak.
694 #ifndef _GLIBCXX_WEAK_DEFINITION
695 # define _GLIBCXX_WEAK_DEFINITION
698 // By default, we assume that __GXX_WEAK__ also means that there is support
699 // for declaring functions as weak while not defining such functions. This
700 // allows for referring to functions provided by other libraries (e.g.,
701 // libitm) without depending on them if the respective features are not used.
702 #ifndef _GLIBCXX_USE_WEAK_REF
703 # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
706 // Conditionally enable annotations for the Transactional Memory TS on C++11.
707 // Most of the following conditions are due to limitations in the current
709 #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \
710 && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \
711 && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \
712 && _GLIBCXX_USE_ALLOCATOR_NEW
713 #define _GLIBCXX_TXN_SAFE transaction_safe
714 #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
716 #define _GLIBCXX_TXN_SAFE
717 #define _GLIBCXX_TXN_SAFE_DYN
720 #if __cplusplus > 201402L
721 // In C++17 mathematical special functions are in namespace std.
722 # define _GLIBCXX_USE_STD_SPEC_FUNCS 1
723 #elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
724 // For C++11 and C++14 they are in namespace std when requested.
725 # define _GLIBCXX_USE_STD_SPEC_FUNCS 1
728 // The remainder of the prewritten config is automatic; all the
729 // user hooks are listed above.
731 // Create a boolean flag to be used to determine if --fast-math is set.
733 # define _GLIBCXX_FAST_MATH 1
735 # define _GLIBCXX_FAST_MATH 0
738 // This marks string literals in header files to be extracted for eventual
739 // translation. It is primarily used for messages in thrown exceptions; see
740 // src/functexcept.cc. We use __N because the more traditional _N is used
741 // for something else under certain OSes (see BADNAMES).
742 #define __N(msgid) (msgid)
744 // For example, <windows.h> is known to #define min and max as macros...
748 // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
749 // so they should be tested with #if not with #ifdef.
750 #if __cplusplus >= 201103L
751 # ifndef _GLIBCXX_USE_C99_MATH
752 # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
754 # ifndef _GLIBCXX_USE_C99_COMPLEX
755 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
757 # ifndef _GLIBCXX_USE_C99_STDIO
758 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
760 # ifndef _GLIBCXX_USE_C99_STDLIB
761 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
763 # ifndef _GLIBCXX_USE_C99_WCHAR
764 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
767 # ifndef _GLIBCXX_USE_C99_MATH
768 # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
770 # ifndef _GLIBCXX_USE_C99_COMPLEX
771 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
773 # ifndef _GLIBCXX_USE_C99_STDIO
774 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
776 # ifndef _GLIBCXX_USE_C99_STDLIB
777 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
779 # ifndef _GLIBCXX_USE_C99_WCHAR
780 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
784 // Unless explicitly specified, enable char8_t extensions only if the core
785 // language char8_t feature macro is defined.
786 #ifndef _GLIBCXX_USE_CHAR8_T
787 # ifdef __cpp_char8_t
788 # define _GLIBCXX_USE_CHAR8_T 1
791 #ifdef _GLIBCXX_USE_CHAR8_T
792 # define __cpp_lib_char8_t 201907L
795 /* Define if __float128 is supported on this host. */
796 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
797 /* For powerpc64 don't use __float128 when it's the same type as long double. */
798 # if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__))
799 # define _GLIBCXX_USE_FLOAT128
803 // Define if float has the IEEE binary32 format.
804 #if __FLT_MANT_DIG__ == 24 \
805 && __FLT_MIN_EXP__ == -125 \
806 && __FLT_MAX_EXP__ == 128
807 # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1
810 // Define if double has the IEEE binary64 format.
811 #if __DBL_MANT_DIG__ == 53 \
812 && __DBL_MIN_EXP__ == -1021 \
813 && __DBL_MAX_EXP__ == 1024
814 # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1
817 // Define if long double has the IEEE binary128 format.
818 #if __LDBL_MANT_DIG__ == 113 \
819 && __LDBL_MIN_EXP__ == -16381 \
820 && __LDBL_MAX_EXP__ == 16384
821 # define _GLIBCXX_LDOUBLE_IS_IEEE_BINARY128 1
824 #if defined __cplusplus && defined __BFLT16_DIG__
827 typedef __decltype(0.0bf16) __bfloat16_t;
832 # ifdef __is_identifier
833 // Intel and older Clang require !__is_identifier for some built-ins:
834 # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B)
836 # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B)
840 #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations)
841 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
844 #if _GLIBCXX_HAS_BUILTIN(__is_aggregate)
845 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
848 #if _GLIBCXX_HAS_BUILTIN(__is_same)
849 # define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1
852 #if _GLIBCXX_HAS_BUILTIN(__builtin_launder)
853 # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
856 // Returns 1 if _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS is not defined and the
857 // compiler has a corresponding built-in type trait, 0 otherwise.
858 // _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS can be defined to disable the use of
860 #ifndef _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS
861 # define _GLIBCXX_USE_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
863 # define _GLIBCXX_USE_BUILTIN_TRAIT(BT) 0
866 // Mark code that should be ignored by the compiler, but seen by Doxygen.
867 #define _GLIBCXX_DOXYGEN_ONLY(X)
869 // PSTL configuration
871 #if __cplusplus >= 201703L
872 // This header is not installed for freestanding:
873 #if __has_include(<pstl/pstl_config.h>)
874 // Preserved here so we have some idea which version of upstream we've pulled in
875 // #define PSTL_VERSION 9000
877 // For now this defaults to being based on the presence of Thread Building Blocks
878 # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND
879 # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>)
881 // This section will need some rework when a new (default) backend type is added
882 # if _GLIBCXX_USE_TBB_PAR_BACKEND
883 # define _PSTL_PAR_BACKEND_TBB
885 # define _PSTL_PAR_BACKEND_SERIAL
888 # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition)
889 # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition)
891 #include <pstl/pstl_config.h>
892 #endif // __has_include
895 // End of prewritten config; the settings discovered at configure time follow.