From 2bd112dee7f9786a0484d9281899a9bb0b2ae57d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 7 Oct 2022 12:18:57 +0100 Subject: libstdc++: std::make_signed_t should be ill-formed Currently we only reject std::make_signed_t but not cv bool. Similarly for std::make_unsigned_t. As well as making those ill-formed, this adds a requires-clause to the make_signed and make_unsigned primary templates. This makes non-integral, non-enum cases fail immediately with a clear error, rather than giving an error about __make_signed_selector being incomplete. libstdc++-v3/ChangeLog: * include/std/type_traits (make_signed, make_unsigned): Add specializations for cv bool. Add requires-clause for C++20 to improve diagnostics for non-integral, non-enum cases. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Check cv bool. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: Adjust expected errors for C++20 and later. * testsuite/lib/prune.exp: Prune "in requirements [with ...]" lines from diagnostics. --- libstdc++-v3/include/std/type_traits | 18 +++++++++++---- .../make_signed/requirements/typedefs_neg.cc | 27 ++++++++++------------ .../make_unsigned/requirements/typedefs_neg.cc | 25 +++++++++----------- .../range_access/range_access_cpp20_neg.cc | 3 ++- libstdc++-v3/testsuite/lib/prune.exp | 1 + 5 files changed, 40 insertions(+), 34 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b74565e..6108b98 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1802,12 +1802,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_unsigned template +#if __cpp_concepts + requires is_integral<_Tp>::value || __is_enum(_Tp) +#endif struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; // Integral, but don't define. - template<> - struct make_unsigned; + template<> struct make_unsigned; + template<> struct make_unsigned; + template<> struct make_unsigned; + template<> struct make_unsigned; /// @cond undocumented @@ -1932,12 +1937,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_signed template +#if __cpp_concepts + requires is_integral<_Tp>::value || __is_enum(_Tp) +#endif struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; // Integral, but don't define. - template<> - struct make_signed; + template<> struct make_signed; + template<> struct make_signed; + template<> struct make_signed; + template<> struct make_signed; #if __cplusplus > 201103L /// Alias template for make_signed diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 051bb64..88b8ae8 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -20,31 +20,28 @@ // . #include -#include -enum test_enum { first_selection }; +struct pod_class { }; void test01() { using std::make_signed; // Negative tests. - typedef make_signed::type test1_type; + using T1 = make_signed::type; // { dg-error "incomplete" } + using T2 = make_signed::type; // { dg-error "incomplete" } + using T3 = make_signed::type; // { dg-error "incomplete" } + using T4 = make_signed::type; // { dg-error "incomplete" } - typedef make_signed<__gnu_test::pod_uint>::type test2_type; + using T5 = make_signed::type; // { dg-error "here" } - typedef make_signed::type test3_type; + using T6 = make_signed::type; // { dg-error "here" } - typedef void (fn_type) (); - typedef make_signed::type test4_type; + using fn_type = void (); + using T7 = make_signed::type; // { dg-error "here" } - typedef make_signed::type test5_type; + using T8 = make_signed::type; // { dg-error "here" } } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 32 } -// { dg-error "required from here" "" { target *-*-* } 34 } -// { dg-error "required from here" "" { target *-*-* } 36 } -// { dg-error "required from here" "" { target *-*-* } 39 } -// { dg-error "required from here" "" { target *-*-* } 41 } - -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 } +// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 } +// { dg-error "constraint failure" "" { target c++20 } 0 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index ff98cc4..50f15e7 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -21,7 +21,6 @@ #include -enum test_enum { first_selection }; struct pod_class { }; void test01() @@ -29,22 +28,20 @@ void test01() using std::make_unsigned; // Negative tests. - typedef make_unsigned::type test1_type; + using T1 = make_unsigned::type; // { dg-error "incomplete" } + using T2 = make_unsigned::type; // { dg-error "incomplete" } + using T3 = make_unsigned::type; // { dg-error "incomplete" } + using T4 = make_unsigned::type; // { dg-error "incomplete" } - typedef make_unsigned::type test2_type; + using T5 = make_unsigned::type; // { dg-error "here" } - typedef make_unsigned::type test3_type; + using T6 = make_unsigned::type; // { dg-error "here" } - typedef void (fn_type) (); - typedef make_unsigned::type test4_type; + using fn_type = void (); + using T7 = make_unsigned::type; // { dg-error "here" } - typedef make_unsigned::type test5_type; + using T8 = make_unsigned::type; // { dg-error "here" } } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 32 } -// { dg-error "required from here" "" { target *-*-* } 34 } -// { dg-error "required from here" "" { target *-*-* } 36 } -// { dg-error "required from here" "" { target *-*-* } 39 } -// { dg-error "required from here" "" { target *-*-* } 41 } - -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 } +// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 } +// { dg-error "constraint failure" "" { target c++20 } 0 } diff --git a/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc b/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc index c0825a5..26c8ae0 100644 --- a/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc +++ b/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc @@ -46,4 +46,5 @@ test03() C c; std::ssize(c); // { dg-error "no matching function" } } -// { dg-error "incomplete type .*make_signed.*S" "" { target *-*-* } 0 } +// { dg-error "incomplete type .*make_signed.*S" "" { target c++17_down } 0 } +// { dg-error "constraint failure" "" { target c++20 } 0 } diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp index d457e97..6d0b77a 100644 --- a/libstdc++-v3/testsuite/lib/prune.exp +++ b/libstdc++-v3/testsuite/lib/prune.exp @@ -51,6 +51,7 @@ proc libstdc++-dg-prune { system text } { regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: in .constexpr. expansion \[^\n\]*" $text "" text + regsub -all "(^|\n)\[^\n\]*: in requirements .with\[^\n\]*" $text "" text regsub -all "(^|\n) inlined from \[^\n\]*" $text "" text # Why doesn't GCC need these to strip header context? regsub -all "(^|\n)In file included from \[^\n\]*" $text "" text -- cgit v1.1 From 1d2f07ed4ce028a7c1f9b18f5d959f30213545ca Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 10 Oct 2022 15:06:53 +0100 Subject: libstdc++: Revert addition of constraints to make_signed/make_unsigned Constraining the primary template makes it unusable in uninstantiated contexts. libstdc++-v3/ChangeLog: * include/std/type_traits (make_signed, make_unsigned): Remove constraints on primary template. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Undo changes to expected error in C++20 mode. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: Likewise. * testsuite/20_util/make_signed/requirements/uninstantiated.cc: New test. * testsuite/20_util/make_unsigned/requirements/uninstantiated.cc: New test. --- libstdc++-v3/include/std/type_traits | 6 ------ .../testsuite/20_util/make_signed/requirements/typedefs_neg.cc | 3 +-- .../testsuite/20_util/make_signed/requirements/uninstantiated.cc | 8 ++++++++ .../testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc | 3 +-- .../20_util/make_unsigned/requirements/uninstantiated.cc | 8 ++++++++ .../testsuite/24_iterators/range_access/range_access_cpp20_neg.cc | 3 +-- 6 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 6108b98..1d7c3b0 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1802,9 +1802,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_unsigned template -#if __cpp_concepts - requires is_integral<_Tp>::value || __is_enum(_Tp) -#endif struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; @@ -1937,9 +1934,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Primary template. /// make_signed template -#if __cpp_concepts - requires is_integral<_Tp>::value || __is_enum(_Tp) -#endif struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 88b8ae8..451eeb8 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -43,5 +43,4 @@ void test01() using T8 = make_signed::type; // { dg-error "here" } } -// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 } -// { dg-error "constraint failure" "" { target c++20 } 0 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc new file mode 100644 index 0000000..3facf0c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/uninstantiated.cc @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } +#include + +// Check that we can name invalid specializations, just don't instantiate them. + +using X = std::make_signed; +using Y = std::make_signed; +using Z = std::make_signed; diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 50f15e7..49d5209 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -43,5 +43,4 @@ void test01() using T8 = make_unsigned::type; // { dg-error "here" } } -// { dg-error "invalid use of incomplete type" "" { target c++17_down } 0 } -// { dg-error "constraint failure" "" { target c++20 } 0 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc new file mode 100644 index 0000000..9b86096 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/uninstantiated.cc @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } +#include + +// Check that we can name invalid specializations, just don't instantiate them. + +using X = std::make_unsigned; +using Y = std::make_unsigned; +using Z = std::make_unsigned; diff --git a/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc b/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc index 26c8ae0..c0825a5 100644 --- a/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc +++ b/libstdc++-v3/testsuite/24_iterators/range_access/range_access_cpp20_neg.cc @@ -46,5 +46,4 @@ test03() C c; std::ssize(c); // { dg-error "no matching function" } } -// { dg-error "incomplete type .*make_signed.*S" "" { target c++17_down } 0 } -// { dg-error "constraint failure" "" { target c++20 } 0 } +// { dg-error "incomplete type .*make_signed.*S" "" { target *-*-* } 0 } -- cgit v1.1 From 27bfe54e975d12aac750f0702f716a4c1c0a81fe Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 11 Oct 2022 00:17:00 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 68f9a1d..58b011b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2022-10-10 Jonathan Wakely + + * include/std/type_traits (make_signed, make_unsigned): Remove + constraints on primary template. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Undo changes to expected error in C++20 mode. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + * testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: + Likewise. + * testsuite/20_util/make_signed/requirements/uninstantiated.cc: + New test. + * testsuite/20_util/make_unsigned/requirements/uninstantiated.cc: + New test. + +2022-10-10 Jonathan Wakely + + * include/std/type_traits (make_signed, make_unsigned): Add + specializations for cv bool. Add requires-clause for C++20 to + improve diagnostics for non-integral, non-enum cases. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Check cv bool. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + * testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: + Adjust expected errors for C++20 and later. + * testsuite/lib/prune.exp: Prune "in requirements [with ...]" + lines from diagnostics. + 2022-10-07 Jonathan Wakely * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Add libstdcxx-hosted -- cgit v1.1 From 0ecd0f1cc6f8f3ba818946a42b22c2ab61f46825 Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Fri, 3 Dec 2021 17:50:56 +0000 Subject: Generic configury support for shared libs on VxWorks This change adds the configury bits to activate the build of shared libs on VxWorks ports configured with --enable-shared, for libraries variants where this is generally supported (rtp, code model !large - currently not compatible with -fPIC). Set lt_cv_deplibs_check_method in libtool.m4, so the build of libraries know how to establish dependencies. This is useful in configurations such as aarch64 where proper support of LSE relies on accurate dependency information between libstdc++ and libgcc_s to begin with. Regenerate configure scripts to reflect libtool.m4 change. 2022-10-09 Olivier Hainque * libtool.m4 (*vxworks*): When enable_shared, set dynamic_linker and friends for rtp !large. Assume the linker has the required abilities and set lt_cv_deplibs_check_method. gcc/ * config.gcc (*vxworks*): Add t-slibgcc fragment if enable_shared. libgcc/ * config.host (*vxworks*): When enable_shared, add libgcc and crtstuff "shared" fragments for rtp except large code model. (aarch64*-wrs-vxworks7*): Remove t-slibgcc-libgcc from the list of fragments. 2022-10-09 Olivier Hainque gcc/ * configure: Regenerate. libatomic/ * configure: Regenerate. libbacktrace/ * configure: Regenerate. libcc1/ * configure: Regenerate. libffi/ * configure: Regenerate. libgfortran/ * configure: Regenerate. libgomp/ * configure: Regenerate. libitm/ * configure: Regenerate. libobjc/ * configure: Regenerate. liboffloadmic/ * configure: Regenerate. liboffloadmic/ * plugin/configure: Regenerate. libphobos/ * configure: Regenerate. libquadmath/ * configure: Regenerate. libsanitizer/ * configure: Regenerate. libssp/ * configure: Regenerate. libstdc++-v3/ * configure: Regenerate. libvtv/ * configure: Regenerate. lto-plugin/ * configure: Regenerate. zlib/ * configure: Regenerate. --- libstdc++-v3/configure | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 7ead77a..4bb1d73 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -7089,6 +7089,11 @@ sysv4 | sysv4.3*) tpf*) lt_cv_deplibs_check_method=pass_all ;; +vxworks*) + # Assume VxWorks cross toolchains are built on Linux, possibly + # as canadian for Windows hosts. + lt_cv_deplibs_check_method=pass_all + ;; esac fi @@ -11747,6 +11752,25 @@ uts4*) shlibpath_var=LD_LIBRARY_PATH ;; +# Shared libraries for VwWorks, >= 7 only at this stage +# and (fpic) still incompatible with "large" code models +# in a few configurations. Only for RTP mode in any case, +# and upon explicit request at configure time. +vxworks7*) + dynamic_linker=no + case ${with_multisubdir}-${enable_shared} in + *large*) + ;; + *mrtp*-yes) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker="$host_os module_loader" + ;; + esac + ;; *) dynamic_linker=no ;; @@ -13874,8 +13898,9 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no + # For VxWorks ports, we assume the use of a GNU linker with + # standard elf conventions. + ld_shlibs_CXX=yes ;; *) @@ -15426,6 +15451,25 @@ uts4*) shlibpath_var=LD_LIBRARY_PATH ;; +# Shared libraries for VwWorks, >= 7 only at this stage +# and (fpic) still incompatible with "large" code models +# in a few configurations. Only for RTP mode in any case, +# and upon explicit request at configure time. +vxworks7*) + dynamic_linker=no + case ${with_multisubdir}-${enable_shared} in + *large*) + ;; + *mrtp*-yes) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker="$host_os module_loader" + ;; + esac + ;; *) dynamic_linker=no ;; -- cgit v1.1 From 637e3668fdc17c4e226538fb14f9fab225433d01 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 5 Oct 2022 21:21:54 +0100 Subject: libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606] Implement a long-standing request to support tuning the size of the emergency buffer for allocating exceptions after malloc fails, or to disable that buffer entirely. It's now possible to disable the dynamic allocation of the buffer and use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool. This is a built-time choice that is baked into libstdc++ and so affects all code linked against that build of libstdc++. The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N which is measured in units of sizeof(void*) not bytes. A given exception type such as std::system_error depends on the target, so giving a size in bytes wouldn't be portable across 16/32/64-bit targets. When libstdc++ is configured to use a dynamic buffer, the size of that buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES environment variable (c.f. PR libstdc++/88264). The number of exceptions to reserve space for is controlled by the "glibcxx.eh_pool.obj_count" and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be able to allocate obj_count exceptions of size obj_size*sizeof(void*) and obj_count "dependent" exceptions rethrown by std::rethrow_exception. With the ability to tune the buffer size, we can reduce the default pool size on 32-bit and 16-bit targets. Most users never need to throw 1kB exceptions in parallel from hundreds of threads after malloc is OOM. The users who do need that can use the tunables to select larger sizes. The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES to: 64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112 32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104 Or approximated by configuring with: 64-bit: --with-libstdcxx-eh-pool-obj-count=252 32-bit: --with-libstdcxx-eh-pool-obj-count=94 libstdc++-v3/ChangeLog: PR libstdc++/68606 * Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro. * configure: Regenerate. * configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC. * crossconfig.m4: Check for secure_getenv. * doc/Makefile.in: Regenerate. * doc/xml/manual/configure.xml: Document new configure options. * doc/xml/manual/evolution.xml: Document addition of tunables. * doc/xml/manual/using_exceptions.xml: Document emergency buffer and tunables. * doc/html/*: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.am: Use EH_POOL_FLAGS. * libsupc++/Makefile.in: Regenerate. * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units of sizeof(void*) not including the ABI's exception header. (EMERGENCY_OBJ_COUNT): Define as target-independent calculation based on word size. (MAX_OBJ_COUNT): Define macro for upper limit on pool size. (pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer. (pool::buffer_size_in_bytes): New static member function. (pool::pool): Parse GLIBCXX_TUNABLES environment variable to set pool size at runtime. (pool::in_pool): Use std::less for total order. (__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing. (__cxa_free_exception, __cxa_free_dependent_exception): Add [[unlikely]] attributes. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * src/libbacktrace/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. --- libstdc++-v3/Makefile.in | 1 + libstdc++-v3/acinclude.m4 | 45 +++++ libstdc++-v3/configure | 67 +++++- libstdc++-v3/configure.ac | 3 + libstdc++-v3/crossconfig.m4 | 1 + libstdc++-v3/doc/Makefile.in | 1 + libstdc++-v3/doc/html/index.html | 4 +- libstdc++-v3/doc/html/manual/api.html | 3 + libstdc++-v3/doc/html/manual/appendix.html | 2 +- libstdc++-v3/doc/html/manual/appendix_porting.html | 2 +- libstdc++-v3/doc/html/manual/configure.html | 10 +- libstdc++-v3/doc/html/manual/index.html | 4 +- libstdc++-v3/doc/html/manual/intro.html | 2 +- libstdc++-v3/doc/html/manual/using.html | 2 +- libstdc++-v3/doc/html/manual/using_exceptions.html | 77 ++++++- libstdc++-v3/doc/xml/manual/configure.xml | 23 +++ libstdc++-v3/doc/xml/manual/evolution.xml | 9 + libstdc++-v3/doc/xml/manual/using_exceptions.xml | 90 +++++++++ libstdc++-v3/include/Makefile.in | 1 + libstdc++-v3/libsupc++/Makefile.am | 2 +- libstdc++-v3/libsupc++/Makefile.in | 3 +- libstdc++-v3/libsupc++/eh_alloc.cc | 225 +++++++++++++++------ libstdc++-v3/po/Makefile.in | 1 + libstdc++-v3/python/Makefile.in | 1 + libstdc++-v3/src/Makefile.in | 1 + libstdc++-v3/src/c++11/Makefile.in | 1 + libstdc++-v3/src/c++17/Makefile.in | 1 + libstdc++-v3/src/c++20/Makefile.in | 1 + libstdc++-v3/src/c++98/Makefile.in | 1 + libstdc++-v3/src/filesystem/Makefile.in | 1 + libstdc++-v3/src/libbacktrace/Makefile.in | 1 + libstdc++-v3/testsuite/Makefile.in | 1 + 32 files changed, 494 insertions(+), 93 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/Makefile.in b/libstdc++-v3/Makefile.in index 58a0acd..a7c2b60 100644 --- a/libstdc++-v3/Makefile.in +++ b/libstdc++-v3/Makefile.in @@ -240,6 +240,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 719eab1..6523ba9 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -5092,6 +5092,51 @@ BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DBACKTRACE_ELF_SIZE=$elfsize" GLIBCXX_CONDITIONAL(ENABLE_BACKTRACE, [test "$enable_libstdcxx_backtrace" = yes]) ]) +dnl +dnl Allow the emergency EH pool to be configured. +dnl +dnl --enable-libstdcxx-static-eh-pool will cause a fixed-size static buffer +dnl to be used for allocating exceptions after malloc fails. The default is +dnl to allocate a buffer using malloc +dnl +dnl --with-libstdcxx-eh-pool-obj-count=N will set the default size for the +dnl buffer. For a static buffer that size is fixed permanently. For a dynamic +dnl buffer it's the default, but it can be overridden from the environment. +dnl +dnl To set the default to approximately the same values as GCC 12, +dnl use --with-libstdcxx-eh-pool-obj-count=94 for 32-bit targets, +dnl and --with-libstdcxx-eh-pool-obj-count=252 for 64-bit targets. +dnl +dnl Defines: +dnl _GLIBCXX_EH_POOL_STATIC if a fixed-size static buffer should be used +dnl instead of allocating a buffer on startup. +dnl _GLIBCXX_EH_POOL_NOBJS to override the default EMERGENCY_OBJ_COUNT value. +dnl +AC_DEFUN([GLIBCXX_EMERGENCY_EH_ALLOC], [ + eh_pool_static= + eh_pool_nobjs= + AC_ARG_ENABLE([libstdcxx-static-eh-pool], + AC_HELP_STRING([--enable-libstdcxx-static-eh-pool], + [use a fixed-size static buffer for allocating exceptions if malloc fails]), + [if test "${enableval}" = yes; then + eh_pool_static="-D_GLIBCXX_EH_POOL_STATIC" + AC_MSG_NOTICE([EH pool using static buffer]) + fi],) + + AC_ARG_WITH([libstdcxx-eh-pool-obj-count], + AC_HELP_STRING([--with-libstdcxx-eh-pool-obj-count], + [the number of exceptions that can be allocated from the pool if malloc fails]), + [if test "${withval}" -ge 0 2>/dev/null; then + eh_pool_obj_count="-D_GLIBCXX_EH_POOL_NOBJS=${withval}" + AC_MSG_NOTICE([EH pool object count: ${withval}]) + else + AC_MSG_ERROR([EH pool obj count must be a non-negative integer: $withval]) + fi],) + + EH_POOL_FLAGS="$eh_pool_static $eh_pool_obj_count" + AC_SUBST(EH_POOL_FLAGS) +]) + # Macros from the top-level gcc directory. m4_include([../config/gc++filt.m4]) m4_include([../config/tls.m4]) diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 4bb1d73..b564175 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -675,6 +675,7 @@ DOT DOXYGEN BUILD_INFO_FALSE BUILD_INFO_TRUE +EH_POOL_FLAGS ENABLE_BACKTRACE_FALSE ENABLE_BACKTRACE_TRUE BACKTRACE_SUPPORTS_THREADS @@ -958,6 +959,8 @@ with_default_libstdcxx_abi enable_libstdcxx_threads enable_libstdcxx_filesystem_ts enable_libstdcxx_backtrace +enable_libstdcxx_static_eh_pool +with_libstdcxx_eh_pool_obj_count enable_cet with_gxx_include_dir enable_version_specific_runtime_libs @@ -1668,6 +1671,9 @@ Optional Features: turns on ISO/IEC TS 18822 support [default=auto] --enable-libstdcxx-backtrace turns on libbacktrace support [default=auto] + --enable-libstdcxx-static-eh-pool + use a fixed-size static buffer for allocating + exceptions if malloc fails --enable-cet enable Intel CET in target libraries [default=auto] --enable-version-specific-runtime-libs Specify that runtime libraries should be installed @@ -1695,6 +1701,9 @@ Optional Packages: --with-system-libunwind use installed libunwind --with-default-libstdcxx-abi set the std::string ABI to use by default + --with-libstdcxx-eh-pool-obj-count + the number of exceptions that can be allocated from + the pool if malloc fails --with-gxx-include-dir=DIR installation directory for include files --with-toolexeclibdir=DIR @@ -12227,7 +12236,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12206 "configure" +#line 12215 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12333,7 +12342,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12312 "configure" +#line 12321 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16053,7 +16062,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 16012 "configure" +#line 16021 "configure" int main() { typedef bool atomic_type; @@ -16088,7 +16097,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16047 "configure" +#line 16056 "configure" int main() { typedef short atomic_type; @@ -16123,7 +16132,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16082 "configure" +#line 16091 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -16159,7 +16168,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16118 "configure" +#line 16127 "configure" int main() { typedef long long atomic_type; @@ -16315,7 +16324,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16274 "configure" +#line 16283 "configure" int main() { _Decimal32 d1; @@ -16357,7 +16366,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16316 "configure" +#line 16325 "configure" template struct same { typedef T2 type; }; @@ -54268,6 +54277,17 @@ _ACEOF fi done + for ac_func in secure_getenv +do : + ac_fn_c_check_func "$LINENO" "secure_getenv" "ac_cv_func_secure_getenv" +if test "x$ac_cv_func_secure_getenv" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SECURE_GETENV 1 +_ACEOF + +fi +done + @@ -71916,6 +71936,37 @@ $as_echo "7.1.0" >&6; } fi +# For libsupc++/eh_alloc.cc defaults. + + eh_pool_static= + eh_pool_nobjs= + # Check whether --enable-libstdcxx-static-eh-pool was given. +if test "${enable_libstdcxx_static_eh_pool+set}" = set; then : + enableval=$enable_libstdcxx_static_eh_pool; if test "${enableval}" = yes; then + eh_pool_static="-D_GLIBCXX_EH_POOL_STATIC" + { $as_echo "$as_me:${as_lineno-$LINENO}: EH pool using static buffer" >&5 +$as_echo "$as_me: EH pool using static buffer" >&6;} + fi +fi + + + +# Check whether --with-libstdcxx-eh-pool-obj-count was given. +if test "${with_libstdcxx_eh_pool_obj_count+set}" = set; then : + withval=$with_libstdcxx_eh_pool_obj_count; if test "${withval}" -ge 0 2>/dev/null; then + eh_pool_obj_count="-D_GLIBCXX_EH_POOL_NOBJS=${withval}" + { $as_echo "$as_me:${as_lineno-$LINENO}: EH pool object count: ${withval}" >&5 +$as_echo "$as_me: EH pool object count: ${withval}" >&6;} + else + as_fn_error $? "EH pool obj count must be a non-negative integer: $withval" "$LINENO" 5 + fi +fi + + + EH_POOL_FLAGS="$eh_pool_static $eh_pool_obj_count" + + + # Define documentation rules conditionally. # See if makeinfo has been installed and is modern enough diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index c05fcdd..42c4530 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -538,6 +538,9 @@ GLIBCXX_CHECK_SIZE_T_MANGLING # Check which release added std::exception_ptr for the target GLIBCXX_CHECK_EXCEPTION_PTR_SYMVER +# For libsupc++/eh_alloc.cc defaults. +GLIBCXX_EMERGENCY_EH_ALLOC + # Define documentation rules conditionally. # See if makeinfo has been installed and is modern enough diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index 130f47f..b3269cb 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -187,6 +187,7 @@ case "${host}" in AC_CHECK_FUNCS(timespec_get) AC_CHECK_FUNCS(sockatmark) AC_CHECK_FUNCS(uselocale) + AC_CHECK_FUNCS(secure_getenv) AM_ICONV ;; *-mingw32*) diff --git a/libstdc++-v3/doc/Makefile.in b/libstdc++-v3/doc/Makefile.in index 6aaceea..469a608 100644 --- a/libstdc++-v3/doc/Makefile.in +++ b/libstdc++-v3/doc/Makefile.in @@ -199,6 +199,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/doc/html/index.html b/libstdc++-v3/doc/html/index.html index 1e0cecb..ce951e6 100644 --- a/libstdc++-v3/doc/html/index.html +++ b/libstdc++-v3/doc/html/index.html @@ -23,7 +23,7 @@


Table of Contents

The GNU C++ Library Manual
I. Introduction -
1. Status
Implementation Status
C++ 1998/2003
Implementation Status
Implementation Specific Behavior
C++ 2011
Implementation Specific Behavior
C++ 2014
Implementation Specific Behavior
Filesystem TS
C++ 2017
Implementation Specific Behavior
Parallelism 2 TS
C++ 2020
C++ 2023
C++ TR1
Implementation Specific Behavior
C++ TR 24733
C++ IS 29124
Implementation Specific Behavior
License
The Code: GPL
The Documentation: GPL, FDL
Bugs
Implementation Bugs
Standard Bugs
2. Setup
Prerequisites
Configure
Make
3. Using
Command Options
Headers
Header Files
Mixing Headers
The C Headers and namespace std
Precompiled Headers
Macros
Dual ABI
Troubleshooting
Namespaces
Available Namespaces
namespace std
Using Namespace Composition
Linking
Almost Nothing
Finding Dynamic or Shared Libraries
Experimental Library Extensions
Concurrency
Prerequisites
Thread Safety
Atomics
IO
Structure
Defaults
Future
Alternatives
Containers
Exceptions
Exception Safety
Exception Neutrality
Doing without
Compatibility
With C
With POSIX thread cancellation
Debugging Support
Using g++
Debug Versions of Library Binary Files
Memory Leak Hunting
Non-memory leaks in Pool and MT allocators
Data Race Hunting
Using gdb
Tracking uncaught exceptions
Debug Mode
Compile Time Checking
II. +
1. Status
Implementation Status
C++ 1998/2003
Implementation Status
Implementation Specific Behavior
C++ 2011
Implementation Specific Behavior
C++ 2014
Implementation Specific Behavior
Filesystem TS
C++ 2017
Implementation Specific Behavior
Parallelism 2 TS
C++ 2020
C++ 2023
C++ TR1
Implementation Specific Behavior
C++ TR 24733
C++ IS 29124
Implementation Specific Behavior
License
The Code: GPL
The Documentation: GPL, FDL
Bugs
Implementation Bugs
Standard Bugs
2. Setup
Prerequisites
Configure
Make
3. Using
Command Options
Headers
Header Files
Mixing Headers
The C Headers and namespace std
Precompiled Headers
Macros
Dual ABI
Troubleshooting
Namespaces
Available Namespaces
namespace std
Using Namespace Composition
Linking
Almost Nothing
Finding Dynamic or Shared Libraries
Experimental Library Extensions
Concurrency
Prerequisites
Thread Safety
Atomics
IO
Structure
Defaults
Future
Alternatives
Containers
Exceptions
Exception Safety
Exception Neutrality
Memory allocation
Doing without
Compatibility
With C
With POSIX thread cancellation
Debugging Support
Using g++
Debug Versions of Library Binary Files
Memory Leak Hunting
Non-memory leaks in Pool and MT allocators
Data Race Hunting
Using gdb
Tracking uncaught exceptions
Debug Mode
Compile Time Checking
II. Standard Contents
4. Support @@ -142,7 +142,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html index 604380e..d985767 100644 --- a/libstdc++-v3/doc/html/manual/api.html +++ b/libstdc++-v3/doc/html/manual/api.html @@ -473,4 +473,7 @@ the process.

12.3

Calling a std::bind result as volatile is ill-formed for C++20 and later. +

13

+Tunables <variable>glibcxx.eh_pool.obj_count</variable> and +<variable>glibcxx.eh_pool.obj_size</variable> were added.

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/appendix.html b/libstdc++-v3/doc/html/manual/appendix.html index c563372..3f8bac0 100644 --- a/libstdc++-v3/doc/html/manual/appendix.html +++ b/libstdc++-v3/doc/html/manual/appendix.html @@ -16,7 +16,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/appendix_porting.html b/libstdc++-v3/doc/html/manual/appendix_porting.html index 55d3f23..4b3f069 100644 --- a/libstdc++-v3/doc/html/manual/appendix_porting.html +++ b/libstdc++-v3/doc/html/manual/appendix_porting.html @@ -14,7 +14,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/configure.html b/libstdc++-v3/doc/html/manual/configure.html index 31c4da8..66adc7d 100644 --- a/libstdc++-v3/doc/html/manual/configure.html +++ b/libstdc++-v3/doc/html/manual/configure.html @@ -220,7 +220,7 @@ freestanding environment, in which only a minimal set of headers are provided. This option builds such an environment. -

--disable-libstdcxx-verbose

+

--disable-libstdcxx-hosted

This is an alias for --disable-hosted-libstdcxx.

--disable-libstdcxx-verbose

By default, the library is configured to write descriptive messages to standard error for certain events such as calling a pure virtual function or the invocation of the standard terminate handler. Those @@ -271,4 +271,12 @@ as the usual libstdc++ and libsupc++ libraries. This is enabled by default on select POSIX targets where it is known to work and disabled otherwise. +

--enable-libstdcxx-static-eh-pool

Use a fixed-size static buffer for the emergency exception handling + pool (see Memory allocation for exceptions). The default + is to allocate the pool on program startup using malloc. + With this option, a static buffer will be provided by libstdc++ instead. + This does not change the library ABI. +

--with-libstdcxx-eh-pool-obj-count=NUM

Set the size of the emergency exception handling pool. NUM is the + number of simultaneous allocated exceptions to support. + This does not change the library ABI.

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html index 2949509..292afde 100644 --- a/libstdc++-v3/doc/html/manual/index.html +++ b/libstdc++-v3/doc/html/manual/index.html @@ -4,7 +4,7 @@


Table of Contents

I. Introduction -
1. Status
Implementation Status
C++ 1998/2003
Implementation Status
Implementation Specific Behavior
C++ 2011
Implementation Specific Behavior
C++ 2014
Implementation Specific Behavior
Filesystem TS
C++ 2017
Implementation Specific Behavior
Parallelism 2 TS
C++ 2020
C++ 2023
C++ TR1
Implementation Specific Behavior
C++ TR 24733
C++ IS 29124
Implementation Specific Behavior
License
The Code: GPL
The Documentation: GPL, FDL
Bugs
Implementation Bugs
Standard Bugs
2. Setup
Prerequisites
Configure
Make
3. Using
Command Options
Headers
Header Files
Mixing Headers
The C Headers and namespace std
Precompiled Headers
Macros
Dual ABI
Troubleshooting
Namespaces
Available Namespaces
namespace std
Using Namespace Composition
Linking
Almost Nothing
Finding Dynamic or Shared Libraries
Experimental Library Extensions
Concurrency
Prerequisites
Thread Safety
Atomics
IO
Structure
Defaults
Future
Alternatives
Containers
Exceptions
Exception Safety
Exception Neutrality
Doing without
Compatibility
With C
With POSIX thread cancellation
Debugging Support
Using g++
Debug Versions of Library Binary Files
Memory Leak Hunting
Non-memory leaks in Pool and MT allocators
Data Race Hunting
Using gdb
Tracking uncaught exceptions
Debug Mode
Compile Time Checking
II. +
1. Status
Implementation Status
C++ 1998/2003
Implementation Status
Implementation Specific Behavior
C++ 2011
Implementation Specific Behavior
C++ 2014
Implementation Specific Behavior
Filesystem TS
C++ 2017
Implementation Specific Behavior
Parallelism 2 TS
C++ 2020
C++ 2023
C++ TR1
Implementation Specific Behavior
C++ TR 24733
C++ IS 29124
Implementation Specific Behavior
License
The Code: GPL
The Documentation: GPL, FDL
Bugs
Implementation Bugs
Standard Bugs
2. Setup
Prerequisites
Configure
Make
3. Using
Command Options
Headers
Header Files
Mixing Headers
The C Headers and namespace std
Precompiled Headers
Macros
Dual ABI
Troubleshooting
Namespaces
Available Namespaces
namespace std
Using Namespace Composition
Linking
Almost Nothing
Finding Dynamic or Shared Libraries
Experimental Library Extensions
Concurrency
Prerequisites
Thread Safety
Atomics
IO
Structure
Defaults
Future
Alternatives
Containers
Exceptions
Exception Safety
Exception Neutrality
Memory allocation
Doing without
Compatibility
With C
With POSIX thread cancellation
Debugging Support
Using g++
Debug Versions of Library Binary Files
Memory Leak Hunting
Non-memory leaks in Pool and MT allocators
Data Race Hunting
Using gdb
Tracking uncaught exceptions
Debug Mode
Compile Time Checking
II. Standard Contents
4. Support @@ -123,7 +123,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/intro.html b/libstdc++-v3/doc/html/manual/intro.html index 1a82344..3027cb6 100644 --- a/libstdc++-v3/doc/html/manual/intro.html +++ b/libstdc++-v3/doc/html/manual/intro.html @@ -5,4 +5,4 @@ Prev The GNU C++ Library Manual Next
\ No newline at end of file + \ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/using.html b/libstdc++-v3/doc/html/manual/using.html index 08facff..f2dc207 100644 --- a/libstdc++-v3/doc/html/manual/using.html +++ b/libstdc++-v3/doc/html/manual/using.html @@ -2,7 +2,7 @@ Chapter 3. Using

Chapter 3. Using

Command Options

Next


Chapter 3. Using

Command Options

The set of features available in the GNU C++ library is shaped by several GCC Command Options. Options that impact libstdc++ are diff --git a/libstdc++-v3/doc/html/manual/using_exceptions.html b/libstdc++-v3/doc/html/manual/using_exceptions.html index 3ae0bea..88bc05d 100644 --- a/libstdc++-v3/doc/html/manual/using_exceptions.html +++ b/libstdc++-v3/doc/html/manual/using_exceptions.html @@ -100,7 +100,62 @@ exception neutrality and exception safety. The constructors of thread that take a callable function argument swallow all exceptions resulting from executing the function argument. -

Doing without

+

Memory allocation

+ When the program throws an exception the runtime will obtain storage for + a __cxa_exception header and the thrown object itself. + Libstdc++ will try to use malloc to obtain storage, + but provides an emergency buffer to be used if malloc fails, + as described by the Itanium + exception handling ABI. +

+ Contrary to the ABI, the libstdc++ emergency buffer is not always 64kB, + and does not always allocate 1kB chunks. The buffer is used as a pool for + variable-sized allocations, so that it doesn't waste space for smaller + exception objects such as std::bad_alloc. + The total size of the buffer is scaled appropriately for the target. + Specifically it depends on sizeof(void*), so that a 64-bit + system uses a larger pool than a 32-bit system. This is done because for + 32-bit systems the exception objects (and the exception header) require + less space, and core counts and thread counts are typically lower as well. +

+ By default, libstdc++ will use malloc to allocate the buffer + on program startup. + Configuring libstdc++ with the + --enable-libstdcxx-static-eh-pool option will make it + use a static buffer instead of using malloc. +

+ The buffer size is chosen automatically, but can be overridden + by configuring with --with-libstdcxx-eh-pool-obj-count=NUM, + where NUM is the number of simultaneous allocations that + should be supported. The size of the pool will be sufficient for + NUM exceptions of 6 * sizeof(void*) bytes, + plus another NUM exceptions captured in + std::exception_ptr and rethrown using + std::rethrow_exception. The buffer size determined by the + obj-count value applies whether the buffer is reserved as static storage + or is allocated dynamically. + Setting obj-count to zero will disable the pool, so that no emergency + buffer is present. +

+ For a dynamic buffer, the default size can also be changed at runtime, + per-process, via the GLIBCXX_TUNABLES environment + variable. + The GLIBCXX_TUNABLES environment variable should be + a string of colon-separated name=value pairs. The + following names will be recognized, with the specified semantics: +

glibcxx.eh_pool.obj_count
+ The number of exception objects to provide space for in the pool. + The value must be a non-negative integer and has the same meaning as the + --with-libstdcxx-eh-pool-obj-count option for + configure. +
glibcxx.eh_pool.obj_size
+ The expected size of exception objects that the pool might get used for. + The value must be a positive integer, and is measured in units of + sizeof(void*). The default value is 6 + which is large enough to store any exception type thrown by libstdc++. + Exceptions larger than this can still be allocated from the pool, + but larger exceptions will exhaust the pool more rapidly. +

Doing without

C++ is a language that strives to be as efficient as is possible in delivering features. As such, considerable care is used by both language implementer and designers to make sure unused features @@ -265,7 +320,7 @@ is called. } catch(...) { this->_M_setstate(ios_base::badbit); } -

Bibliography

+

Bibliography

System Interface Definitions, Issue 7 (IEEE Std. 1003.1-2008) @@ -274,40 +329,44 @@ is called. . Copyright © 2008 The Open Group/The Institute of Electrical and Electronics Engineers, Inc. - .

+ .

Error and Exception Handling . David Abrahams . Boost - .

+ .

Exception-Safety in Generic Components . David Abrahams. Boost - .

+ .

Standard Library Exception Policy . Matt Austern. WG21 N1077 - .

+ .

ia64 c++ abi exception handling . Richard Henderson. GNU - .

+ .

+ . Bjarne Stroustrup.

Exceptional C++ . Exception-Safety Issues and Techniques - . Herb Sutter.

+ . Herb Sutter.

\ No newline at end of file diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml index 8c26acc..c6c5981 100644 --- a/libstdc++-v3/doc/xml/manual/configure.xml +++ b/libstdc++-v3/doc/xml/manual/configure.xml @@ -366,6 +366,11 @@ + --disable-libstdcxx-hosted + + This is an alias for --disable-hosted-libstdcxx. + + --disable-libstdcxx-verbose @@ -446,6 +451,24 @@ + --enable-libstdcxx-static-eh-pool + + Use a fixed-size static buffer for the emergency exception handling + pool (see ). The default + is to allocate the pool on program startup using malloc. + With this option, a static buffer will be provided by libstdc++ instead. + This does not change the library ABI. + + + + --with-libstdcxx-eh-pool-obj-count=NUM + + Set the size of the emergency exception handling pool. NUM is the + number of simultaneous allocated exceptions to support. + This does not change the library ABI. + + + diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml index 8293618..a29e4df 100644 --- a/libstdc++-v3/doc/xml/manual/evolution.xml +++ b/libstdc++-v3/doc/xml/manual/evolution.xml @@ -1080,4 +1080,13 @@ and later. +
<constant>13</constant> + + +Tunables glibcxx.eh_pool.obj_count and +glibcxx.eh_pool.obj_size were added. + + +
+ diff --git a/libstdc++-v3/doc/xml/manual/using_exceptions.xml b/libstdc++-v3/doc/xml/manual/using_exceptions.xml index 32bff85..47dedc1 100644 --- a/libstdc++-v3/doc/xml/manual/using_exceptions.xml +++ b/libstdc++-v3/doc/xml/manual/using_exceptions.xml @@ -188,6 +188,87 @@ exception neutrality and exception safety. +
Memory allocation + + + When the program throws an exception the runtime will obtain storage for + a __cxa_exception header and the thrown object itself. + Libstdc++ will try to use malloc to obtain storage, + but provides an emergency buffer to be used if malloc fails, + as described by the Itanium + exception handling ABI. + + + + Contrary to the ABI, the libstdc++ emergency buffer is not always 64kB, + and does not always allocate 1kB chunks. The buffer is used as a pool for + variable-sized allocations, so that it doesn't waste space for smaller + exception objects such as std::bad_alloc. + The total size of the buffer is scaled appropriately for the target. + Specifically it depends on sizeof(void*), so that a 64-bit + system uses a larger pool than a 32-bit system. This is done because for + 32-bit systems the exception objects (and the exception header) require + less space, and core counts and thread counts are typically lower as well. + + + + By default, libstdc++ will use malloc to allocate the buffer + on program startup. + libstdc++ with the + --enable-libstdcxx-static-eh-pool option will make it + use a static buffer instead of using malloc. + + + + The buffer size is chosen automatically, but can be overridden + by configuring with --with-libstdcxx-eh-pool-obj-count=NUM, + where NUM is the number of simultaneous allocations that + should be supported. The size of the pool will be sufficient for + NUM exceptions of 6 * sizeof(void*) bytes, + plus another NUM exceptions captured in + std::exception_ptr and rethrown using + std::rethrow_exception. The buffer size determined by the + obj-count value applies whether the buffer is reserved as static storage + or is allocated dynamically. + Setting obj-count to zero will disable the pool, so that no emergency + buffer is present. + + + + For a dynamic buffer, the default size can also be changed at runtime, + per-process, via the GLIBCXX_TUNABLES environment + variable. + The GLIBCXX_TUNABLES environment variable should be + a string of colon-separated name=value pairs. The + following names will be recognized, with the specified semantics: + + + + + glibcxx.eh_pool.obj_count + + The number of exception objects to provide space for in the pool. + The value must be a non-negative integer and has the same meaning as the + --with-libstdcxx-eh-pool-obj-count option for + configure. + + + + glibcxx.eh_pool.obj_size + + The expected size of exception objects that the pool might get used for. + The value must be a positive integer, and is measured in units of + sizeof(void*). The default value is 6 + which is large enough to store any exception type thrown by libstdc++. + Exceptions larger than this can still be allocated from the pool, + but larger exceptions will exhaust the pool more rapidly. + + + + +
+
Doing without @@ -538,6 +619,15 @@ is called. + + + <link xmlns:xlink="http://www.w3.org/1999/xlink" + xlink:href="https://www.gnu.org/software/libc/manual/html_node/Tunables.html"> + Tunables, The GNU C Library + </link> + + +
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 9d60755..0a3a1e3 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -199,6 +199,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index 65b5c1a..cde9fbd 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -139,7 +139,7 @@ atomicity.cc: ${atomicity_file} # as the occasion call for it. AM_CXXFLAGS = \ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ - $(XTEMPLATE_FLAGS) $(FREESTANDING_FLAGS) \ + $(XTEMPLATE_FLAGS) $(FREESTANDING_FLAGS) $(EH_POOL_FLAGS) \ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) AM_MAKEFLAGS = \ diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index a440200..1127095 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -308,6 +308,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ @@ -587,7 +588,7 @@ atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h # as the occasion call for it. AM_CXXFLAGS = \ $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ - $(XTEMPLATE_FLAGS) $(FREESTANDING_FLAGS) \ + $(XTEMPLATE_FLAGS) $(FREESTANDING_FLAGS) $(EH_POOL_FLAGS) \ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) AM_MAKEFLAGS = \ diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc index 68f3198..50dc37c 100644 --- a/libstdc++-v3/libsupc++/eh_alloc.cc +++ b/libstdc++-v3/libsupc++/eh_alloc.cc @@ -25,16 +25,45 @@ // This is derived from the C++ ABI for IA-64. Where we diverge // for cross-architecture compatibility are noted with "@@@". -#include -#include +#include // std::exception +#include // std::terminate +#include // std::malloc, std::free, std::strtoul +#include // INT_MAX +#include // std::less +#include "unwind-cxx.h" #if _GLIBCXX_HOSTED -#include +# include // std::string_view +# include // std::strchr, std::memset +# include // __gnu_cxx::__mutex, __gnu_cxx::__scoped_lock #endif -#include -#include -#include "unwind-cxx.h" -#include -#include + +// We use an emergency buffer used for exceptions when malloc fails. +// If _GLIBCXX_EH_POOL_STATIC is defined (e.g. by configure) then we use +// a fixed-size static buffer. Otherwise, allocate on startup using malloc. +// +// The size of the buffer is N * (S * P + R + D), where: +// N == The number of objects to reserve space for. +// Defaults to EMERGENCY_OBJ_COUNT, defined below. +// S == Estimated size of exception objects to account for. +// This size is in units of sizeof(void*) not bytes. +// Defaults to EMERGENCY_OBJ_SIZE, defined below. +// P == sizeof(void*). +// R == sizeof(__cxa_refcounted_exception). +// D == sizeof(__cxa_dependent_exception). +// +// This provides space for N thrown exceptions of S words each, and an +// additional N dependent exceptions from std::rethrow_exception. +// +// The calculation allows values of N and S to be target-independent, +// as the size will be scaled by the size of basic types on the target, +// and space for the C++ exception header (__cxa_refcounted_exception) +// is added automatically. +// +// For a dynamically allocated buffer, N and S can be set from the environment. +// Setting N=0 will disable the emergency buffer. +// The GLIBCXX_TUNABLES environment variable will be checked for the following: +// - Tunable glibcxx.eh_pool.obj_count overrides EMERGENCY_OBJ_COUNT. +// - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE. #if _GLIBCXX_HOSTED using std::free; @@ -50,46 +79,61 @@ extern "C" void *memset (void *, int, std::size_t); using namespace __cxxabiv1; -// ??? How to control these parameters. - -// Guess from the size of basic types how large a buffer is reasonable. -// Note that the basic c++ exception header has 13 pointers and 2 ints, -// so on a system with PSImode pointers we're talking about 56 bytes -// just for overhead. - -#if INT_MAX == 32767 -# define EMERGENCY_OBJ_SIZE 128 -# define EMERGENCY_OBJ_COUNT 16 -#elif !defined (_GLIBCXX_LLP64) && LONG_MAX == 2147483647 -# define EMERGENCY_OBJ_SIZE 512 -# define EMERGENCY_OBJ_COUNT 32 +// Assume that 6 * sizeof(void*) is a reasonable exception object size. +// Throwing very many large objects will exhaust the pool more quickly. +// N.B. sizeof(std::bad_alloc) == sizeof(void*) +// and sizeof(std::runtime_error) == 2 * sizeof(void*) +// and sizeof(std::system_error) == 4 * sizeof(void*). +#define EMERGENCY_OBJ_SIZE 6 + +#ifdef __GTHREADS +// Assume that the number of concurrent exception objects scales with the +// processor word size, i.e., 16-bit systems are not likely to have hundreds +// of threads all simultaneously throwing on OOM conditions. +# define EMERGENCY_OBJ_COUNT (4 * __SIZEOF_POINTER__ * __SIZEOF_POINTER__) +# define MAX_OBJ_COUNT (16 << __SIZEOF_POINTER__) #else -# define EMERGENCY_OBJ_SIZE 1024 -# define EMERGENCY_OBJ_COUNT 64 +# define EMERGENCY_OBJ_COUNT 4 +# define MAX_OBJ_COUNT 64 #endif -#ifndef __GTHREADS -# undef EMERGENCY_OBJ_COUNT -# define EMERGENCY_OBJ_COUNT 4 +// This can be set by configure. +#ifdef _GLIBCXX_EH_POOL_NOBJS +# if _GLIBCXX_EH_POOL_NOBJS > MAX_OBJ_COUNT +# warning "_GLIBCXX_EH_POOL_NOBJS value is too large; ignoring it" +# else +# undef EMERGENCY_OBJ_COUNT +# define EMERGENCY_OBJ_COUNT _GLIBCXX_EH_POOL_NOBJS +# endif #endif namespace __gnu_cxx { - void __freeres(); + void __freeres() noexcept; } namespace { + static constexpr std::size_t + buffer_size_in_bytes(std::size_t obj_count, std::size_t obj_size) noexcept + { + // N * (S * P + R + D) + constexpr std::size_t P = sizeof(void*); + constexpr std::size_t R = sizeof(__cxa_refcounted_exception); + constexpr std::size_t D = sizeof(__cxa_dependent_exception); + return obj_count * (obj_size * P + R + D); + } + // A fixed-size heap, variable size object allocator class pool { public: - pool(); + pool() noexcept; - _GLIBCXX_NODISCARD void *allocate (std::size_t); - void free (void *); + _GLIBCXX_NODISCARD void *allocate (std::size_t) noexcept; + void free (void *) noexcept; - bool in_pool (void *); + bool in_pool (void *) const noexcept; private: struct free_entry { @@ -101,33 +145,87 @@ namespace char data[] __attribute__((aligned)); }; +#ifdef __GTHREADS // A single mutex controlling emergency allocations. __gnu_cxx::__mutex emergency_mutex; + using __scoped_lock = __gnu_cxx::__scoped_lock; +#else + int emergency_mutex = 0; + struct __scoped_lock { explicit __scoped_lock(int) { } }; +#endif // The free-list - free_entry *first_free_entry; + free_entry *first_free_entry = nullptr; // The arena itself - we need to keep track of these only // to implement in_pool. - char *arena; - std::size_t arena_size; +#ifdef _GLIBCXX_EH_POOL_STATIC + static constexpr std::size_t arena_size + = buffer_size_in_bytes(EMERGENCY_OBJ_COUNT, EMERGENCY_OBJ_SIZE); + alignas(void*) char arena[std::max(arena_size, sizeof(free_entry))]; +#else + char *arena = nullptr; + std::size_t arena_size = 0; +#endif - friend void __gnu_cxx::__freeres(); + friend void __gnu_cxx::__freeres() noexcept; }; - pool::pool() + pool::pool() noexcept { - // Allocate the arena - we could add a GLIBCXX_EH_ARENA_SIZE environment - // to make this tunable. - arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT - + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception)); +#ifndef _GLIBCXX_EH_POOL_STATIC + int obj_size = EMERGENCY_OBJ_SIZE; + int obj_count = EMERGENCY_OBJ_COUNT; + +#if _GLIBCXX_HOSTED +#if _GLIBCXX_HAVE_SECURE_GETENV + const char* str = ::secure_getenv("GLIBCXX_TUNABLES"); +#else + const char* str = std::getenv("GLIBCXX_TUNABLES"); +#endif + const std::string_view ns_name = "glibcxx.eh_pool"; + std::pair tunables[]{ + {"obj_size", 0}, {"obj_count", obj_count} + }; + while (str) + { + if (*str == ':') + ++str; + + if (!ns_name.compare(0, ns_name.size(), str, ns_name.size()) + && str[ns_name.size()] == '.') + { + str += ns_name.size() + 1; + for (auto& t : tunables) + if (!t.first.compare(0, t.first.size(), str, t.first.size()) + && str[t.first.size()] == '=') + { + str += t.first.size() + 1; + char* end; + unsigned long val = strtoul(str, &end, 0); + if ((*end == ':' || *end == '\0') && val <= INT_MAX) + t.second = val; + str = end; + break; + } + } + str = strchr(str, ':'); + } + obj_count = std::min(tunables[1].second, MAX_OBJ_COUNT); // Can be zero. + if (tunables[0].second != 0) + obj_size = tunables[0].second; +#endif // HOSTED + + arena_size = buffer_size_in_bytes(obj_count, obj_size); + if (arena_size == 0) + return; arena = (char *)malloc (arena_size); if (!arena) { // If the allocation failed go without an emergency pool. arena_size = 0; - first_free_entry = NULL; return; } +#endif // STATIC // Populate the free-list with a single entry covering the whole arena first_free_entry = reinterpret_cast (arena); @@ -136,7 +234,7 @@ namespace first_free_entry->next = NULL; } - void *pool::allocate (std::size_t size) + void *pool::allocate (std::size_t size) noexcept { __gnu_cxx::__scoped_lock sentry(emergency_mutex); // We need an additional size_t member plus the padding to @@ -188,9 +286,9 @@ namespace return &x->data; } - void pool::free (void *data) + void pool::free (void *data) noexcept { - __gnu_cxx::__scoped_lock sentry(emergency_mutex); + __scoped_lock sentry(emergency_mutex); allocated_entry *e = reinterpret_cast (reinterpret_cast (data) - offsetof (allocated_entry, data)); std::size_t sz = e->size; @@ -252,11 +350,10 @@ namespace } } - bool pool::in_pool (void *ptr) + inline bool pool::in_pool (void *ptr) const noexcept { - char *p = reinterpret_cast (ptr); - return (p > arena - && p < arena + arena_size); + std::less less; + return less(ptr, arena + arena_size) && less(arena, ptr); } pool emergency_pool; @@ -264,24 +361,26 @@ namespace namespace __gnu_cxx { + __attribute__((cold)) void - __freeres() + __freeres() noexcept { +#ifndef _GLIBCXX_EH_POOL_STATIC if (emergency_pool.arena) { ::free(emergency_pool.arena); emergency_pool.arena = 0; } +#endif } } extern "C" void * -__cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW +__cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept { - void *ret; - thrown_size += sizeof (__cxa_refcounted_exception); - ret = malloc (thrown_size); + + void *ret = malloc (thrown_size); if (!ret) ret = emergency_pool.allocate (thrown_size); @@ -296,10 +395,10 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW extern "C" void -__cxxabiv1::__cxa_free_exception(void *vptr) _GLIBCXX_NOTHROW +__cxxabiv1::__cxa_free_exception(void *vptr) noexcept { char *ptr = (char *) vptr - sizeof (__cxa_refcounted_exception); - if (emergency_pool.in_pool (ptr)) + if (emergency_pool.in_pool (ptr)) [[__unlikely__]] emergency_pool.free (ptr); else free (ptr); @@ -307,31 +406,27 @@ __cxxabiv1::__cxa_free_exception(void *vptr) _GLIBCXX_NOTHROW extern "C" __cxa_dependent_exception* -__cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW +__cxxabiv1::__cxa_allocate_dependent_exception() noexcept { - __cxa_dependent_exception *ret; - - ret = static_cast<__cxa_dependent_exception*> - (malloc (sizeof (__cxa_dependent_exception))); + void *ret = malloc (sizeof (__cxa_dependent_exception)); if (!ret) - ret = static_cast <__cxa_dependent_exception*> - (emergency_pool.allocate (sizeof (__cxa_dependent_exception))); + ret = emergency_pool.allocate (sizeof (__cxa_dependent_exception)); if (!ret) std::terminate (); memset (ret, 0, sizeof (__cxa_dependent_exception)); - return ret; + return static_cast<__cxa_dependent_exception*>(ret); } extern "C" void __cxxabiv1::__cxa_free_dependent_exception - (__cxa_dependent_exception *vptr) _GLIBCXX_NOTHROW + (__cxa_dependent_exception *vptr) noexcept { - if (emergency_pool.in_pool (vptr)) + if (emergency_pool.in_pool (vptr)) [[__unlikely__]] emergency_pool.free (vptr); else free (vptr); diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in index 243f3db..af3d4c4 100644 --- a/libstdc++-v3/po/Makefile.in +++ b/libstdc++-v3/po/Makefile.in @@ -199,6 +199,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/python/Makefile.in b/libstdc++-v3/python/Makefile.in index 9da4b31..0c600de 100644 --- a/libstdc++-v3/python/Makefile.in +++ b/libstdc++-v3/python/Makefile.in @@ -229,6 +229,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index cef290c..c54c0f6 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -301,6 +301,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index 4db28bd..013ab3c 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -266,6 +266,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/c++17/Makefile.in b/libstdc++-v3/src/c++17/Makefile.in index b88917e..217cbbe 100644 --- a/libstdc++-v3/src/c++17/Makefile.in +++ b/libstdc++-v3/src/c++17/Makefile.in @@ -245,6 +245,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in index 197d75b..c04bb7d 100644 --- a/libstdc++-v3/src/c++20/Makefile.in +++ b/libstdc++-v3/src/c++20/Makefile.in @@ -240,6 +240,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in index 90eff5d..77ec8c7 100644 --- a/libstdc++-v3/src/c++98/Makefile.in +++ b/libstdc++-v3/src/c++98/Makefile.in @@ -261,6 +261,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/filesystem/Makefile.in b/libstdc++-v3/src/filesystem/Makefile.in index 8986b42..010bcfc 100644 --- a/libstdc++-v3/src/filesystem/Makefile.in +++ b/libstdc++-v3/src/filesystem/Makefile.in @@ -269,6 +269,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/src/libbacktrace/Makefile.in b/libstdc++-v3/src/libbacktrace/Makefile.in index 5c6b4dd..a52f645 100644 --- a/libstdc++-v3/src/libbacktrace/Makefile.in +++ b/libstdc++-v3/src/libbacktrace/Makefile.in @@ -302,6 +302,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 1708060..328a036 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -199,6 +199,7 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +EH_POOL_FLAGS = @EH_POOL_FLAGS@ ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@ EXEEXT = @EXEEXT@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ -- cgit v1.1 From 23c3cbaed36f6d2f3a7a64f6ebda69329723514b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 11 Oct 2022 20:19:08 +0100 Subject: libstdc++: Fix bootstrap for --disable-threads build [PR107221] The __scoped_lock type should be used unqualified so that we always refer to pool::__scoped_lock, which might be the dummy fallback implementation. The __mutex and __scoped_lock types in already work fine without __GTHREADS being defined, but that header isn't included at all unless _GLIBCXX_HOSTED != 0. The fallback implementation should be used for ! _GLIBCXX_HOSTED instead of for !defined __GTHREADS. libstdc++-v3/ChangeLog: PR bootstrap/107221 * libsupc++/eh_alloc.cc (pool): Change preprocessor condition for using __mutex from __GTHREADS to _GLIBCXX_HOSTED. (pool::allocate): Remove namespace qualification to use pool::__scoped_lock instead of __gnu_cxx::__scoped_lock. --- libstdc++-v3/libsupc++/eh_alloc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc index 50dc37c..81b8a15 100644 --- a/libstdc++-v3/libsupc++/eh_alloc.cc +++ b/libstdc++-v3/libsupc++/eh_alloc.cc @@ -145,7 +145,7 @@ namespace char data[] __attribute__((aligned)); }; -#ifdef __GTHREADS +#if _GLIBCXX_HOSTED // A single mutex controlling emergency allocations. __gnu_cxx::__mutex emergency_mutex; using __scoped_lock = __gnu_cxx::__scoped_lock; @@ -236,7 +236,7 @@ namespace void *pool::allocate (std::size_t size) noexcept { - __gnu_cxx::__scoped_lock sentry(emergency_mutex); + __scoped_lock sentry(emergency_mutex); // We need an additional size_t member plus the padding to // ensure proper alignment of data. size += offsetof (allocated_entry, data); -- cgit v1.1 From ab332cd78d083edb2fddaa3c02578cafade12725 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 12 Oct 2022 00:17:24 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 58b011b..def58a6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,57 @@ +2022-10-11 Jonathan Wakely + + PR bootstrap/107221 + * libsupc++/eh_alloc.cc (pool): Change preprocessor condition + for using __mutex from __GTHREADS to _GLIBCXX_HOSTED. + (pool::allocate): Remove namespace qualification to use + pool::__scoped_lock instead of __gnu_cxx::__scoped_lock. + +2022-10-11 Jonathan Wakely + + PR libstdc++/68606 + * Makefile.in: Regenerate. + * acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro. + * configure: Regenerate. + * configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC. + * crossconfig.m4: Check for secure_getenv. + * doc/Makefile.in: Regenerate. + * doc/xml/manual/configure.xml: Document new configure options. + * doc/xml/manual/evolution.xml: Document addition of tunables. + * doc/xml/manual/using_exceptions.xml: Document emergency + buffer and tunables. + * doc/html/*: Regenerate. + * include/Makefile.in: Regenerate. + * libsupc++/Makefile.am: Use EH_POOL_FLAGS. + * libsupc++/Makefile.in: Regenerate. + * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units + of sizeof(void*) not including the ABI's exception header. + (EMERGENCY_OBJ_COUNT): Define as target-independent calculation + based on word size. + (MAX_OBJ_COUNT): Define macro for upper limit on pool size. + (pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer. + (pool::buffer_size_in_bytes): New static member function. + (pool::pool): Parse GLIBCXX_TUNABLES environment variable to set + pool size at runtime. + (pool::in_pool): Use std::less for total order. + (__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing. + (__cxa_free_exception, __cxa_free_dependent_exception): Add + [[unlikely]] attributes. + * po/Makefile.in: Regenerate. + * python/Makefile.in: Regenerate. + * src/Makefile.in: Regenerate. + * src/c++11/Makefile.in: Regenerate. + * src/c++17/Makefile.in: Regenerate. + * src/c++20/Makefile.in: Regenerate. + * src/c++98/Makefile.in: Regenerate. + * src/filesystem/Makefile.in: Regenerate. + * src/libbacktrace/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + +2022-10-11 Olivier Hainque + Olivier Hainque + + * configure: Regenerate. + 2022-10-10 Jonathan Wakely * include/std/type_traits (make_signed, make_unsigned): Remove -- cgit v1.1 From 6d2294a83e1417720e1f8ddf5aa4dc1a35ef89d5 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 12 Oct 2022 09:31:32 +0200 Subject: regenerate configure files Needed after a recent change. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. liboffloadmic/ChangeLog: * configure: Regenerate. * plugin/configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate. --- libstdc++-v3/configure | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index b564175..6077e69 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -12236,7 +12236,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12215 "configure" +#line 12239 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12342,7 +12342,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12321 "configure" +#line 12345 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16062,7 +16062,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 16021 "configure" +#line 16065 "configure" int main() { typedef bool atomic_type; @@ -16097,7 +16097,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16056 "configure" +#line 16100 "configure" int main() { typedef short atomic_type; @@ -16132,7 +16132,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16091 "configure" +#line 16135 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -16168,7 +16168,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16127 "configure" +#line 16171 "configure" int main() { typedef long long atomic_type; @@ -16324,7 +16324,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16283 "configure" +#line 16327 "configure" int main() { _Decimal32 d1; @@ -16366,7 +16366,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16325 "configure" +#line 16369 "configure" template struct same { typedef T2 type; }; -- cgit v1.1 From bfcd9f84531fa99e9d00efd8bcfd3c8ac16fa360 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Wed, 12 Oct 2022 11:14:11 -0400 Subject: libstdc++: Implement ranges::repeat_view from P2474R2 libstdc++-v3/ChangeLog: * include/std/ranges (repeat_view): Define. (repeat_view::_Iterator): Define. (views::__detail::__can_repeat_view): Define. (views::__detail::__can_bounded_repeat_view): Define. (views::_Repeat, views::repeat): Define. * testsuite/std/ranges/repeat/1.cc: New test. --- libstdc++-v3/include/std/ranges | 210 ++++++++++++++++++++++++++ libstdc++-v3/testsuite/std/ranges/repeat/1.cc | 93 ++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 libstdc++-v3/testsuite/std/ranges/repeat/1.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 1f82112..5857d42 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -7356,6 +7356,216 @@ namespace views::__adaptor inline constexpr _JoinWith join_with; } // namespace views + + template + requires (is_object_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> + && (__detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t>)) + class repeat_view : public view_interface> + { + __detail::__box<_Tp> _M_value = _Tp(); + [[no_unique_address]] _Bound _M_bound = _Bound(); + + struct _Iterator; + + public: + repeat_view() requires default_initializable<_Tp> = default; + + constexpr explicit + repeat_view(const _Tp& __value, _Bound __bound = _Bound()) + : _M_value(__value), _M_bound(__bound) + { + if constexpr (!same_as<_Bound, unreachable_sentinel_t>) + __glibcxx_assert(__bound >= 0); + } + + constexpr explicit + repeat_view(_Tp&& __value, _Bound __bound = _Bound()) + : _M_value(std::move(__value)), _M_bound(__bound) + { } + + template + requires constructible_from<_Tp, _Args...> + && constructible_from<_Bound, _BoundArgs...> + constexpr explicit + repeat_view(piecewise_construct_t, + tuple<_Args...> __args, + tuple<_BoundArgs...> __bound_args = tuple<>{}) + : _M_value(std::make_from_tuple<_Tp>(std::move(__args))), + _M_bound(std::make_from_tuple<_Bound>(std::move(__bound_args))) + { } + + constexpr _Iterator + begin() const + { return _Iterator(std::__addressof(*_M_value)); } + + constexpr _Iterator + end() const requires (!same_as<_Bound, unreachable_sentinel_t>) + { return _Iterator(std::__addressof(*_M_value), _M_bound); } + + constexpr unreachable_sentinel_t + end() const noexcept + { return unreachable_sentinel; } + + constexpr auto + size() const requires (!same_as<_Bound, unreachable_sentinel_t>) + { return __detail::__to_unsigned_like(_M_bound); } + }; + + template + repeat_view(_Tp, _Bound) -> repeat_view<_Tp, _Bound>; + + template + requires __detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t> + class repeat_view<_Tp, _Bound>::_Iterator + { + using __index_type + = __conditional_t, ptrdiff_t, _Bound>; + + const _Tp* _M_value = nullptr; + __index_type _M_current = __index_type(); + + constexpr explicit + _Iterator(const _Tp* __value, __index_type __bound = __index_type()) + : _M_value(__value), _M_current(__bound) + { + if constexpr (!same_as<_Bound, unreachable_sentinel_t>) + __glibcxx_assert(__bound >= 0); + } + + friend repeat_view; + + public: + using iterator_concept = random_access_iterator_tag; + using iterator_category = random_access_iterator_tag; + using value_type = _Tp; + using difference_type = __conditional_t<__detail::__is_signed_integer_like<__index_type>, + __index_type, + __detail::__iota_diff_t<__index_type>>; + + _Iterator() = default; + + constexpr const _Tp& + operator*() const noexcept + { return *_M_value; } + + constexpr _Iterator& + operator++() + { + ++_M_current; + return *this; + } + + constexpr _Iterator + operator++(int) + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr _Iterator& + operator--() + { + if constexpr (!same_as<_Bound, unreachable_sentinel_t>) + __glibcxx_assert(_M_current > 0); + --_M_current; + return *this; + } + + constexpr _Iterator + operator--(int) + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr _Iterator& + operator+=(difference_type __n) + { + if constexpr (!same_as<_Bound, unreachable_sentinel_t>) + __glibcxx_assert(_M_current + __n >= 0); + _M_current += __n; + return *this; + } + + constexpr _Iterator& + operator-=(difference_type __n) + { + if constexpr (!same_as<_Bound, unreachable_sentinel_t>) + __glibcxx_assert(_M_current - __n >= 0); + _M_current -= __n; + return *this; + } + + constexpr const _Tp& + operator[](difference_type __n) const noexcept + { return *(*this + __n); } + + friend constexpr bool + operator==(const _Iterator& __x, const _Iterator& __y) + { return __x._M_current == __y._M_current; } + + friend constexpr auto + operator<=>(const _Iterator& __x, const _Iterator& __y) + { return __x._M_current <=> __y._M_current; } + + friend constexpr _Iterator + operator+(_Iterator __i, difference_type __n) + { + __i += __n; + return __i; + } + + friend constexpr _Iterator + operator+(difference_type __n, _Iterator __i) + { return __i + __n; } + + friend constexpr _Iterator + operator-(_Iterator __i, difference_type __n) + { + __i -= __n; + return __i; + } + + friend constexpr difference_type + operator-(const _Iterator& __x, const _Iterator& __y) + { + return (static_cast(__x._M_current) + - static_cast(__y._M_current)); + } + }; + + namespace views + { + namespace __detail + { + template + concept __can_repeat_view + = requires { repeat_view(std::declval<_Tp>()); }; + + template + concept __can_bounded_repeat_view + = requires { repeat_view(std::declval<_Tp>(), std::declval<_Bound>()); }; + } + + struct _Repeat + { + template + requires __detail::__can_repeat_view<_Tp> + constexpr auto + operator() [[nodiscard]] (_Tp&& __value) const + { return repeat_view(std::forward<_Tp>(__value)); } + + template + requires __detail::__can_bounded_repeat_view<_Tp, _Bound> + constexpr auto + operator() [[nodiscard]] (_Tp&& __value, _Bound __bound) const + { return repeat_view(std::forward<_Tp>(__value), __bound); } + }; + + inline constexpr _Repeat repeat; + } #endif // C++23 } // namespace ranges diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc new file mode 100644 index 0000000..3698ed1 --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++23 } } + +#include +#include +#include + +namespace ranges = std::ranges; +namespace views = std::views; + +constexpr bool +test01() +{ + auto v = views::repeat(42); + static_assert(ranges::random_access_range + && !ranges::sized_range); + auto i = ranges::begin(v); + auto s = ranges::end(v); + VERIFY( *i == 42 ); + VERIFY( i[0] == 42 ); + VERIFY( &i[0] == &i[1] ); + VERIFY( &*i == &*(i+1) ); + VERIFY( i != s ); + auto j = i + 5, k = i + 12; + VERIFY( k - i == 12 ); + VERIFY( k - j == 7 ); + VERIFY( i - j == -5 ); + VERIFY( k > j ); + VERIFY( j < k ); + VERIFY( i + 5 == j ); + VERIFY( i != j ); + VERIFY( i + 5 <= j ); + VERIFY( j - 5 >= i ); + + return true; +} + +constexpr bool +test02() +{ + constexpr int bound = 20; + auto v = views::repeat(42, bound); + static_assert(ranges::random_access_range + && ranges::sized_range); + VERIFY( ranges::equal(v, views::repeat(42) | views::take(bound)) ); + auto i = ranges::begin(v); + auto s = ranges::end(v); + VERIFY( *i == 42 ); + VERIFY( i[0] == 42 ); + VERIFY( &i[0] == &i[1] ); + VERIFY( &*i == &*(i+1) ); + VERIFY( i != s ); + auto j = i + 5, k = i + 12; + VERIFY( k - i == 12 ); + VERIFY( k - j == 7 ); + VERIFY( i - j == -5 ); + VERIFY( k > j ); + VERIFY( j < k ); + VERIFY( i + 5 == j ); + VERIFY( i != j ); + VERIFY( i + 5 <= j ); + VERIFY( j - 5 >= i ); + + VERIFY( ranges::size(v) == bound ); + VERIFY( s - i == bound ); + VERIFY( s - j == bound - (j - i) ); + VERIFY( i + bound == s ); + VERIFY( bound + i == s ); + + return true; +} + +constexpr bool +test03() +{ + struct A { int n, m; }; + auto v = ranges::repeat_view(std::piecewise_construct, + std::tuple{1, 2}, + std::tuple{3}); + VERIFY( v[0].n == 1 ); + VERIFY( v[0].m == 2 ); + VERIFY( ranges::size(v) == 3 ); + + return true; +} + +int +main() +{ + static_assert(test01()); + static_assert(test02()); + static_assert(test03()); +} -- cgit v1.1 From f77281b25ca6bb34ba271fa826e1e79a15df95fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dumont?= Date: Wed, 10 Aug 2022 19:35:41 +0200 Subject: libstdc++: Add __gnu_debug::basic_string<>::compare overloads Rather than adding those implementations we are adding a: using _Base::compare; so that any compare method not implemented at __gnu_debug::basic_string level are injected from the base class. Also review how __gnu_debug::basic_string is tested. Now require to define _GLIBCXX_TEST_DEBUG_STRING when running 'make check-debug'. libstdc++-v3/ChangeLog * include/debug/string: Add using _Base::compare. (__gnu_debug::basic_string<>::compare(const basic_string<>&)): Remove. (__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&)): Remove. (__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&, size_type, size_type)): Remove. * testsuite/util/testsuite_string.h [_GLIBCXX_TEST_DEBUG_STRING]: Include . * testsuite/21_strings/basic_string/operations/compare/char/1.cc: Include testsuite_string.h and use __gnu_test::string. * testsuite/21_strings/basic_string/operations/compare/char/13650.cc: Likewise. * testsuite/21_strings/basic_string/operations/compare/char/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/rfind/char/1.cc: Likewise. * testsuite/21_strings/basic_string/operations/rfind/char/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/rfind/char/3.cc: Likewise. * testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc: Include testsuite_string.h and use __gnu_test::wstring. * testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc: Likewise. * testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc: Likewise. --- libstdc++-v3/include/debug/string | 19 +++++-------------- .../basic_string/operations/compare/char/1.cc | 4 ++-- .../basic_string/operations/compare/char/13650.cc | 4 ++-- .../basic_string/operations/compare/char/2.cc | 6 +++--- .../basic_string/operations/compare/wchar_t/1.cc | 4 ++-- .../basic_string/operations/compare/wchar_t/13650.cc | 4 ++-- .../basic_string/operations/compare/wchar_t/2.cc | 6 +++--- .../basic_string/operations/rfind/char/1.cc | 18 +++++++++--------- .../basic_string/operations/rfind/char/2.cc | 10 +++++----- .../basic_string/operations/rfind/char/3.cc | 14 +++++++------- libstdc++-v3/testsuite/util/testsuite_string.h | 2 +- 11 files changed, 41 insertions(+), 50 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index c16751c..574a78e 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -1023,22 +1023,11 @@ namespace __gnu_debug substr(size_type __pos = 0, size_type __n = _Base::npos) const { return basic_string(_Base::substr(__pos, __n)); } - int - compare(const basic_string& __str) const - { return _Base::compare(__str); } - - int - compare(size_type __pos1, size_type __n1, - const basic_string& __str) const - { return _Base::compare(__pos1, __n1, __str); } - - int - compare(size_type __pos1, size_type __n1, const basic_string& __str, - size_type __pos2, size_type __n2) const - { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); } + using _Base::compare; + _GLIBCXX20_CONSTEXPR int - compare(const _CharT* __s) const + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT { __glibcxx_check_string(__s); return _Base::compare(__s); @@ -1046,6 +1035,7 @@ namespace __gnu_debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 5. string::compare specification questionable + _GLIBCXX20_CONSTEXPR int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { @@ -1055,6 +1045,7 @@ namespace __gnu_debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 5. string::compare specification questionable + _GLIBCXX20_CONSTEXPR int compare(size_type __pos1, size_type __n1,const _CharT* __s, size_type __n2) const diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc index 0bef0d2..c04b83c 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc @@ -29,7 +29,7 @@ // NB compare should be thought of as a lexographical compare, ie how // things would be sorted in a dictionary. -#include +#include #include #include @@ -67,7 +67,7 @@ test_value(int result, want_value expected) int test01() { - using namespace std; + using namespace __gnu_test; string str_0("costa rica"); string str_1("costa marbella"); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/13650.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/13650.cc index 96fd2f1..ce95623 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/13650.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/13650.cc @@ -19,13 +19,13 @@ // 21.3.6.8 basic_string::compare [lib.string::compare] -#include +#include #include // libstdc++/13650 void test01() { - using namespace std; + using namespace __gnu_test; const char lit_01[] = { 'w', 'e', '\0', 'r', 'd' }; const char lit_02[] = { 'w', 'e', 'i', '\0', 'd' }; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/2.cc index 17e8752..fca1543 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/2.cc @@ -19,14 +19,14 @@ // [string::compare] -#include +#include #include void test03() { std::string_view str1("foobar"); - std::string str2("foobar"); + __gnu_test::string str2("foobar"); auto x = str2.compare(str1); VERIFY (x == 0); @@ -52,7 +52,7 @@ test03() void test04() { - const std::string str("a"); + const __gnu_test::string str("a"); char c = 'a'; int res = str.compare(0, 1, &c, 1); VERIFY ( !res ); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc index 97a873a..aa5c168 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc @@ -29,7 +29,7 @@ // NB compare should be thought of as a lexographical compare, ie how // things would be sorted in a dictionary. -#include +#include #include enum want_value {lt=0, z=1, gt=2}; @@ -67,7 +67,7 @@ test_value(int result, want_value expected) int test01() { - using namespace std; + using namespace __gnu_test; wstring str_0(L"costa rica"); wstring str_1(L"costa marbella"); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc index 1825c6b..f3dd4eb 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc @@ -19,13 +19,13 @@ // 21.3.6.8 basic_string::compare [lib.string::compare] -#include +#include #include // libstdc++/13650 void test01() { - using namespace std; + using namespace __gnu_test; const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' }; const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' }; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc index dd703c1..c6d219a 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc @@ -19,14 +19,14 @@ // [string::compare] -#include +#include #include void test03() { std::wstring_view str1(L"foobar"); - std::wstring str2(L"foobar"); + __gnu_test::wstring str2(L"foobar"); auto x = str2.compare(str1); VERIFY (x == 0); @@ -52,7 +52,7 @@ test03() void test04() { - const std::wstring str(L"a"); + const __gnu_test::wstring str(L"a"); wchar_t c = L'a'; int res = str.compare(0, 1, &c, 1); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc index 73843b0..76fcb07 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc @@ -17,23 +17,23 @@ // with this library; see the file COPYING3. If not see // . -#include +#include #include // 21.3.6.2 basic_string rfind void test01(void) { - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - csize_type npos = std::string::npos; + typedef __gnu_test::string::size_type csize_type; + typedef __gnu_test::string::const_reference cref; + typedef __gnu_test::string::reference ref; + csize_type npos = __gnu_test::string::npos; csize_type csz01, csz02; const char str_lit01[] = "mave"; - const std::string str01("mavericks, santa cruz"); - std::string str02(str_lit01); - std::string str03("s, s"); - std::string str04; + const __gnu_test::string str01("mavericks, santa cruz"); + __gnu_test::string str02(str_lit01); + __gnu_test::string str03("s, s"); + __gnu_test::string str04; // size_type rfind(const string&, size_type pos = 0) const; csz01 = str01.rfind(str01); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc index 5879655..9fecfcf 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc @@ -17,14 +17,14 @@ // with this library; see the file COPYING3. If not see // . -#include +#include #include // 21.3.6.4 basic_string::find_last_of void test02() { - std::string z("ab"); - std::string::size_type pos; + __gnu_test::string z("ab"); + __gnu_test::string::size_type pos; pos = z.find_last_of("ab"); VERIFY( pos == 1 ); pos = z.find_last_of("Xa"); @@ -32,13 +32,13 @@ void test02() pos = z.find_last_of("Xb"); VERIFY( pos == 1 ); pos = z.find_last_of("XYZ"); - VERIFY( pos == std::string::npos ); + VERIFY( pos == __gnu_test::string::npos ); pos = z.find_last_of('a'); VERIFY( pos == 0 ); pos = z.find_last_of('b'); VERIFY( pos == 1 ); pos = z.find_last_of('X'); - VERIFY( pos == std::string::npos ); + VERIFY( pos == __gnu_test::string::npos ); } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc index 1ff9c94..69471e6 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc @@ -17,23 +17,23 @@ // with this library; see the file COPYING3. If not see // . -#include +#include #include // 21.3.6.6 basic_string::find_last_not_of void test03() { - typedef std::string::size_type csize_type; - std::string::size_type pos; - csize_type npos = std::string::npos; + typedef __gnu_test::string::size_type csize_type; + __gnu_test::string::size_type pos; + csize_type npos = __gnu_test::string::npos; - std::string x; + __gnu_test::string x; pos = x.find_last_not_of('X'); VERIFY( pos == npos ); pos = x.find_last_not_of("XYZ"); VERIFY( pos == npos ); - std::string y("a"); + __gnu_test::string y("a"); pos = y.find_last_not_of('X'); VERIFY( pos == 0 ); pos = y.find_last_not_of('a'); @@ -43,7 +43,7 @@ void test03() pos = y.find_last_not_of("a"); VERIFY( pos == npos ); - std::string z("ab"); + __gnu_test::string z("ab"); pos = z.find_last_not_of('X'); VERIFY( pos == 1 ); pos = z.find_last_not_of("XYZ"); diff --git a/libstdc++-v3/testsuite/util/testsuite_string.h b/libstdc++-v3/testsuite/util/testsuite_string.h index 7121ff8..7e61d98 100644 --- a/libstdc++-v3/testsuite/util/testsuite_string.h +++ b/libstdc++-v3/testsuite/util/testsuite_string.h @@ -1,7 +1,7 @@ #ifndef _GLIBCXX_TESTSUITE_STRING_H #define _GLIBCXX_TESTSUITE_STRING_H -#ifdef _GLIBCXX_DEBUG +#if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_TEST_DEBUG_STRING) # include namespace __gnu_test { -- cgit v1.1 From 781f477a13ae14ca661018518f4d4a9e6881b0dd Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 13 Oct 2022 00:17:37 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index def58a6..a78e198 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,38 @@ +2022-10-12 François Dumont + + * include/debug/string: Add using _Base::compare. + (__gnu_debug::basic_string<>::compare(const basic_string<>&)): Remove. + (__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&)): + Remove. + (__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&, + size_type, size_type)): Remove. + * testsuite/util/testsuite_string.h [_GLIBCXX_TEST_DEBUG_STRING]: Include . + * testsuite/21_strings/basic_string/operations/compare/char/1.cc: Include testsuite_string.h + and use __gnu_test::string. + * testsuite/21_strings/basic_string/operations/compare/char/13650.cc: Likewise. + * testsuite/21_strings/basic_string/operations/compare/char/2.cc: Likewise. + * testsuite/21_strings/basic_string/operations/rfind/char/1.cc: Likewise. + * testsuite/21_strings/basic_string/operations/rfind/char/2.cc: Likewise. + * testsuite/21_strings/basic_string/operations/rfind/char/3.cc: Likewise. + * testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc: + Include testsuite_string.h + and use __gnu_test::wstring. + * testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc: Likewise. + * testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc: Likewise. + +2022-10-12 Patrick Palka + + * include/std/ranges (repeat_view): Define. + (repeat_view::_Iterator): Define. + (views::__detail::__can_repeat_view): Define. + (views::__detail::__can_bounded_repeat_view): Define. + (views::_Repeat, views::repeat): Define. + * testsuite/std/ranges/repeat/1.cc: New test. + +2022-10-12 Martin Liska + + * configure: Regenerate. + 2022-10-11 Jonathan Wakely PR bootstrap/107221 -- cgit v1.1