1 // Predefined symbols and macros -*- C++ -*- 2 3 // Copyright (C) 1997-2022 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{version} 28 */ 29 30 #ifndef _GLIBCXX_CXX_CONFIG_H 31 #define _GLIBCXX_CXX_CONFIG_H 1 32 33 // The major release number for the GCC release the C++ library belongs to. 34 #define _GLIBCXX_RELEASE 35 36 // The datestamp of the C++ library in compressed ISO date format. 37 #define __GLIBCXX__ 38 39 // Macros for various attributes. 40 // _GLIBCXX_PURE 41 // _GLIBCXX_CONST 42 // _GLIBCXX_NORETURN 43 // _GLIBCXX_NOTHROW 44 // _GLIBCXX_VISIBILITY 45 #ifndef _GLIBCXX_PURE 46 # define _GLIBCXX_PURE __attribute__ ((__pure__)) 47 #endif 48 49 #ifndef _GLIBCXX_CONST 50 # define _GLIBCXX_CONST __attribute__ ((__const__)) 51 #endif 52 53 #ifndef _GLIBCXX_NORETURN 54 # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) 55 #endif 56 57 // See below for C++ 58 #ifndef _GLIBCXX_NOTHROW 59 # ifndef __cplusplus 60 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) 61 # endif 62 #endif 63 64 // Macros for visibility attributes. 65 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 66 // _GLIBCXX_VISIBILITY 67 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 68 69 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 70 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) 71 #else 72 // If this is not supplied by the OS-specific or CPU-specific 73 // headers included below, it will be defined to an empty default. 74 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) 75 #endif 76 77 // Macros for deprecated attributes. 78 // _GLIBCXX_USE_DEPRECATED 79 // _GLIBCXX_DEPRECATED 80 // _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) 81 // _GLIBCXX11_DEPRECATED 82 // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) 83 // _GLIBCXX14_DEPRECATED 84 // _GLIBCXX14_DEPRECATED_SUGGEST( string-literal ) 85 // _GLIBCXX17_DEPRECATED 86 // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) 87 // _GLIBCXX20_DEPRECATED( string-literal ) 88 // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) 89 #ifndef _GLIBCXX_USE_DEPRECATED 90 # define _GLIBCXX_USE_DEPRECATED 1 91 #endif 92 93 #if defined(__DEPRECATED) 94 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) 95 # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ 96 __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) 97 #else 98 # define _GLIBCXX_DEPRECATED 99 # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) 100 #endif 101 102 #if defined(__DEPRECATED) && (__cplusplus >= 201103L) 103 # define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED 104 # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) 105 #else 106 # define _GLIBCXX11_DEPRECATED 107 # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) 108 #endif 109 110 #if defined(__DEPRECATED) && (__cplusplus >= 201402L) 111 # define _GLIBCXX14_DEPRECATED _GLIBCXX_DEPRECATED 112 # define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) 113 #else 114 # define _GLIBCXX14_DEPRECATED 115 # define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) 116 #endif 117 118 #if defined(__DEPRECATED) && (__cplusplus >= 201703L) 119 # define _GLIBCXX17_DEPRECATED [[__deprecated__]] 120 # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) 121 #else 122 # define _GLIBCXX17_DEPRECATED 123 # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) 124 #endif 125 126 #if defined(__DEPRECATED) && (__cplusplus >= 202002L) 127 # define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] 128 # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) 129 #else 130 # define _GLIBCXX20_DEPRECATED(MSG) 131 # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) 132 #endif 133 134 // Macros for ABI tag attributes. 135 #ifndef _GLIBCXX_ABI_TAG_CXX11 136 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) 137 #endif 138 139 // Macro to warn about unused results. 140 #if __cplusplus >= 201703L 141 # define _GLIBCXX_NODISCARD [[__nodiscard__]] 142 #else 143 # define _GLIBCXX_NODISCARD 144 #endif 145 146 147 148 #if __cplusplus 149 150 // Macro for constexpr, to support in mixed 03/0x mode. 151 #ifndef _GLIBCXX_CONSTEXPR 152 # if __cplusplus >= 201103L 153 # define _GLIBCXX_CONSTEXPR constexpr 154 # define _GLIBCXX_USE_CONSTEXPR constexpr 155 # else 156 # define _GLIBCXX_CONSTEXPR 157 # define _GLIBCXX_USE_CONSTEXPR const 158 # endif 159 #endif 160 161 #ifndef _GLIBCXX14_CONSTEXPR 162 # if __cplusplus >= 201402L 163 # define _GLIBCXX14_CONSTEXPR constexpr 164 # else 165 # define _GLIBCXX14_CONSTEXPR 166 # endif 167 #endif 168 169 #ifndef _GLIBCXX17_CONSTEXPR 170 # if __cplusplus >= 201703L 171 # define _GLIBCXX17_CONSTEXPR constexpr 172 # else 173 # define _GLIBCXX17_CONSTEXPR 174 # endif 175 #endif 176 177 #ifndef _GLIBCXX20_CONSTEXPR 178 # if __cplusplus >= 202002L 179 # define _GLIBCXX20_CONSTEXPR constexpr 180 # else 181 # define _GLIBCXX20_CONSTEXPR 182 # endif 183 #endif 184 185 #ifndef _GLIBCXX23_CONSTEXPR 186 # if __cplusplus >= 202100L 187 # define _GLIBCXX23_CONSTEXPR constexpr 188 # else 189 # define _GLIBCXX23_CONSTEXPR 190 # endif 191 #endif 192 193 #ifndef _GLIBCXX17_INLINE 194 # if __cplusplus >= 201703L 195 # define _GLIBCXX17_INLINE inline 196 # else 197 # define _GLIBCXX17_INLINE 198 # endif 199 #endif 200 201 // Macro for noexcept, to support in mixed 03/0x mode. 202 #ifndef _GLIBCXX_NOEXCEPT 203 # if __cplusplus >= 201103L 204 # define _GLIBCXX_NOEXCEPT noexcept 205 # define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) 206 # define _GLIBCXX_USE_NOEXCEPT noexcept 207 # define _GLIBCXX_THROW(_EXC) 208 # else 209 # define _GLIBCXX_NOEXCEPT 210 # define _GLIBCXX_NOEXCEPT_IF(...) 211 # define _GLIBCXX_USE_NOEXCEPT throw() 212 # define _GLIBCXX_THROW(_EXC) throw(_EXC) 213 # endif 214 #endif 215 216 #ifndef _GLIBCXX_NOTHROW 217 # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT 218 #endif 219 220 #ifndef _GLIBCXX_THROW_OR_ABORT 221 # if __cpp_exceptions 222 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) 223 # else 224 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) 225 # endif 226 #endif 227 228 #if __cpp_noexcept_function_type 229 #define _GLIBCXX_NOEXCEPT_PARM , bool _NE 230 #define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) 231 #else 232 #define _GLIBCXX_NOEXCEPT_PARM 233 #define _GLIBCXX_NOEXCEPT_QUAL 234 #endif 235 236 // Macro for extern template, ie controlling template linkage via use 237 // of extern keyword on template declaration. As documented in the g++ 238 // manual, it inhibits all implicit instantiations and is used 239 // throughout the library to avoid multiple weak definitions for 240 // required types that are already explicitly instantiated in the 241 // library binary. This substantially reduces the binary size of 242 // resulting executables. 243 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern 244 // templates only in basic_string, thus activating its debug-mode 245 // checks even at -O0. 246 #define _GLIBCXX_EXTERN_TEMPLATE 247 248 /* 249 Outline of libstdc++ namespaces. 250 251 namespace std 252 { 253 namespace __debug { } 254 namespace __parallel { } 255 namespace __cxx1998 { } 256 257 namespace __detail { 258 namespace __variant { } // C++17 259 } 260 261 namespace rel_ops { } 262 263 namespace tr1 264 { 265 namespace placeholders { } 266 namespace regex_constants { } 267 namespace __detail { } 268 } 269 270 namespace tr2 { } 271 272 namespace decimal { } 273 274 namespace chrono { } // C++11 275 namespace placeholders { } // C++11 276 namespace regex_constants { } // C++11 277 namespace this_thread { } // C++11 278 inline namespace literals { // C++14 279 inline namespace chrono_literals { } // C++14 280 inline namespace complex_literals { } // C++14 281 inline namespace string_literals { } // C++14 282 inline namespace string_view_literals { } // C++17 283 } 284 } 285 286 namespace abi { } 287 288 namespace __gnu_cxx 289 { 290 namespace __detail { } 291 } 292 293 For full details see: 294 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html 295 */ 296 namespace std 297 { 298 typedef __SIZE_TYPE__ size_t; 299 typedef __PTRDIFF_TYPE__ ptrdiff_t; 300 301 #if __cplusplus >= 201103L 302 typedef decltype(nullptr) nullptr_t; 303 #endif 304 305 #pragma GCC visibility push(default) 306 // This allows the library to terminate without including all of <exception> 307 // and without making the declaration of std::terminate visible to users. 308 extern "C++" __attribute__ ((__noreturn__, __always_inline__)) 309 inline void __terminate() _GLIBCXX_USE_NOEXCEPT 310 { 311 void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); 312 terminate(); 313 } 314 #pragma GCC visibility pop 315 } 316 317 #define _GLIBCXX_USE_DUAL_ABI 318 319 #if ! _GLIBCXX_USE_DUAL_ABI 320 // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI 321 # undef _GLIBCXX_USE_CXX11_ABI 322 #endif 323 324 #ifndef _GLIBCXX_USE_CXX11_ABI 325 #define _GLIBCXX_USE_CXX11_ABI 326 #endif 327 328 #if _GLIBCXX_USE_CXX11_ABI 329 namespace std 330 { 331 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } 332 } 333 namespace __gnu_cxx 334 { 335 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } 336 } 337 # define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: 338 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { 339 # define _GLIBCXX_END_NAMESPACE_CXX11 } 340 # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 341 #else 342 # define _GLIBCXX_NAMESPACE_CXX11 343 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 344 # define _GLIBCXX_END_NAMESPACE_CXX11 345 # define _GLIBCXX_DEFAULT_ABI_TAG 346 #endif 347 348 // Non-zero if inline namespaces are used for versioning the entire library. 349 #define _GLIBCXX_INLINE_VERSION 350 351 #if _GLIBCXX_INLINE_VERSION 352 // Inline namespace for symbol versioning of (nearly) everything in std. 353 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { 354 # define _GLIBCXX_END_NAMESPACE_VERSION } 355 // Unused when everything in std is versioned anyway. 356 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) 357 # define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) 358 359 namespace std 360 { 361 inline _GLIBCXX_BEGIN_NAMESPACE_VERSION 362 #if __cplusplus >= 201402L 363 inline namespace literals { 364 inline namespace chrono_literals { } 365 inline namespace complex_literals { } 366 inline namespace string_literals { } 367 #if __cplusplus > 201402L 368 inline namespace string_view_literals { } 369 #endif // C++17 370 } 371 #endif // C++14 372 _GLIBCXX_END_NAMESPACE_VERSION 373 } 374 375 namespace __gnu_cxx 376 { 377 inline _GLIBCXX_BEGIN_NAMESPACE_VERSION 378 _GLIBCXX_END_NAMESPACE_VERSION 379 } 380 381 #else 382 // Unused. 383 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION 384 # define _GLIBCXX_END_NAMESPACE_VERSION 385 // Used to version individual components, e.g. std::_V2::error_category. 386 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) inline namespace X { 387 # define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) } // inline namespace X 388 #endif 389 390 // Inline namespaces for special modes: debug, parallel. 391 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) 392 namespace std 393 { 394 _GLIBCXX_BEGIN_NAMESPACE_VERSION 395 396 // Non-inline namespace for components replaced by alternates in active mode. 397 namespace __cxx1998 398 { 399 # if _GLIBCXX_USE_CXX11_ABI 400 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } 401 # endif 402 } 403 404 _GLIBCXX_END_NAMESPACE_VERSION 405 406 // Inline namespace for debug mode. 407 # ifdef _GLIBCXX_DEBUG 408 inline namespace __debug { } 409 # endif 410 411 // Inline namespaces for parallel mode. 412 # ifdef _GLIBCXX_PARALLEL 413 inline namespace __parallel { } 414 # endif 415 } 416 417 // Check for invalid usage and unsupported mixed-mode use. 418 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) 419 # error illegal use of multiple inlined namespaces 420 # endif 421 422 // Check for invalid use due to lack for weak symbols. 423 # if __NO_INLINE__ && !__GXX_WEAK__ 424 # warning currently using inlined namespace mode which may fail \ 425 without inlining due to lack of weak symbols 426 # endif 427 #endif 428 429 // Macros for namespace scope. Either namespace std:: or the name 430 // of some nested namespace within it corresponding to the active mode. 431 // _GLIBCXX_STD_A 432 // _GLIBCXX_STD_C 433 // 434 // Macros for opening/closing conditional namespaces. 435 // _GLIBCXX_BEGIN_NAMESPACE_ALGO 436 // _GLIBCXX_END_NAMESPACE_ALGO 437 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER 438 // _GLIBCXX_END_NAMESPACE_CONTAINER 439 #if defined(_GLIBCXX_DEBUG) 440 # define _GLIBCXX_STD_C __cxx1998 441 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ 442 namespace _GLIBCXX_STD_C { 443 # define _GLIBCXX_END_NAMESPACE_CONTAINER } 444 #else 445 # define _GLIBCXX_STD_C std 446 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER 447 # define _GLIBCXX_END_NAMESPACE_CONTAINER 448 #endif 449 450 #ifdef _GLIBCXX_PARALLEL 451 # define _GLIBCXX_STD_A __cxx1998 452 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ 453 namespace _GLIBCXX_STD_A { 454 # define _GLIBCXX_END_NAMESPACE_ALGO } 455 #else 456 # define _GLIBCXX_STD_A std 457 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO 458 # define _GLIBCXX_END_NAMESPACE_ALGO 459 #endif 460 461 // GLIBCXX_ABI Deprecated 462 // Define if compatibility should be provided for -mlong-double-64. 463 #undef _GLIBCXX_LONG_DOUBLE_COMPAT 464 465 // Define if compatibility should be provided for alternative 128-bit long 466 // double formats. Not possible for Clang until __ibm128 is supported. 467 #ifndef __clang__ 468 #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 469 #endif 470 471 // Inline namespaces for long double 128 modes. 472 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ 473 && defined __LONG_DOUBLE_IEEE128__ 474 namespace std 475 { 476 // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. 477 inline namespace __gnu_cxx_ieee128 { } 478 inline namespace __gnu_cxx11_ieee128 { } 479 } 480 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: 481 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { 482 # define _GLIBCXX_END_NAMESPACE_LDBL } 483 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: 484 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { 485 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } 486 487 #else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 488 489 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ 490 namespace std 491 { 492 inline namespace __gnu_cxx_ldbl128 { } 493 } 494 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: 495 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { 496 # define _GLIBCXX_END_NAMESPACE_LDBL } 497 #else 498 # define _GLIBCXX_NAMESPACE_LDBL 499 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL 500 # define _GLIBCXX_END_NAMESPACE_LDBL 501 #endif 502 503 #if _GLIBCXX_USE_CXX11_ABI 504 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 505 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 506 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 507 #else 508 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL 509 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL 510 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL 511 #endif 512 513 #endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 514 515 namespace std 516 { 517 #pragma GCC visibility push(default) 518 // Internal version of std::is_constant_evaluated(). 519 // This can be used without checking if the compiler supports the feature. 520 // The macro _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED can be used to check if 521 // the compiler support is present to make this function work as expected. 522 _GLIBCXX_CONSTEXPR inline bool 523 __is_constant_evaluated() _GLIBCXX_NOEXCEPT 524 { 525 #if __cpp_if_consteval >= 202106L 526 # define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1 527 if consteval { return true; } else { return false; } 528 #elif __cplusplus >= 201103L && __has_builtin(__builtin_is_constant_evaluated) 529 # define _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 1 530 return __builtin_is_constant_evaluated(); 531 #else 532 return false; 533 #endif 534 } 535 #pragma GCC visibility pop 536 } 537 538 // Debug Mode implies checking assertions. 539 #if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) 540 # define _GLIBCXX_ASSERTIONS 1 541 #endif 542 543 // Disable std::string explicit instantiation declarations in order to assert. 544 #ifdef _GLIBCXX_ASSERTIONS 545 # undef _GLIBCXX_EXTERN_TEMPLATE 546 # define _GLIBCXX_EXTERN_TEMPLATE -1 547 #endif 548 549 550 #if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED 551 # define __glibcxx_constexpr_assert(cond) \ 552 if (std::__is_constant_evaluated() && !bool(cond)) \ 553 __builtin_unreachable() /* precondition violation detected! */ 554 #else 555 # define __glibcxx_constexpr_assert(unevaluated) 556 #endif 557 558 #undef _GLIBCXX_VERBOSE_ASSERT 559 560 // Assert. 561 #if defined(_GLIBCXX_ASSERTIONS) \ 562 || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) 563 # ifdef _GLIBCXX_VERBOSE_ASSERT 564 namespace std 565 { 566 #pragma GCC visibility push(default) 567 // Avoid the use of assert, because we're trying to keep the <cassert> 568 // include out of the mix. 569 extern "C++" _GLIBCXX_NORETURN 570 void 571 __glibcxx_assert_fail(const char* __file, int __line, 572 const char* __function, const char* __condition) 573 _GLIBCXX_NOEXCEPT; 574 #pragma GCC visibility pop 575 } 576 #define __glibcxx_assert_impl(_Condition) \ 577 if (__builtin_expect(!bool(_Condition), false)) \ 578 { \ 579 __glibcxx_constexpr_assert(false); \ 580 std::__glibcxx_assert_fail(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ 581 #_Condition); \ 582 } 583 # else // ! VERBOSE_ASSERT 584 # define __glibcxx_assert_impl(_Condition) \ 585 if (__builtin_expect(!bool(_Condition), false)) \ 586 { \ 587 __glibcxx_constexpr_assert(false); \ 588 __builtin_abort(); \ 589 } 590 # endif 591 #endif 592 593 #if defined(_GLIBCXX_ASSERTIONS) 594 # define __glibcxx_assert(cond) \ 595 do { __glibcxx_assert_impl(cond); } while (false) 596 #else 597 # define __glibcxx_assert(cond) \ 598 do { __glibcxx_constexpr_assert(cond); } while (false) 599 #endif 600 601 // Macro indicating that TSAN is in use. 602 #if __SANITIZE_THREAD__ 603 # define _GLIBCXX_TSAN 1 604 #elif defined __has_feature 605 # if __has_feature(thread_sanitizer) 606 # define _GLIBCXX_TSAN 1 607 # endif 608 #endif 609 610 // Macros for race detectors. 611 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and 612 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain 613 // atomic (lock-free) synchronization to race detectors: 614 // the race detector will infer a happens-before arc from the former to the 615 // latter when they share the same argument pointer. 616 // 617 // The most frequent use case for these macros (and the only case in the 618 // current implementation of the library) is atomic reference counting: 619 // void _M_remove_reference() 620 // { 621 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); 622 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) 623 // { 624 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); 625 // _M_destroy(__a); 626 // } 627 // } 628 // The annotations in this example tell the race detector that all memory 629 // accesses occurred when the refcount was positive do not race with 630 // memory accesses which occurred after the refcount became zero. 631 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE 632 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) 633 #endif 634 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER 635 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) 636 #endif 637 638 // Macros for C linkage: define extern "C" linkage only when using C++. 639 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { 640 # define _GLIBCXX_END_EXTERN_C } 641 642 #define _GLIBCXX_USE_ALLOCATOR_NEW 643 644 #ifdef __SIZEOF_INT128__ 645 #if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ 646 // If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined 647 // unless the compiler is in strict mode. If it's not defined and the strict 648 // macro is not defined, something is wrong. 649 #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" 650 #endif 651 #endif 652 653 #else // !__cplusplus 654 # define _GLIBCXX_BEGIN_EXTERN_C 655 # define _GLIBCXX_END_EXTERN_C 656 #endif 657 658 659 // First includes. 660 661 // Pick up any OS-specific definitions. 662 #include <bits/os_defines.h> 663 664 // Pick up any CPU-specific definitions. 665 #include <bits/cpu_defines.h> 666 667 // If platform uses neither visibility nor psuedo-visibility, 668 // specify empty default for namespace annotation macros. 669 #ifndef _GLIBCXX_PSEUDO_VISIBILITY 670 # define _GLIBCXX_PSEUDO_VISIBILITY(V) 671 #endif 672 673 // Certain function definitions that are meant to be overridable from 674 // user code are decorated with this macro. For some targets, this 675 // macro causes these definitions to be weak. 676 #ifndef _GLIBCXX_WEAK_DEFINITION 677 # define _GLIBCXX_WEAK_DEFINITION 678 #endif 679 680 // By default, we assume that __GXX_WEAK__ also means that there is support 681 // for declaring functions as weak while not defining such functions. This 682 // allows for referring to functions provided by other libraries (e.g., 683 // libitm) without depending on them if the respective features are not used. 684 #ifndef _GLIBCXX_USE_WEAK_REF 685 # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ 686 #endif 687 688 // Conditionally enable annotations for the Transactional Memory TS on C++11. 689 // Most of the following conditions are due to limitations in the current 690 // implementation. 691 #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ 692 && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ 693 && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ 694 && _GLIBCXX_USE_ALLOCATOR_NEW 695 #define _GLIBCXX_TXN_SAFE transaction_safe 696 #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic 697 #else 698 #define _GLIBCXX_TXN_SAFE 699 #define _GLIBCXX_TXN_SAFE_DYN 700 #endif 701 702 #if __cplusplus > 201402L 703 // In C++17 mathematical special functions are in namespace std. 704 # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 705 #elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 706 // For C++11 and C++14 they are in namespace std when requested. 707 # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 708 #endif 709 710 // The remainder of the prewritten config is automatic; all the 711 // user hooks are listed above. 712 713 // Create a boolean flag to be used to determine if --fast-math is set. 714 #ifdef __FAST_MATH__ 715 # define _GLIBCXX_FAST_MATH 1 716 #else 717 # define _GLIBCXX_FAST_MATH 0 718 #endif 719 720 // This marks string literals in header files to be extracted for eventual 721 // translation. It is primarily used for messages in thrown exceptions; see 722 // src/functexcept.cc. We use __N because the more traditional _N is used 723 // for something else under certain OSes (see BADNAMES). 724 #define __N(msgid) (msgid) 725 726 // For example, <windows.h> is known to #define min and max as macros... 727 #undef min 728 #undef max 729 730 // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally 731 // so they should be tested with #if not with #ifdef. 732 #if __cplusplus >= 201103L 733 # ifndef _GLIBCXX_USE_C99_MATH 734 # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH 735 # endif 736 # ifndef _GLIBCXX_USE_C99_COMPLEX 737 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX 738 # endif 739 # ifndef _GLIBCXX_USE_C99_STDIO 740 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO 741 # endif 742 # ifndef _GLIBCXX_USE_C99_STDLIB 743 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB 744 # endif 745 # ifndef _GLIBCXX_USE_C99_WCHAR 746 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR 747 # endif 748 #else 749 # ifndef _GLIBCXX_USE_C99_MATH 750 # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH 751 # endif 752 # ifndef _GLIBCXX_USE_C99_COMPLEX 753 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX 754 # endif 755 # ifndef _GLIBCXX_USE_C99_STDIO 756 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO 757 # endif 758 # ifndef _GLIBCXX_USE_C99_STDLIB 759 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB 760 # endif 761 # ifndef _GLIBCXX_USE_C99_WCHAR 762 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR 763 # endif 764 #endif 765 766 // Unless explicitly specified, enable char8_t extensions only if the core 767 // language char8_t feature macro is defined. 768 #ifndef _GLIBCXX_USE_CHAR8_T 769 # ifdef __cpp_char8_t 770 # define _GLIBCXX_USE_CHAR8_T 1 771 # endif 772 #endif 773 #ifdef _GLIBCXX_USE_CHAR8_T 774 # define __cpp_lib_char8_t 201907L 775 #endif 776 777 /* Define if __float128 is supported on this host. */ 778 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) 779 /* For powerpc64 don't use __float128 when it's the same type as long double. */ 780 # if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) 781 # define _GLIBCXX_USE_FLOAT128 782 # endif 783 #endif 784 785 // Define if float has the IEEE binary32 format. 786 #if __FLT_MANT_DIG__ == 24 \ 787 && __FLT_MIN_EXP__ == -125 \ 788 && __FLT_MAX_EXP__ == 128 789 # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 790 #endif 791 792 // Define if double has the IEEE binary64 format. 793 #if __DBL_MANT_DIG__ == 53 \ 794 && __DBL_MIN_EXP__ == -1021 \ 795 && __DBL_MAX_EXP__ == 1024 796 # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 797 #endif 798 799 #ifdef __has_builtin 800 # ifdef __is_identifier 801 // Intel and older Clang require !__is_identifier for some built-ins: 802 # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) 803 # else 804 # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) 805 # endif 806 #endif 807 808 #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) 809 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 810 #endif 811 812 #if _GLIBCXX_HAS_BUILTIN(__is_aggregate) 813 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 814 #endif 815 816 #if _GLIBCXX_HAS_BUILTIN(__is_same) 817 # define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 818 #endif 819 820 #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) 821 # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 822 #endif 823 824 #undef _GLIBCXX_HAS_BUILTIN 825 826 // Mark code that should be ignored by the compiler, but seen by Doxygen. 827 #define _GLIBCXX_DOXYGEN_ONLY(X) 828 829 // PSTL configuration 830 831 #if __cplusplus >= 201703L 832 // This header is not installed for freestanding: 833 #if __has_include(<pstl/pstl_config.h>) 834 // Preserved here so we have some idea which version of upstream we've pulled in 835 // #define PSTL_VERSION 9000 836 837 // For now this defaults to being based on the presence of Thread Building Blocks 838 # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND 839 # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>) 840 # endif 841 // This section will need some rework when a new (default) backend type is added 842 # if _GLIBCXX_USE_TBB_PAR_BACKEND 843 # define _PSTL_PAR_BACKEND_TBB 844 # else 845 # define _PSTL_PAR_BACKEND_SERIAL 846 # endif 847 848 # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) 849 # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) 850 851 #include <pstl/pstl_config.h> 852 #endif // __has_include 853 #endif // C++17 854 855 // End of prewritten config; the settings discovered at configure time follow. 856