Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/c++/15/bits/std.compat.cc
1 // -*- C++ -*- [std.modules] module std.compat 2 3 // Copyright The GNU Toolchain Authors. 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. 9 10 // This library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // Under Section 7 of GPL version 3, you are granted additional 16 // permissions described in the GCC Runtime Library Exception, version 17 // 3.1, as published by the Free Software Foundation. 18 19 // You should have received a copy of the GNU General Public License and 20 // a copy of the GCC Runtime Library Exception along with this program; 21 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 // <http://www.gnu.org/licenses/>. 23 24 module; 25 26 #include <stdbit.h> 27 #include <stdckdint.h> 28 29 export module std.compat; 30 export import std; 31 32 #ifdef __STDC_VERSION_STDBIT_H__ 33 // <stdbit.h> 34 export 35 { 36 #define _GLIBCXX_STDBIT_FUNC(F) \ 37 using __gnu_cxx::F ## _uc; \ 38 using __gnu_cxx::F ## _us; \ 39 using __gnu_cxx::F ## _ui; \ 40 using __gnu_cxx::F ## _ul; \ 41 using __gnu_cxx::F ## _ull; \ 42 using __gnu_cxx::F 43 _GLIBCXX_STDBIT_FUNC(stdc_leading_zeros); 44 _GLIBCXX_STDBIT_FUNC(stdc_leading_ones); 45 _GLIBCXX_STDBIT_FUNC(stdc_trailing_zeros); 46 _GLIBCXX_STDBIT_FUNC(stdc_trailing_ones); 47 _GLIBCXX_STDBIT_FUNC(stdc_first_leading_zero); 48 _GLIBCXX_STDBIT_FUNC(stdc_first_leading_one); 49 _GLIBCXX_STDBIT_FUNC(stdc_first_trailing_zero); 50 _GLIBCXX_STDBIT_FUNC(stdc_first_trailing_one); 51 _GLIBCXX_STDBIT_FUNC(stdc_count_zeros); 52 _GLIBCXX_STDBIT_FUNC(stdc_count_ones); 53 _GLIBCXX_STDBIT_FUNC(stdc_has_single_bit); 54 _GLIBCXX_STDBIT_FUNC(stdc_bit_width); 55 _GLIBCXX_STDBIT_FUNC(stdc_bit_floor); 56 _GLIBCXX_STDBIT_FUNC(stdc_bit_ceil); 57 #undef _GLIBCXX_STDBIT_FUNC 58 } 59 #endif 60 61 #ifdef __STDC_VERSION_STDCKDINT_H__ 62 // <stdckdint.h> 63 export 64 { 65 using __gnu_cxx::ckd_add; 66 using __gnu_cxx::ckd_sub; 67 using __gnu_cxx::ckd_mul; 68 } 69 #endif 70 71 #define STD_COMPAT 1 72 73 // C library exports are appended from std-clib.cc.in. 74 // C standard library exports for -*- C++ -*- std and std.compat modules 75 // This file is appended to std.cc.in or std-compat.cc.in. 76 77 #ifdef STD_COMPAT 78 #define C_LIB_NAMESPACE 79 #else 80 #define C_LIB_NAMESPACE namespace std 81 #endif 82 83 // C standard library headers [tab:headers.cpp.c] 84 85 // 19.3 <cassert> 86 // No exports 87 88 // 23.5.1 <cctype> 89 export C_LIB_NAMESPACE 90 { 91 using std::isalnum; 92 using std::isalpha; 93 #ifdef _GLIBCXX_USE_C99_CTYPE 94 using std::isblank; 95 #endif 96 using std::iscntrl; 97 using std::isdigit; 98 using std::isgraph; 99 using std::islower; 100 using std::isprint; 101 using std::ispunct; 102 using std::isspace; 103 using std::isupper; 104 using std::isxdigit; 105 using std::tolower; 106 using std::toupper; 107 } 108 109 // 19.4 <cerrno> 110 // No exports 111 112 // 28.3 <cfenv> 113 export C_LIB_NAMESPACE 114 { 115 #ifdef _GLIBCXX_USE_C99_FENV 116 using std::feclearexcept; 117 using std::fegetenv; 118 using std::fegetexceptflag; 119 using std::fegetround; 120 using std::feholdexcept; 121 using std::fenv_t; 122 using std::feraiseexcept; 123 using std::fesetenv; 124 using std::fesetexceptflag; 125 using std::fesetround; 126 using std::fetestexcept; 127 using std::feupdateenv; 128 using std::fexcept_t; 129 #endif 130 } 131 132 // 17.3.7 <cfloat> [cfloat.syn] 133 // No exports, only provides macros 134 135 // 31.13.2 <cinttypes> 136 export C_LIB_NAMESPACE 137 { 138 #ifdef _GLIBCXX_USE_C99_INTTYPES 139 using std::imaxabs; 140 using std::imaxdiv; 141 using std::imaxdiv_t; 142 using std::strtoimax; 143 using std::strtoumax; 144 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T 145 using std::wcstoimax; 146 using std::wcstoumax; 147 #endif 148 #endif 149 } 150 151 // 17.3.6 <climits> [climits.syn] 152 // No exports, only provides macros 153 154 // 30.5 <clocale> 155 export C_LIB_NAMESPACE 156 { 157 using std::lconv; 158 using std::localeconv; 159 using std::setlocale; 160 // LC_* macros not exported 161 } 162 163 // 28.7.1 <cmath> 164 export C_LIB_NAMESPACE 165 { 166 using std::abs; 167 using std::acos; 168 using std::acosf; 169 using std::acosh; 170 using std::acoshf; 171 using std::acoshl; 172 using std::acosl; 173 using std::asin; 174 using std::asinf; 175 using std::asinh; 176 using std::asinhf; 177 using std::asinhl; 178 using std::asinl; 179 using std::atan; 180 using std::atan2; 181 using std::atan2f; 182 using std::atan2l; 183 using std::atanf; 184 using std::atanh; 185 using std::atanhf; 186 using std::atanhl; 187 using std::atanl; 188 using std::cbrt; 189 using std::cbrtf; 190 using std::cbrtl; 191 using std::ceil; 192 using std::ceilf; 193 using std::ceill; 194 using std::copysign; 195 using std::copysignf; 196 using std::copysignl; 197 using std::cos; 198 using std::cosf; 199 using std::cosh; 200 using std::coshf; 201 using std::coshl; 202 using std::cosl; 203 using std::double_t; 204 using std::erf; 205 using std::erfc; 206 using std::erfcf; 207 using std::erfcl; 208 using std::erff; 209 using std::erfl; 210 using std::exp; 211 using std::exp2; 212 using std::exp2f; 213 using std::exp2l; 214 using std::expf; 215 using std::expl; 216 using std::expm1; 217 using std::expm1f; 218 using std::expm1l; 219 using std::fabs; 220 using std::fabsf; 221 using std::fabsl; 222 using std::fdim; 223 using std::fdimf; 224 using std::fdiml; 225 using std::float_t; 226 using std::floor; 227 using std::floorf; 228 using std::floorl; 229 using std::fma; 230 using std::fmaf; 231 using std::fmal; 232 using std::fmax; 233 using std::fmaxf; 234 using std::fmaxl; 235 using std::fmin; 236 using std::fminf; 237 using std::fminl; 238 using std::fmod; 239 using std::fmodf; 240 using std::fmodl; 241 using std::fpclassify; 242 using std::frexp; 243 using std::frexpf; 244 using std::frexpl; 245 using std::hypot; 246 using std::hypotf; 247 using std::hypotl; 248 using std::ilogb; 249 using std::ilogbf; 250 using std::ilogbl; 251 using std::isfinite; 252 using std::isgreater; 253 using std::isgreaterequal; 254 using std::isinf; 255 using std::isless; 256 using std::islessequal; 257 using std::islessgreater; 258 using std::isnan; 259 using std::isnormal; 260 using std::isunordered; 261 using std::ldexp; 262 using std::ldexpf; 263 using std::ldexpl; 264 #ifndef STD_COMPAT 265 using std::lerp; 266 #endif 267 using std::lgamma; 268 using std::lgammaf; 269 using std::lgammal; 270 using std::llrint; 271 using std::llrintf; 272 using std::llrintl; 273 using std::llround; 274 using std::llroundf; 275 using std::llroundl; 276 using std::log; 277 using std::log10; 278 using std::log10f; 279 using std::log10l; 280 using std::log1p; 281 using std::log1pf; 282 using std::log1pl; 283 using std::log2; 284 using std::log2f; 285 using std::log2l; 286 using std::logb; 287 using std::logbf; 288 using std::logbl; 289 using std::logf; 290 using std::logl; 291 using std::lrint; 292 using std::lrintf; 293 using std::lrintl; 294 using std::lround; 295 using std::lroundf; 296 using std::lroundl; 297 using std::modf; 298 using std::modff; 299 using std::modfl; 300 using std::nan; 301 using std::nanf; 302 using std::nanl; 303 using std::nearbyint; 304 using std::nearbyintf; 305 using std::nearbyintl; 306 using std::nextafter; 307 using std::nextafterf; 308 using std::nextafterl; 309 using std::nexttoward; 310 using std::nexttowardf; 311 using std::nexttowardl; 312 using std::pow; 313 using std::powf; 314 using std::powl; 315 using std::remainder; 316 using std::remainderf; 317 using std::remainderl; 318 using std::remquo; 319 using std::remquof; 320 using std::remquol; 321 using std::rint; 322 using std::rintf; 323 using std::rintl; 324 using std::round; 325 using std::roundf; 326 using std::roundl; 327 using std::scalbln; 328 using std::scalblnf; 329 using std::scalblnl; 330 using std::scalbn; 331 using std::scalbnf; 332 using std::scalbnl; 333 using std::signbit; 334 using std::sin; 335 using std::sinf; 336 using std::sinh; 337 using std::sinhf; 338 using std::sinhl; 339 using std::sinl; 340 using std::sqrt; 341 using std::sqrtf; 342 using std::sqrtl; 343 using std::tan; 344 using std::tanf; 345 using std::tanh; 346 using std::tanhf; 347 using std::tanhl; 348 using std::tanl; 349 using std::tgamma; 350 using std::tgammaf; 351 using std::tgammal; 352 using std::trunc; 353 using std::truncf; 354 using std::truncl; 355 356 #if __cpp_lib_math_special_functions && !defined(STD_COMPAT) 357 using std::assoc_laguerre; 358 using std::assoc_laguerref; 359 using std::assoc_laguerrel; 360 using std::assoc_legendre; 361 using std::assoc_legendref; 362 using std::assoc_legendrel; 363 using std::beta; 364 using std::betaf; 365 using std::betal; 366 using std::comp_ellint_1; 367 using std::comp_ellint_1f; 368 using std::comp_ellint_1l; 369 using std::comp_ellint_2; 370 using std::comp_ellint_2f; 371 using std::comp_ellint_2l; 372 using std::comp_ellint_3; 373 using std::comp_ellint_3f; 374 using std::comp_ellint_3l; 375 using std::cyl_bessel_i; 376 using std::cyl_bessel_if; 377 using std::cyl_bessel_il; 378 using std::cyl_bessel_j; 379 using std::cyl_bessel_jf; 380 using std::cyl_bessel_jl; 381 using std::cyl_bessel_k; 382 using std::cyl_bessel_kf; 383 using std::cyl_bessel_kl; 384 using std::cyl_neumann; 385 using std::cyl_neumannf; 386 using std::cyl_neumannl; 387 using std::ellint_1; 388 using std::ellint_1f; 389 using std::ellint_1l; 390 using std::ellint_2; 391 using std::ellint_2f; 392 using std::ellint_2l; 393 using std::ellint_3; 394 using std::ellint_3f; 395 using std::ellint_3l; 396 using std::expint; 397 using std::expintf; 398 using std::expintl; 399 using std::hermite; 400 using std::hermitef; 401 using std::hermitel; 402 using std::legendre; 403 using std::legendref; 404 using std::legendrel; 405 using std::laguerre; 406 using std::laguerref; 407 using std::laguerrel; 408 using std::riemann_zeta; 409 using std::riemann_zetaf; 410 using std::riemann_zetal; 411 using std::sph_bessel; 412 using std::sph_besself; 413 using std::sph_bessell; 414 using std::sph_legendre; 415 using std::sph_legendref; 416 using std::sph_legendrel; 417 using std::sph_neumann; 418 using std::sph_neumannf; 419 using std::sph_neumannl; 420 #endif 421 } 422 423 // 17.13.3 <csetjmp> 424 export C_LIB_NAMESPACE 425 { 426 using std::jmp_buf; 427 using std::longjmp; 428 // setjmp macro not exported 429 } 430 431 // 17.13.4 <csignal> 432 export C_LIB_NAMESPACE 433 { 434 using std::raise; 435 using std::sig_atomic_t; 436 using std::signal; 437 // SIG_* macros not exported 438 } 439 440 // 17.13.2 <cstdarg> 441 export C_LIB_NAMESPACE 442 { 443 using std::va_list; 444 // va_arg and friend macros not exported 445 } 446 447 // 17.2.1 <cstddef> [cstddef.syn] 448 export C_LIB_NAMESPACE 449 { 450 using std::max_align_t; 451 using std::nullptr_t; 452 using std::ptrdiff_t; 453 using std::size_t; 454 #ifndef STD_COMPAT 455 using std::byte; 456 using std::operator<<=; 457 using std::operator<<; 458 using std::operator>>=; 459 using std::operator>>; 460 using std::operator|=; 461 using std::operator|; 462 using std::operator&=; 463 using std::operator&; 464 using std::operator^=; 465 using std::operator^; 466 using std::operator~; 467 using std::to_integer; 468 #endif 469 // NULL and offsetof macros not exported 470 } 471 472 // 17.4 <cstdint> 473 export C_LIB_NAMESPACE 474 { 475 using std::int8_t; 476 using std::int16_t; 477 using std::int32_t; 478 using std::int64_t; 479 using std::int_fast16_t; 480 using std::int_fast32_t; 481 using std::int_fast64_t; 482 using std::int_fast8_t; 483 using std::int_least16_t; 484 using std::int_least32_t; 485 using std::int_least64_t; 486 using std::int_least8_t; 487 using std::intmax_t; 488 using std::intptr_t; 489 using std::uint8_t; 490 using std::uint16_t; 491 using std::uint32_t; 492 using std::uint64_t; 493 using std::uint_fast16_t; 494 using std::uint_fast32_t; 495 using std::uint_fast64_t; 496 using std::uint_fast8_t; 497 using std::uint_least16_t; 498 using std::uint_least32_t; 499 using std::uint_least64_t; 500 using std::uint_least8_t; 501 using std::uintmax_t; 502 using std::uintptr_t; 503 } 504 505 // 31.13.1 <cstdio> 506 export C_LIB_NAMESPACE 507 { 508 using std::clearerr; 509 using std::fclose; 510 using std::feof; 511 using std::ferror; 512 using std::fflush; 513 using std::fgetc; 514 using std::fgetpos; 515 using std::fgets; 516 using std::FILE; 517 using std::fopen; 518 using std::fpos_t; 519 using std::fprintf; 520 using std::fputc; 521 using std::fputs; 522 using std::fread; 523 using std::freopen; 524 using std::fscanf; 525 using std::fseek; 526 using std::fsetpos; 527 using std::ftell; 528 using std::fwrite; 529 using std::getc; 530 using std::getchar; 531 using std::perror; 532 using std::printf; 533 using std::putc; 534 using std::putchar; 535 using std::puts; 536 using std::remove; 537 using std::rename; 538 using std::rewind; 539 using std::scanf; 540 using std::setbuf; 541 using std::setvbuf; 542 using std::size_t; 543 using std::snprintf; 544 using std::sprintf; 545 using std::sscanf; 546 using std::tmpfile; 547 #if _GLIBCXX_USE_TMPNAM 548 using std::tmpnam; 549 #endif 550 using std::ungetc; 551 using std::vfprintf; 552 using std::vfscanf; 553 using std::vprintf; 554 using std::vscanf; 555 using std::vsnprintf; 556 using std::vsprintf; 557 using std::vsscanf; 558 } 559 560 // 17.2.2 <cstdlib> [cstdlib.syn] 561 export C_LIB_NAMESPACE 562 { 563 using std::_Exit; 564 using std::abort; 565 using std::abs; 566 #ifdef _GLIBCXX_HAVE_ALIGNED_ALLOC 567 using std::aligned_alloc; 568 #endif 569 #ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 570 using std::at_quick_exit; 571 #endif 572 using std::atexit; 573 using std::atof; 574 using std::atoi; 575 using std::atol; 576 using std::atoll; 577 using std::bsearch; 578 using std::calloc; 579 using std::div; 580 using std::div_t; 581 using std::exit; 582 using std::free; 583 using std::getenv; 584 using std::labs; 585 using std::ldiv; 586 using std::ldiv_t; 587 using std::llabs; 588 using std::lldiv; 589 using std::lldiv_t; 590 using std::malloc; 591 #ifdef _GLIBCXX_HAVE_MBSTATE_T 592 using std::mblen; 593 using std::mbstowcs; 594 using std::mbtowc; 595 #endif 596 using std::qsort; 597 #ifdef _GLIBCXX_HAVE_QUICK_EXIT 598 using std::quick_exit; 599 #endif 600 using std::rand; 601 using std::realloc; 602 using std::size_t; 603 using std::srand; 604 using std::strtod; 605 using std::strtof; 606 using std::strtol; 607 using std::strtold; 608 using std::strtoll; 609 using std::strtoul; 610 using std::strtoull; 611 using std::system; 612 #ifdef _GLIBCXX_USE_WCHAR_T 613 using std::wcstombs; 614 using std::wctomb; 615 #endif 616 } 617 618 // 23.5.3 <cstring> 619 export C_LIB_NAMESPACE 620 { 621 using std::memchr; 622 using std::memcmp; 623 using std::memcpy; 624 using std::memmove; 625 using std::memset; 626 using std::size_t; 627 using std::strcat; 628 using std::strchr; 629 using std::strcmp; 630 using std::strcoll; 631 using std::strcpy; 632 using std::strcspn; 633 using std::strerror; 634 using std::strlen; 635 using std::strncat; 636 using std::strncmp; 637 using std::strncpy; 638 using std::strpbrk; 639 using std::strrchr; 640 using std::strspn; 641 using std::strstr; 642 using std::strtok; 643 using std::strxfrm; 644 } 645 646 // 29.15 <ctime> 647 export C_LIB_NAMESPACE 648 { 649 using std::asctime; 650 using std::clock; 651 using std::clock_t; 652 using std::ctime; 653 using std::difftime; 654 using std::gmtime; 655 using std::localtime; 656 using std::mktime; 657 using std::size_t; 658 using std::strftime; 659 using std::time; 660 using std::time_t; 661 using std::tm; 662 #ifdef _GLIBCXX_HAVE_TIMESPEC_GET 663 using std::timespec; 664 using std::timespec_get; 665 #endif 666 } 667 668 // 23.5.5 <cuchar> 669 export C_LIB_NAMESPACE 670 { 671 #if _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 672 using std::mbrtoc8; 673 using std::c8rtomb; 674 #endif 675 #if _GLIBCXX_USE_C11_UCHAR_CXX11 676 using std::mbrtoc16; 677 using std::c16rtomb; 678 using std::mbrtoc32; 679 using std::c32rtomb; 680 #endif 681 } 682 683 #if _GLIBCXX_USE_WCHAR_T 684 // 23.5.4 <cwchar> 685 export C_LIB_NAMESPACE 686 { 687 using std::btowc; 688 using std::fgetwc; 689 using std::fgetws; 690 using std::fputwc; 691 using std::fputws; 692 using std::fwide; 693 using std::fwprintf; 694 using std::fwscanf; 695 using std::getwc; 696 using std::getwchar; 697 using std::mbrlen; 698 using std::mbrtowc; 699 using std::mbsinit; 700 using std::mbsrtowcs; 701 using std::mbstate_t; 702 using std::putwc; 703 using std::putwchar; 704 using std::size_t; 705 using std::swprintf; 706 using std::swscanf; 707 using std::tm; 708 using std::ungetwc; 709 using std::vfwprintf; 710 # if _GLIBCXX_HAVE_VFWSCANF 711 using std::vfwscanf; 712 #endif 713 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 714 using std::vswprintf; 715 #endif 716 # if _GLIBCXX_HAVE_VSWSCANF 717 using std::vswscanf; 718 #endif 719 using std::vwprintf; 720 # if _GLIBCXX_HAVE_VWSCANF 721 using std::vwscanf; 722 #endif 723 using std::wcrtomb; 724 using std::wcscat; 725 using std::wcschr; 726 using std::wcscmp; 727 using std::wcscoll; 728 using std::wcscpy; 729 using std::wcscspn; 730 using std::wcsftime; 731 using std::wcslen; 732 using std::wcsncat; 733 using std::wcsncmp; 734 using std::wcsncpy; 735 using std::wcspbrk; 736 using std::wcsrchr; 737 using std::wcsrtombs; 738 using std::wcsspn; 739 using std::wcsstr; 740 using std::wcstod; 741 #if _GLIBCXX_HAVE_WCSTOF 742 using std::wcstof; 743 #endif 744 using std::wcstok; 745 using std::wcstol; 746 #if _GLIBCXX_USE_C99_WCHAR 747 using std::wcstold; 748 using std::wcstoll; 749 #endif 750 using std::wcstoul; 751 #if _GLIBCXX_USE_C99_WCHAR 752 using std::wcstoull; 753 #endif 754 using std::wcsxfrm; 755 using std::wctob; 756 using std::wint_t; 757 using std::wmemchr; 758 using std::wmemcmp; 759 using std::wmemcpy; 760 using std::wmemmove; 761 using std::wmemset; 762 using std::wprintf; 763 using std::wscanf; 764 } 765 #endif 766 767 #if _GLIBCXX_USE_WCHAR_T 768 // 23.5.2 <cwctype> 769 export C_LIB_NAMESPACE 770 { 771 using std::iswalnum; 772 using std::iswalpha; 773 #if _GLIBCXX_HAVE_ISWBLANK 774 using std::iswblank; 775 #endif 776 using std::iswcntrl; 777 using std::iswctype; 778 using std::iswdigit; 779 using std::iswgraph; 780 using std::iswlower; 781 using std::iswprint; 782 using std::iswpunct; 783 using std::iswspace; 784 using std::iswupper; 785 using std::iswxdigit; 786 using std::towctrans; 787 using std::towlower; 788 using std::towupper; 789 using std::wctrans; 790 using std::wctrans_t; 791 using std::wctype; 792 using std::wctype_t; 793 using std::wint_t; 794 } 795 #endif