aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-10-21 12:48:02 +0200
committerMartin Liska <mliska@suse.cz>2022-10-21 12:48:02 +0200
commit5776a5ffab3b92d6ccac87ccf32c580ee2742d5a (patch)
treecbdbbff551198c5e4bba8d08d734ad74a1d0d684 /libstdc++-v3
parent4465e2a047c3b175bf6c4ca500547eb6b12df52f (diff)
parentbf3b532b524ecacb3202ab2c8af419ffaaab7cff (diff)
downloadgcc-5776a5ffab3b92d6ccac87ccf32c580ee2742d5a.zip
gcc-5776a5ffab3b92d6ccac87ccf32c580ee2742d5a.tar.gz
gcc-5776a5ffab3b92d6ccac87ccf32c580ee2742d5a.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog56
-rw-r--r--libstdc++-v3/acinclude.m45
-rwxr-xr-xlibstdc++-v3/configure18
-rw-r--r--libstdc++-v3/include/bits/mofunc_impl.h5
-rw-r--r--libstdc++-v3/include/std/charconv59
-rw-r--r--libstdc++-v3/include/std/ranges58
-rw-r--r--libstdc++-v3/libsupc++/atexit_thread.cc20
-rw-r--r--libstdc++-v3/libsupc++/guard.cc31
-rw-r--r--libstdc++-v3/src/c++11/thread.cc9
-rw-r--r--libstdc++-v3/testsuite/20_util/move_only_function/call.cc11
-rw-r--r--libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc20
-rw-r--r--libstdc++-v3/testsuite/std/ranges/repeat/1.cc33
12 files changed, 281 insertions, 44 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 09988f6..1bfdcf6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,59 @@
+2022-10-20 Patrick Palka <ppalka@redhat.com>
+
+ * include/std/charconv (__detail::__from_chars_alnum_to_val_table):
+ Redefine as a class template containing the members type, value and
+ _S_make_table. Don't use a local class as the table type.
+ (__detail::__table): Remove.
+ (__detail::__from_chars_alnum_to_val): Adjust after the above.
+
+2022-10-19 Patrick Palka <ppalka@redhat.com>
+
+ * include/std/ranges (views::__detail::__is_repeat_view): Define
+ and later define a partial specialization.
+ (views::__detail::__take_of_repeat_view): Declare and later define.
+ (views::__detail::__drop_of_repeat_view): Likewise.
+ (views::_Take::operator()): Return a repeat_view if the argument
+ is a repeat_view as per P2474R2.
+ (views::_Drop::operator()): Likewise.
+ (repeat_view): Befriend __take/drop_of_repeat_view.
+ * testsuite/std/ranges/repeat/1.cc (test04): New test.
+
+2022-10-19 Patrick Palka <ppalka@redhat.com>
+
+ PR libstdc++/107313
+ * include/std/ranges (stride_view::_Iterator::operator-): Fix typo.
+ * testsuite/std/ranges/adaptors/stride/1.cc (test03): New test.
+
+2022-10-19 LIU Hao <lh_mouse@126.com>
+
+ * src/c++11/thread.cc (get_nprocs): Add new implementation
+ for native Windows targets
+
+2022-10-19 LIU Hao <lh_mouse@126.com>
+
+ * libsupc++/atexit_thread.cc (__cxa_thread_atexit): Use
+ implementation from mcfgthread if available
+ * libsupc++/guard.cc (__cxa_guard_acquire, __cxa_guard_release,
+ __cxa_guard_abort): Use implementations from mcfgthread if
+ available
+ * configure: Regenerate
+
+2022-10-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/106652
+ * include/std/limits: Fix a typo, 202202L -> 202002L.
+ (numeric_limits::<_Float16>::radix, numeric_limits::<_Float32>::radix,
+ numeric_limits::<_Float64>::radix, numeric_limits::<_Float128>::radix,
+ numeric_limits::<__gnu_cxx::__bfloat16_t>::radix): Use __FLT_RADIX__
+ macro instead of type specific macros.
+ * include/c_global/cmath (nextafter(_Float16, _Float16)): New
+ overload.
+ (nextafter(__gnu_cxx::__bfloat16_t, __gnu_cxx::__bfloat16_t)):
+ Likewise.
+ * testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
+ (test_functions): Uncomment nextafter test. Fix up sph_neumann call.
+ * testsuite/26_numerics/headers/cmath/nextafter_c++23.cc: New test.
+
2022-10-18 Patrick Palka <ppalka@redhat.com>
* include/std/ranges (stride_view): Define.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 6523ba9..6f67292 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2982,7 +2982,10 @@ AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
enable_hosted_libstdcxx=no
;;
*)
- enable_hosted_libstdcxx=yes
+ case "${with_newlib}-${with_headers}" in
+ no-no) enable_hosted_libstdcxx=no ;;
+ *) enable_hosted_libstdcxx=yes ;;
+ esac
;;
esac])
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6077e69..9159ffb 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -15698,7 +15698,10 @@ else
enable_hosted_libstdcxx=no
;;
*)
- enable_hosted_libstdcxx=yes
+ case "${with_newlib}-${with_headers}" in
+ no-no) enable_hosted_libstdcxx=no ;;
+ *) enable_hosted_libstdcxx=yes ;;
+ esac
;;
esac
fi
@@ -15855,6 +15858,7 @@ case $target_thread_file in
tpf) thread_header=config/s390/gthr-tpf.h ;;
vxworks) thread_header=config/gthr-vxworks.h ;;
win32) thread_header=config/i386/gthr-win32.h ;;
+ mcf) thread_header=config/i386/gthr-mcf.h ;;
esac
@@ -16062,7 +16066,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 16065 "configure"
+#line 16069 "configure"
int main()
{
typedef bool atomic_type;
@@ -16097,7 +16101,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16100 "configure"
+#line 16104 "configure"
int main()
{
typedef short atomic_type;
@@ -16132,7 +16136,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16135 "configure"
+#line 16139 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
@@ -16168,7 +16172,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16171 "configure"
+#line 16175 "configure"
int main()
{
typedef long long atomic_type;
@@ -16324,7 +16328,7 @@ $as_echo "mutex" >&6; }
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16327 "configure"
+#line 16331 "configure"
int main()
{
_Decimal32 d1;
@@ -16366,7 +16370,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16369 "configure"
+#line 16373 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
diff --git a/libstdc++-v3/include/bits/mofunc_impl.h b/libstdc++-v3/include/bits/mofunc_impl.h
index 405c405..47e1e50 100644
--- a/libstdc++-v3/include/bits/mofunc_impl.h
+++ b/libstdc++-v3/include/bits/mofunc_impl.h
@@ -205,10 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
template<typename _Tp>
- using __param_t
- = __conditional_t<is_trivially_copyable_v<_Tp>
- && sizeof(_Tp) <= sizeof(long),
- _Tp, _Tp&&>;
+ using __param_t = __conditional_t<is_scalar_v<_Tp>, _Tp, _Tp&&>;
using _Invoker = _Res (*)(_Mofunc_base _GLIBCXX_MOF_CV*,
__param_t<_ArgTypes>...) noexcept(_Noex);
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index 7aefdd3..a65fbed 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -413,30 +413,36 @@ namespace __detail
return true;
}
- // Construct and return a lookup table that maps 0-9, A-Z and a-z to their
- // corresponding base-36 value and maps all other characters to 127.
- constexpr auto
- __from_chars_alnum_to_val_table()
- {
- constexpr unsigned char __lower_letters[27] = "abcdefghijklmnopqrstuvwxyz";
- constexpr unsigned char __upper_letters[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- struct { unsigned char __data[1u << __CHAR_BIT__] = {}; } __table;
- for (auto& __entry : __table.__data)
- __entry = 127;
- for (int __i = 0; __i < 10; ++__i)
- __table.__data['0' + __i] = __i;
- for (int __i = 0; __i < 26; ++__i)
+ template<bool _DecOnly>
+ struct __from_chars_alnum_to_val_table
+ {
+ struct type { unsigned char __data[1u << __CHAR_BIT__] = {}; };
+
+ // Construct and return a lookup table that maps 0-9, A-Z and a-z to their
+ // corresponding base-36 value and maps all other characters to 127.
+ static constexpr type
+ _S_make_table()
{
- __table.__data[__lower_letters[__i]] = 10 + __i;
- __table.__data[__upper_letters[__i]] = 10 + __i;
+ constexpr unsigned char __lower_letters[27] = "abcdefghijklmnopqrstuvwxyz";
+ constexpr unsigned char __upper_letters[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ type __table;
+ for (auto& __entry : __table.__data)
+ __entry = 127;
+ for (int __i = 0; __i < 10; ++__i)
+ __table.__data['0' + __i] = __i;
+ for (int __i = 0; __i < 26; ++__i)
+ {
+ __table.__data[__lower_letters[__i]] = 10 + __i;
+ __table.__data[__upper_letters[__i]] = 10 + __i;
+ }
+ return __table;
}
- return __table;
- }
-#if __cpp_lib_constexpr_charconv
- template<bool _DecOnly>
- inline constexpr auto __table = __from_chars_alnum_to_val_table();
-#endif
+ // This initializer is made superficially dependent in order
+ // to prevent the compiler from wastefully constructing the
+ // table ahead of time when it's not needed.
+ static constexpr type value = (_DecOnly, _S_make_table());
+ };
// If _DecOnly is true: if the character is a decimal digit, then
// return its corresponding base-10 value, otherwise return a value >= 127.
@@ -449,16 +455,7 @@ namespace __detail
if _GLIBCXX17_CONSTEXPR (_DecOnly)
return static_cast<unsigned char>(__c - '0');
else
- {
-#if __cpp_lib_constexpr_charconv
- if (std::__is_constant_evaluated())
- return __table<_DecOnly>.__data[__c];
-#endif
- // This initializer is deliberately made dependent in order to work
- // around modules bug PR105322.
- static constexpr auto __table = (_DecOnly, __from_chars_alnum_to_val_table());
- return __table.__data[__c];
- }
+ return __from_chars_alnum_to_val_table<_DecOnly>::value.__data[__c];
}
/// std::from_chars implementation for integers in a power-of-two base.
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index d113cf1..a55e9e7 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2257,6 +2257,13 @@ namespace views::__adaptor
template<typename _Winc, typename _Bound>
inline constexpr bool __is_iota_view<iota_view<_Winc, _Bound>> = true;
+ template<typename _Range>
+ inline constexpr bool __is_repeat_view = false;
+
+ template<typename _Range>
+ constexpr auto
+ __take_of_repeat_view(_Range&&, range_difference_t<_Range>); // defined later
+
template<typename _Range, typename _Dp>
concept __can_take_view
= requires { take_view(std::declval<_Range>(), std::declval<_Dp>()); };
@@ -2291,6 +2298,8 @@ namespace views::__adaptor
else
return iota_view(*__begin, *__end);
}
+ else if constexpr (__detail::__is_repeat_view<_Tp>)
+ return __detail::__take_of_repeat_view(std::forward<_Range>(__r), __n);
else
return take_view(std::forward<_Range>(__r), __n);
}
@@ -2527,6 +2536,10 @@ namespace views::__adaptor
{
namespace __detail
{
+ template<typename _Range>
+ constexpr auto
+ __drop_of_repeat_view(_Range&&, range_difference_t<_Range>); // defined later
+
template<typename _Range, typename _Dp>
concept __can_drop_view
= requires { drop_view(std::declval<_Range>(), std::declval<_Dp>()); };
@@ -2568,6 +2581,8 @@ namespace views::__adaptor
else
return _Tp(__begin, __end);
}
+ else if constexpr (__detail::__is_repeat_view<_Tp>)
+ return __detail::__drop_of_repeat_view(std::forward<_Range>(__r), __n);
else
return drop_view(std::forward<_Range>(__r), __n);
}
@@ -7367,6 +7382,14 @@ namespace views::__adaptor
struct _Iterator;
+ template<typename _Range>
+ friend constexpr auto
+ views::__detail::__take_of_repeat_view(_Range&&, range_difference_t<_Range>);
+
+ template<typename _Range>
+ friend constexpr auto
+ views::__detail::__drop_of_repeat_view(_Range&&, range_difference_t<_Range>);
+
public:
repeat_view() requires default_initializable<_Tp> = default;
@@ -7540,6 +7563,9 @@ namespace views::__adaptor
{
namespace __detail
{
+ template<typename _Tp, typename _Bound>
+ inline constexpr bool __is_repeat_view<repeat_view<_Tp, _Bound>> = true;
+
template<typename _Tp>
concept __can_repeat_view
= requires { repeat_view(std::declval<_Tp>()); };
@@ -7565,6 +7591,36 @@ namespace views::__adaptor
};
inline constexpr _Repeat repeat;
+
+ namespace __detail
+ {
+ template<typename _Range>
+ constexpr auto
+ __take_of_repeat_view(_Range&& __r, range_difference_t<_Range> __n)
+ {
+ using _Tp = remove_cvref_t<_Range>;
+ static_assert(__is_repeat_view<_Tp>);
+ if constexpr (sized_range<_Tp>)
+ return views::repeat(*__r._M_value, std::min(ranges::distance(__r), __n));
+ else
+ return views::repeat(*__r._M_value, __n);
+ }
+
+ template<typename _Range>
+ constexpr auto
+ __drop_of_repeat_view(_Range&& __r, range_difference_t<_Range> __n)
+ {
+ using _Tp = remove_cvref_t<_Range>;
+ static_assert(__is_repeat_view<_Tp>);
+ if constexpr (sized_range<_Tp>)
+ {
+ auto __sz = ranges::distance(__r);
+ return views::repeat(*__r._M_value, __sz - std::min(__sz, __n));
+ }
+ else
+ return __r;
+ }
+ }
}
template<input_range _Vp>
@@ -7874,7 +7930,7 @@ namespace views::__adaptor
friend constexpr difference_type
operator-(default_sentinel_t __y, const _Iterator& __x)
requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>>
- { return __detail::__div_ceil(__x._M_end, __x._M_current, __x._M_stride); }
+ { return __detail::__div_ceil(__x._M_end - __x._M_current, __x._M_stride); }
friend constexpr difference_type
operator-(const _Iterator& __x, default_sentinel_t __y)
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index a2693d0..2f936ab 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -25,6 +25,24 @@
#include <cstdlib>
#include <new>
#include "bits/gthr.h"
+
+#ifdef __USING_MCFGTHREAD__
+
+#include <mcfgthread/cxa.h>
+
+namespace __cxxabiv1 {
+
+extern "C" int
+__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
+ void *obj, void *dso_handle) _GLIBCXX_NOTHROW
+{
+ return __MCF_cxa_thread_atexit (dtor, obj, dso_handle);
+}
+
+} // namespace __cxxabiv1
+
+#else // __USING_MCFGTHREAD__
+
#ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -173,3 +191,5 @@ __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
}
#endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+
+#endif // __USING_MCFGTHREAD__
diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
index abb5711..0f81a22 100644
--- a/libstdc++-v3/libsupc++/guard.cc
+++ b/libstdc++-v3/libsupc++/guard.cc
@@ -28,6 +28,35 @@
#include <cxxabi.h>
#include <exception>
#include <new>
+
+#ifdef __USING_MCFGTHREAD__
+
+#include <mcfgthread/cxa.h>
+
+namespace __cxxabiv1 {
+
+extern "C" int
+__cxa_guard_acquire (__guard* g) _GLIBCXX_NOTHROW
+ {
+ return __MCF_cxa_guard_acquire(g);
+ }
+
+extern "C" void
+__cxa_guard_release (__guard* g) _GLIBCXX_NOTHROW
+ {
+ __MCF_cxa_guard_release(g);
+ }
+
+extern "C" void
+__cxa_guard_abort (__guard* g) _GLIBCXX_NOTHROW
+ {
+ __MCF_cxa_guard_abort(g);
+ }
+
+} // namespace __cxxabiv1
+
+#else // __USING_MCFGTHREAD__
+
#include <ext/atomicity.h>
#include <ext/concurrence.h>
#include <bits/atomic_lockfree_defines.h>
@@ -458,3 +487,5 @@ namespace __cxxabiv1
#endif
}
}
+
+#endif // __USING_MCFGTHREAD__
diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index 707a4ad..a54bc3e 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -68,6 +68,15 @@ static inline int get_nprocs()
#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)
# include <unistd.h>
# define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
+#elif defined(_WIN32)
+# include <windows.h>
+static inline int get_nprocs()
+{
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo(&sysinfo);
+ return (int) sysinfo.dwNumberOfProcessors;
+}
+# define _GLIBCXX_NPROCS get_nprocs()
#else
# define _GLIBCXX_NPROCS 0
#endif
diff --git a/libstdc++-v3/testsuite/20_util/move_only_function/call.cc b/libstdc++-v3/testsuite/20_util/move_only_function/call.cc
index 68aa205..3e15983 100644
--- a/libstdc++-v3/testsuite/20_util/move_only_function/call.cc
+++ b/libstdc++-v3/testsuite/20_util/move_only_function/call.cc
@@ -191,10 +191,21 @@ test04()
VERIFY( std::move(std::as_const(f5))() == 3 );
}
+struct Incomplete;
+
+void
+test_params()
+{
+ std::move_only_function<void(Incomplete)> f1;
+ std::move_only_function<void(Incomplete&)> f2;
+ std::move_only_function<void(Incomplete&&)> f3;
+}
+
int main()
{
test01();
test02();
test03();
test04();
+ test_params();
}
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
index 745d1a6..37ae896 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
@@ -64,10 +64,30 @@ test02()
VERIFY( ranges::equal(v, (int[]){1, 4, 7}) );
}
+void
+test03()
+{
+ // PR libstdc++/107313
+ int x[] = {1, 2, 3, 4, 5};
+ __gnu_test::test_input_range<int> rx(x);
+ auto r = views::counted(rx.begin(), 4) | views::stride(2);
+ auto i = r.begin();
+ std::default_sentinel_t s = r.end();
+ VERIFY( s != i );
+ VERIFY( s - i == 2 && i - s == -2 );
+ ++i;
+ VERIFY( s != i );
+ VERIFY( s - i == 1 && i - s == -1 );
+ ++i;
+ VERIFY( s == i );
+ VERIFY( s - i == 0 && i - s == 0 );
+}
+
int
main()
{
static_assert(test01());
test02<__gnu_test::test_input_range<int>>();
test02<__gnu_test::test_forward_range<int>>();
+ test03();
}
diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
index 3698ed1..f9817c9 100644
--- a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
@@ -84,10 +84,43 @@ test03()
return true;
}
+constexpr bool
+test04()
+{
+ // Verify P2474R2 changes to views::take/drop.
+ auto r = views::repeat(42);
+
+ auto rt = r | views::take(10);
+ static_assert(views::__detail::__is_repeat_view<decltype(rt)>);
+ VERIFY( ranges::equal(rt, views::repeat(42, 10)) );
+
+ auto rd = r | views::drop(10);
+ static_assert(std::same_as<decltype(rd), decltype(r)>);
+
+ auto br = views::repeat(42, 37);
+
+ auto brt = br | views::take(10);
+ static_assert(std::same_as<decltype(brt), decltype(br)>);
+ VERIFY( ranges::equal(brt, views::repeat(42, 10)) );
+
+ auto brt100 = br | views::take(100);
+ VERIFY( ranges::equal(brt100, br) );
+
+ auto brd = br | views::drop(10);
+ static_assert(std::same_as<decltype(brd), decltype(br)>);
+ VERIFY( ranges::equal(brd, views::repeat(42, 27)) );
+
+ auto brd100 = br | views::drop(100);
+ VERIFY( ranges::empty(brd100) );
+
+ return true;
+}
+
int
main()
{
static_assert(test01());
static_assert(test02());
static_assert(test03());
+ static_assert(test04());
}