[gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] defer to check_vect_support* [PR115454]

2024-06-26 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:c658106424868e6512d9042693e3296efc68916d

commit c658106424868e6512d9042693e3296efc68916d
Author: Alexandre Oliva 
Date:   Wed Jun 26 05:54:44 2024 -0300

[libstdc++] [testsuite] defer to check_vect_support* [PR115454]

The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

PR libstdc++/115454
* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
to check_vect_support_and_set_flags's default dg-do action.

Diff:
---
 libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc 
b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
index 25a713b4e94..4ade8601f27 100644
--- a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
@@ -1,5 +1,4 @@
 // { dg-options "-std=gnu++17" }
-// { dg-do run { target *-*-* } }
 // { dg-require-effective-target c++17 }
 // { dg-additional-options "-march=x86-64-v4" { target avx512f_runtime } }
 // { dg-require-cmath "" }


[gcc r15-1692] [libstdc++] [testsuite] defer to check_vect_support* [PR115454]

2024-06-27 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:95faa1bea7bdc7f92fcccb3543bfcbc8184c5e5b

commit r15-1692-g95faa1bea7bdc7f92fcccb3543bfcbc8184c5e5b
Author: Alexandre Oliva 
Date:   Thu Jun 27 07:22:48 2024 -0300

[libstdc++] [testsuite] defer to check_vect_support* [PR115454]

The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

PR libstdc++/115454
* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
to check_vect_support_and_set_flags's default dg-do action.

Diff:
---
 libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc 
b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
index 25a713b4e94..4ade8601f27 100644
--- a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
@@ -1,5 +1,4 @@
 // { dg-options "-std=gnu++17" }
-// { dg-do run { target *-*-* } }
 // { dg-require-effective-target c++17 }
 // { dg-additional-options "-march=x86-64-v4" { target avx512f_runtime } }
 // { dg-require-cmath "" }


[gcc r14-10352] [libstdc++] [testsuite] defer to check_vect_support* [PR115454]

2024-06-27 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:b70af0bd2e33e9cc20dae45c131429a402fc8845

commit r14-10352-gb70af0bd2e33e9cc20dae45c131429a402fc8845
Author: Alexandre Oliva 
Date:   Thu Jun 27 08:14:34 2024 -0300

[libstdc++] [testsuite] defer to check_vect_support* [PR115454]

The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

PR libstdc++/115454
* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
to check_vect_support_and_set_flags's default dg-do action.

(cherry picked from commit 95faa1bea7bdc7f92fcccb3543bfcbc8184c5e5b)

Diff:
---
 libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc 
b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
index 25a713b4e94..4ade8601f27 100644
--- a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
@@ -1,5 +1,4 @@
 // { dg-options "-std=gnu++17" }
-// { dg-do run { target *-*-* } }
 // { dg-require-effective-target c++17 }
 // { dg-additional-options "-march=x86-64-v4" { target avx512f_runtime } }
 // { dg-require-cmath "" }


[gcc r13-8872] [libstdc++] [testsuite] defer to check_vect_support* [PR115454]

2024-06-27 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:3de1c4985bebd1882b6643789daba24f2d11bafe

commit r13-8872-g3de1c4985bebd1882b6643789daba24f2d11bafe
Author: Alexandre Oliva 
Date:   Thu Jun 27 08:32:15 2024 -0300

[libstdc++] [testsuite] defer to check_vect_support* [PR115454]

The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

PR libstdc++/115454
* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
to check_vect_support_and_set_flags's default dg-do action.

(cherry picked from commit 95faa1bea7bdc7f92fcccb3543bfcbc8184c5e5b)

Diff:
---
 libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc 
b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
index 25a713b4e94..4ade8601f27 100644
--- a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
@@ -1,5 +1,4 @@
 // { dg-options "-std=gnu++17" }
-// { dg-do run { target *-*-* } }
 // { dg-require-effective-target c++17 }
 // { dg-additional-options "-march=x86-64-v4" { target avx512f_runtime } }
 // { dg-require-cmath "" }


[gcc r14-10016] [libstdc++] [testsuite] xfail double-prec from_chars for float128_t

2024-04-18 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:5b178179e85ace01a97def40531e915c180aaeca

commit r14-10016-g5b178179e85ace01a97def40531e915c180aaeca
Author: Alexandre Oliva 
Date:   Thu Apr 18 08:00:56 2024 -0300

[libstdc++] [testsuite] xfail double-prec from_chars for float128_t

Tests 20_util/from_chars/4.cc and 20_util/to_chars/long_double.cc were
adjusted about a year ago to skip long double on some targets, because
the fastfloat library was limited to 64-bit doubles.

The same problem comes up in similar float128_t tests on
aarch64-vxworks.  This patch adjusts them similarly.

Unlike the earlier tests, that got similar treatment for
x86_64-vxworks, these haven't failed there.


for  libstdc++-v3/ChangeLog

* testsuite/20_util/from_chars/8.cc: Skip float128_t testing
on aarch64-vxworks.
* testsuite/20_util/to_chars/float128_c++23.cc: Xfail run on
aarch64-vxworks.

Diff:
---
 libstdc++-v3/testsuite/20_util/from_chars/8.cc| 3 ++-
 libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/20_util/from_chars/8.cc 
b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
index ee60d88c332..a6343422c5a 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/8.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
@@ -17,6 +17,7 @@
 
 // { dg-do run { target c++23 } }
 // { dg-add-options ieee }
+// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* } }
 
 #include 
 #include 
@@ -343,7 +344,7 @@ test06()
 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
   test_max_mantissa();
 #endif
-#if defined(__GLIBCXX_TYPE_INT_N_0) \
+#if defined(__GLIBCXX_TYPE_INT_N_0) && !defined SKIP_LONG_DOUBLE \
 && defined(__STDCPP_FLOAT128_T__) && 
defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
   test_max_mantissa();
 #endif
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc 
b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
index 547632817b4..ca00761ee7c 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
@@ -19,6 +19,7 @@
 // { dg-require-effective-target ieee_floats }
 // { dg-require-effective-target size32plus }
 // { dg-add-options ieee }
+// { dg-xfail-run-if "from_chars limited to double-precision" { 
aarch64-*-vxworks* } }
 
 #include 
 #include 


[gcc r14-10017] [libstdc++] [testsuite] disable SRA for compare_exchange_padding

2024-04-18 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:dcf0bd14cda706be8d0c18963812beefca51df39

commit r14-10017-gdcf0bd14cda706be8d0c18963812beefca51df39
Author: Alexandre Oliva 
Date:   Thu Apr 18 08:00:59 2024 -0300

[libstdc++] [testsuite] disable SRA for compare_exchange_padding

On arm-vx7r2, the uses of as.load() as initializer get SRAed, so the
padding bits in the tests are not what we might expect from full-word
struct copies.

I tried adding a function to perform bitwise copying, but even taking
the as.load() argument by const&, we'd still construct a temporary
with SRAed field-wise copying.  Unable to find another way to ensure
we wouldn't get a temporary, I went for disabling SRA.


for  libstdc++-v3/ChangeLog

* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
Disable SRA.

Diff:
---
 libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
index 2f18d426e7f..a6081968ca8 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
@@ -1,6 +1,7 @@
 // { dg-do run { target c++20 } }
 // { dg-require-atomic-cmpxchg-word "" }
 // { dg-add-options libatomic }
+// { dg-additional-options "-fno-tree-sra" }
 
 #include 
 #include 
@@ -26,10 +27,10 @@ main ()
   s.s = 42;
 
   std::atomic as{ s };
-  auto ts = as.load();
+  auto ts = as.load(); // SRA might prevent copying of padding bits here.
   VERIFY( !compare_struct(s, ts) ); // padding cleared on construction
   as.exchange(s);
-  auto es = as.load();
+  auto es = as.load(); // SRA might prevent copying of padding bits here.
   VERIFY( compare_struct(ts, es) ); // padding cleared on exchange
 
   S n;


[gcc(refs/users/aoliva/heads/testme)] [libstdc++-v3] [rtems] enable filesystem support

2024-05-28 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:0276651ab74a1200d8c1defeee3b2a4f53712fe7

commit 0276651ab74a1200d8c1defeee3b2a4f53712fe7
Author: Alexandre Oliva 
Date:   Wed May 29 02:52:25 2024 -0300

[libstdc++-v3] [rtems] enable filesystem support

mkdir, chdir and chmod functions are defined in librtemscpu, that
doesn't get linked in during libstdc++-v3 configure, but applications
use -qrtems for linking, which brings those symbols in, so it makes
sense to mark them as available so that the C++ filesystem APIs are
enabled.


for  libstdc++-v3/ChangeLog

* configure.ac [*-*-rtems*]: Set chdir, chmod and mkdir as
available.
* configure: Rebuilt.

Diff:
---
 libstdc++-v3/configure| 7 +++
 libstdc++-v3/configure.ac | 7 +++
 2 files changed, 14 insertions(+)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 5179cc507f1..a7d1c015906 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28610,6 +28610,13 @@ _ACEOF
 
 $as_echo "#define HAVE_USLEEP 1" >>confdefs.h
 
+
+   # These functions are defined in librtempscpu.  We don't use
+   # -qrtems during configure, so we don't link that in, and fail
+   # to find them.
+   glibcxx_cv_chdir=yes
+   glibcxx_cv_chmod=yes
+   glibcxx_cv_mkdir=yes
 ;;
 esac
   elif test "x$with_headers" != "xno"; then
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 37396bd6ebb..0725c81bc9f 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -400,6 +400,13 @@ dnl # rather than hardcoding that information.
 AC_DEFINE(HAVE_SYMLINK)
 AC_DEFINE(HAVE_TRUNCATE)
 AC_DEFINE(HAVE_USLEEP)
+
+   # These functions are defined in librtempscpu.  We don't use
+   # -qrtems during configure, so we don't link that in, and fail
+   # to find them.
+   glibcxx_cv_chdir=yes
+   glibcxx_cv_chmod=yes
+   glibcxx_cv_mkdir=yes
 ;;
 esac
   elif test "x$with_headers" != "xno"; then


[gcc r15-921] [libstdc++-v3] [rtems] enable filesystem support

2024-05-30 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:5955c18dfb970740d55d432aeee5cb5a6f51cf65

commit r15-921-g5955c18dfb970740d55d432aeee5cb5a6f51cf65
Author: Alexandre Oliva 
Date:   Thu May 30 04:01:15 2024 -0300

[libstdc++-v3] [rtems] enable filesystem support

mkdir, chdir and chmod functions are defined in librtemscpu, that
doesn't get linked in during libstdc++-v3 configure, but applications
use -qrtems for linking, which brings those symbols in, so it makes
sense to mark them as available so that the C++ filesystem APIs are
enabled.


for  libstdc++-v3/ChangeLog

* configure.ac [*-*-rtems*]: Set chdir, chmod and mkdir as
available.
* configure: Rebuilt.

Diff:
---
 libstdc++-v3/configure| 7 +++
 libstdc++-v3/configure.ac | 7 +++
 2 files changed, 14 insertions(+)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 5179cc507f1..5645e991af7 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28610,6 +28610,13 @@ _ACEOF
 
 $as_echo "#define HAVE_USLEEP 1" >>confdefs.h
 
+
+# These functions are defined in librtemscpu.  We don't use
+# -qrtems during configure, so we don't link that in, and fail
+# to find them.
+glibcxx_cv_chdir=yes
+glibcxx_cv_chmod=yes
+glibcxx_cv_mkdir=yes
 ;;
 esac
   elif test "x$with_headers" != "xno"; then
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 37396bd6ebb..ccb24a82be7 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -400,6 +400,13 @@ dnl # rather than hardcoding that information.
 AC_DEFINE(HAVE_SYMLINK)
 AC_DEFINE(HAVE_TRUNCATE)
 AC_DEFINE(HAVE_USLEEP)
+
+# These functions are defined in librtemscpu.  We don't use
+# -qrtems during configure, so we don't link that in, and fail
+# to find them.
+glibcxx_cv_chdir=yes
+glibcxx_cv_chmod=yes
+glibcxx_cv_mkdir=yes
 ;;
 esac
   elif test "x$with_headers" != "xno"; then


[gcc r15-1049] [libstdc++] add _GLIBCXX_CLANG to workaround predefined __clang__

2024-06-05 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:67be156f952241ad99af1eedc4da91bc2e201cd3

commit r15-1049-g67be156f952241ad99af1eedc4da91bc2e201cd3
Author: Alexandre Oliva 
Date:   Wed Jun 5 22:43:54 2024 -0300

[libstdc++] add _GLIBCXX_CLANG to workaround predefined __clang__

A proprietary embedded operating system that uses clang as its primary
compiler ships headers that require __clang__ to be defined.  Defining
that macro causes libstdc++ to adopt workarounds that work for clang
but that break for GCC.

So, introduce a _GLIBCXX_CLANG macro, and a convention to test for it
rather than for __clang__, so that a GCC variant that adds -D__clang__
to satisfy system headers can also -D_GLIBCXX_CLANG=0 to avoid
workarounds that are not meant for GCC.

I've left fast_float and ryu files alone, their tests for __clang__
don't seem to be harmful for GCC, they don't include bits/c++config,
and patching such third-party files would just make trouble for
updating them without visible benefit.  pstl_config.h, though also
imported, required adjustment.


for  libstdc++-v3/ChangeLog

* include/bits/c++config (_GLIBCXX_CLANG): Define or undefine.
* include/bits/locale_facets_nonio.tcc: Test for it.
* include/bits/stl_bvector.h: Likewise.
* include/c_compatibility/stdatomic.h: Likewise.
* include/experimental/bits/simd.h: Likewise.
* include/experimental/bits/simd_builtin.h: Likewise.
* include/experimental/bits/simd_detail.h: Likewise.
* include/experimental/bits/simd_x86.h: Likewise.
* include/experimental/simd: Likewise.
* include/std/complex: Likewise.
* include/std/ranges: Likewise.
* include/std/variant: Likewise.
* include/pstl/pstl_config.h: Likewise.

Diff:
---
 libstdc++-v3/include/bits/c++config   | 13 -
 libstdc++-v3/include/bits/locale_facets_nonio.tcc |  2 +-
 libstdc++-v3/include/bits/stl_bvector.h   |  2 +-
 libstdc++-v3/include/c_compatibility/stdatomic.h  |  2 +-
 libstdc++-v3/include/experimental/bits/simd.h | 10 +-
 libstdc++-v3/include/experimental/bits/simd_builtin.h |  4 ++--
 libstdc++-v3/include/experimental/bits/simd_detail.h  |  8 
 libstdc++-v3/include/experimental/bits/simd_x86.h | 12 ++--
 libstdc++-v3/include/experimental/simd|  2 +-
 libstdc++-v3/include/pstl/pstl_config.h   |  4 ++--
 libstdc++-v3/include/std/complex  |  4 ++--
 libstdc++-v3/include/std/ranges   |  8 
 libstdc++-v3/include/std/variant  |  2 +-
 13 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/libstdc++-v3/include/bits/c++config 
b/libstdc++-v3/include/bits/c++config
index b57e3f338e9..6dca2d9467a 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -481,9 +481,20 @@ _GLIBCXX_END_NAMESPACE_VERSION
 // Define if compatibility should be provided for -mlong-double-64.
 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
 
+// Use an alternate macro to test for clang, so as to provide an easy
+// workaround for systems (such as vxworks) whose headers require
+// __clang__ to be defined, even when compiling with GCC.
+#if !defined _GLIBCXX_CLANG && defined __clang__
+# define _GLIBCXX_CLANG __clang__
+// Turn -D_GLIBCXX_CLANG=0 into -U_GLIBCXX_CLANG, so that
+// _GLIBCXX_CLANG can be tested as defined, just like __clang__.
+#elif !_GLIBCXX_CLANG
+# undef _GLIBCXX_CLANG
+#endif
+
 // Define if compatibility should be provided for alternative 128-bit long
 // double formats. Not possible for Clang until __ibm128 is supported.
-#ifndef __clang__
+#ifndef _GLIBCXX_CLANG
 #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
 #endif
 
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc 
b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 8f67be5a614..72136f42f08 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -1465,7 +1465,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
   ctype<_CharT> const& __ctype = use_facet >(__loc);
   __err = ios_base::goodbit;
   bool __use_state = false;
-#if __GNUC__ >= 5 && !defined(__clang__)
+#if __GNUC__ >= 5 && !defined(_GLIBCXX_CLANG)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wpmf-conversions"
   // Nasty hack.  The C++ standard mandates that get invokes the do_get
diff --git a/libstdc++-v3/include/bits/stl_bvector.h 
b/libstdc++-v3/include/bits/stl_bvector.h
index d567e26f4e4..52153cadf8f 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -185,7 +185,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 void
 _M_assume_normalized() const
 {
-#if __has_attribute(__assume__) && !defined(__clang__)
+#if __has_attrib

[gcc(refs/users/aoliva/heads/testme)] [libstdc++] drop workaround for clang<=7

2024-06-06 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:c3e23e85d8a348cfaecf1a8885ad02318ade0ad6

commit c3e23e85d8a348cfaecf1a8885ad02318ade0ad6
Author: Alexandre Oliva 
Date:   Fri Jun 7 00:27:15 2024 -0300

[libstdc++] drop workaround for clang<=7

In response to a request in the review of the patch that introduced
_GLIBCXX_CLANG, this patch removes from std/variant an obsolete
workaround for clang 7-.


for  libstdc++-v3/ChangeLog

* include/std/variant: Drop obsolete workaround.

Diff:
---
 libstdc++-v3/include/std/variant | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 51aaa620851..13ea1dd3849 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1758,11 +1758,6 @@ namespace __detail::__variant
  }, __rhs);
   }
 
-#if defined(_GLIBCXX_CLANG) && __clang_major__ <= 7
-public:
-  using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852
-#endif
-
 private:
   template
friend constexpr decltype(auto)


[gcc r15-1098] [libstdc++] drop workaround for clang<=7

2024-06-07 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:b6a9deb1e2ae01ee906e78e06e3a1b073d20e023

commit r15-1098-gb6a9deb1e2ae01ee906e78e06e3a1b073d20e023
Author: Alexandre Oliva 
Date:   Fri Jun 7 07:00:11 2024 -0300

[libstdc++] drop workaround for clang<=7

In response to a request in the review of the patch that introduced
_GLIBCXX_CLANG, this patch removes from std/variant an obsolete
workaround for clang 7-.


for  libstdc++-v3/ChangeLog

* include/std/variant: Drop obsolete workaround.

Diff:
---
 libstdc++-v3/include/std/variant | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 51aaa620851..13ea1dd3849 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1758,11 +1758,6 @@ namespace __detail::__variant
  }, __rhs);
   }
 
-#if defined(_GLIBCXX_CLANG) && __clang_major__ <= 7
-public:
-  using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852
-#endif
-
 private:
   template
friend constexpr decltype(auto)


[gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] xfail double-prec from_chars for float128_t

2024-06-11 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:1c784e7ac556b71f5771c6112b319dad2bcb8c4c

commit 1c784e7ac556b71f5771c6112b319dad2bcb8c4c
Author: Alexandre Oliva 
Date:   Sat Jun 8 09:42:55 2024 -0300

[libstdc++] [testsuite] xfail double-prec from_chars for float128_t

Tests involving float128_t were xfailed or otherwise worked around for
vxworks on aarch64.  The same issue came up on rtems.  This patch
adjusts them similarly.


for  libstdc++-v3/ChangeLog

* testsuite/20_util/from_chars/8.cc: Skip float128_t testing
on aarch64-rtems*.
* testsuite/20_util/to_chars/float128_c++23.cc: Xfail run on
aarch64-rtems*.

Diff:
---
 libstdc++-v3/testsuite/20_util/from_chars/8.cc| 2 +-
 libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/20_util/from_chars/8.cc 
b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
index a6343422c5a9..bacad89943b5 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/8.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
@@ -17,7 +17,7 @@
 
 // { dg-do run { target c++23 } }
 // { dg-add-options ieee }
-// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* } }
+// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* 
aarch64-*-rtems* } }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc 
b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
index ca00761ee7c9..6cb9cadcd204 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
@@ -19,7 +19,7 @@
 // { dg-require-effective-target ieee_floats }
 // { dg-require-effective-target size32plus }
 // { dg-add-options ieee }
-// { dg-xfail-run-if "from_chars limited to double-precision" { 
aarch64-*-vxworks* } }
+// { dg-xfail-run-if "from_chars limited to double-precision" { 
aarch64-*-vxworks* aarch64-*-rtems* } }
 
 #include 
 #include 


[gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] require cmath for c++23 cmath tests

2024-06-11 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:bed26758b722c27f22be833546b0ef9a9793dfe2

commit bed26758b722c27f22be833546b0ef9a9793dfe2
Author: Alexandre Oliva 
Date:   Tue Jun 11 20:25:33 2024 -0300

[libstdc++] [testsuite] require cmath for c++23 cmath tests

Some c++23 tests fail on targets that don't satisfy dg-require-cmath,
because referenced math functions don't get declared in std.  Add the
missing requirement.


for  libstdc++-v3/ChangeLog

* testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc:
Require cmath.
* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc:
Likewise.
* testsuite/26_numerics/headers/cmath/nextafter_std_c++23.cc:
Likewise.

Diff:
---
 libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc | 1 +
 libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc | 1 +
 libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc | 1 +
 3 files changed, 3 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
index 0e3d112fe2e8..3c2377fd6987 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do link { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
index 000cebf364aa..ea68ac5da755 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do link { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
index 7d7e10bd8aea..91767d22cc3f 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 


[gcc r15-1225] [libstdc++] [testsuite] xfail double-prec from_chars for float128_t

2024-06-12 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:6c3b01db8274f0392a3f4dccbd9ac71d0c53c04f

commit r15-1225-g6c3b01db8274f0392a3f4dccbd9ac71d0c53c04f
Author: Alexandre Oliva 
Date:   Wed Jun 12 19:48:04 2024 -0300

[libstdc++] [testsuite] xfail double-prec from_chars for float128_t

Tests involving float128_t were xfailed or otherwise worked around for
vxworks on aarch64.  The same issue came up on rtems.  This patch
adjusts them similarly.


for  libstdc++-v3/ChangeLog

* testsuite/20_util/from_chars/8.cc: Skip float128_t testing
on aarch64-rtems*.
* testsuite/20_util/to_chars/float128_c++23.cc: Xfail run on
aarch64-rtems*.

Diff:
---
 libstdc++-v3/testsuite/20_util/from_chars/8.cc| 2 +-
 libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/20_util/from_chars/8.cc 
b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
index a6343422c5a9..bacad89943b5 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/8.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/8.cc
@@ -17,7 +17,7 @@
 
 // { dg-do run { target c++23 } }
 // { dg-add-options ieee }
-// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* } }
+// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* 
aarch64-*-rtems* } }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc 
b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
index ca00761ee7c9..6cb9cadcd204 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc
@@ -19,7 +19,7 @@
 // { dg-require-effective-target ieee_floats }
 // { dg-require-effective-target size32plus }
 // { dg-add-options ieee }
-// { dg-xfail-run-if "from_chars limited to double-precision" { 
aarch64-*-vxworks* } }
+// { dg-xfail-run-if "from_chars limited to double-precision" { 
aarch64-*-vxworks* aarch64-*-rtems* } }
 
 #include 
 #include 


[gcc r15-1226] [libstdc++] [testsuite] require cmath for c++23 cmath tests

2024-06-12 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:5288935d30c4615cce664ca8fba65eecf05c326f

commit r15-1226-g5288935d30c4615cce664ca8fba65eecf05c326f
Author: Alexandre Oliva 
Date:   Wed Jun 12 19:48:06 2024 -0300

[libstdc++] [testsuite] require cmath for c++23 cmath tests

Some c++23 tests fail on targets that don't satisfy dg-require-cmath,
because referenced math functions don't get declared in std.  Add the
missing requirement.


for  libstdc++-v3/ChangeLog

* testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc:
Require cmath.
* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc:
Likewise.
* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc:
Likewise.

Diff:
---
 libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc | 1 +
 libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc | 1 +
 libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc | 1 +
 3 files changed, 3 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
index 0e3d112fe2e8..3c2377fd6987 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do link { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
index 000cebf364aa..ea68ac5da755 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do link { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
index 7d7e10bd8aea..91767d22cc3f 100644
--- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++23 } }
+// { dg-require-cmath "" }
 
 #include 
 #include 


[gcc r15-1301] [libstdc++] [testsuite] require cmath for [PR114359]

2024-06-13 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:9b8c3e622c7cd4ea393f59b873c3107767e1ba88

commit r15-1301-g9b8c3e622c7cd4ea393f59b873c3107767e1ba88
Author: Alexandre Oliva 
Date:   Thu Jun 13 20:10:55 2024 -0300

[libstdc++] [testsuite] require cmath for [PR114359]

When !_GLIBCXX_USE_C99_MATH_TR1, binomial_distribution doesn't use the
optimized algorithm that was fixed in response to PR114359.  Without
that optimized algorithm, operator() ends up looping very very long
for the test, to the point that it would time out by several orders of
magnitude, without even exercising the optimized algorithm that we're
testing for regressions.  Arrange for the test to be skipped if that
bit won't be exercised.


for  libstdc++-v3/ChangeLog

PR libstdc++/114359
* testsuite/26_numerics/random/binomial_distribution/114359.cc:
Require cmath.

Diff:
---
 .../26_numerics/random/binomial_distribution/114359.cc  | 13 +
 1 file changed, 13 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc 
b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc
index c1e4c380bf91..12d967dcbfd3 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc
@@ -2,6 +2,19 @@
 
 // Bug 114359 - std::binomial_distribution hangs in infinite loop
 
+// { dg-require-cmath "" }
+
+// The requirement above is not strictly true.  The test should work
+// without cmath, and it probably does, but without cmath,
+// binomial_distribution::operator() skips the optimized algorithm and
+// calls _M_waiting to loop a gazillion times.  On aarch64-rtems6
+// qemu, that loop takes over 5 minutes to go through a small fraction
+// of the iteration space (__x at 22k, limited at 1G; __sum at 2e-5,
+// limited at 0.69).  The bug we're regression-testing here was in the
+// cmath-requiring bit, so even if this could conceivably not time out
+// on a really fast machine, there's hardly any reason to exercise
+// this extreme case.
+
 #include 
 
 int main()


[gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] no libatomic for vxworks

2024-06-24 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:441c81173683b53bbc5cba645d860a5f8065fe77

commit 441c81173683b53bbc5cba645d860a5f8065fe77
Author: Alexandre Oliva 
Date:   Mon Jun 24 14:34:27 2024 -0300

[libstdc++] [testsuite] no libatomic for vxworks

libatomic hasn't been ported to vxworks.  Most of the stdatomic.h and
 underlying requirements are provided by builtins and libgcc,
and the vxworks libc already provides remaining __atomic symbols, so
porting libatomic doesn't seem to make sense.

However, some of the target arch-only tests in
add_options_for_libatomic cover vxworks targets, so we end up
attempting to link libatomic in, even though it's not there.
Preempt those too-broad tests.


Co-Authored-By: Marc Poulhiès 

for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp (add_options_for_libatomic):
None for *-*-vxworks*.

Diff:
---
 libstdc++-v3/testsuite/lib/dg-options.exp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp 
b/libstdc++-v3/testsuite/lib/dg-options.exp
index 84f9e3ebc73..0d77fb029b0 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -338,6 +338,11 @@ proc atomic_link_flags { paths } {
 }
 
 proc add_options_for_libatomic { flags } {
+# We don't (need to) build libatomic for vxworks.  Don't try to
+# link it in, even on arches that support libatomic.
+if { [istarget *-*-vxworks*] } {
+   return $flags
+}
 if { [istarget hppa*-*-hpux*]
 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
 || [istarget riscv*-*-*]


[gcc(refs/users/aoliva/heads/testme)] [libstdc++] [testsuite] avoid async.cc loss of precision [PR91486]

2024-07-29 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:9d90ad447ba1872c8606e1b33b4545ceb40ee0d0

commit 9d90ad447ba1872c8606e1b33b4545ceb40ee0d0
Author: Alexandre Oliva 
Date:   Mon Jul 29 19:48:52 2024 -0300

[libstdc++] [testsuite] avoid async.cc loss of precision [PR91486]

When we get to test_pr91486_wait_until(), we're about 10s past the
float_steady_clock epoch.  This is enough for the 1s delta for the
timeout to come out slightly lower when the futex-less wait_until
converts the deadline from float_steady_clock to __clock_t.  So we may
wake up a little too early, and end up looping one extra time to sleep
for e.g. another 954ns until we hit the deadline.

Each iteration calls float_steady_clock::now(), bumping the call_count
that we VERIFY() at the end of the subtest.  Since we expect at most 3
calls, and we're going to have at the very least 3 on futex-less
targets (one in the test proper, one before wait_until_impl to compute
the deadline, and one after wait_until_impl to check whether the
deadline was hit), any such imprecision that causes an extra iteration
will reach 5 and cause the test to fail.

Initializing the epoch in the beginning of the test makes such
spurious fails due to loss of precision far less likely.  I don't
suppose allowing for an extra couple of calls would be desirable.

While at that, I'm annotating unused status variables as such.


for  libstdc++-v3/ChangeLog

PR libstdc++/91486
* testsuite/30_threads/async/async.cc
(test_pr91486_wait_for): Mark status as unused.
(test_pr91486_wait_until): Likewise.  Initialize epoch later.

Diff:
---
 libstdc++-v3/testsuite/30_threads/async/async.cc | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/testsuite/30_threads/async/async.cc 
b/libstdc++-v3/testsuite/30_threads/async/async.cc
index 3b157ed9c568..2474d318d7b1 100644
--- a/libstdc++-v3/testsuite/30_threads/async/async.cc
+++ b/libstdc++-v3/testsuite/30_threads/async/async.cc
@@ -173,7 +173,7 @@ void test_pr91486_wait_for()
 
   std::chrono::duration const wait_time = std::chrono::seconds(1);
   auto const start_steady = chrono::steady_clock::now();
-  auto status = f1.wait_for(wait_time);
+  auto status __attribute__ ((__unused__)) = f1.wait_for(wait_time);
   auto const elapsed_steady = chrono::steady_clock::now() - start_steady;
 
   VERIFY( elapsed_steady >= std::chrono::seconds(1) );
@@ -209,7 +209,7 @@ struct float_steady_clock
   }
 };
 
-chrono::steady_clock::time_point float_steady_clock::epoch = 
chrono::steady_clock::now();
+chrono::steady_clock::time_point float_steady_clock::epoch;
 int float_steady_clock::call_count = 0;
 
 void test_pr91486_wait_until()
@@ -218,6 +218,19 @@ void test_pr91486_wait_until()
   std::this_thread::sleep_for(std::chrono::seconds(1));
 });
 
+  // When we don't _GLIBCXX_HAVE_LINUX_FUTEX, we use
+  // condition_variables, whose wait_until converts times using
+  // deltas, and if too much time has elapsed since we set the epoch
+  // during program initialization, say if the other tests took over
+  // 8s and we're unlucky with the numbers, we may lose enough
+  // precision from the 1s delta that we don't sleep until the
+  // deadline, and then we may loop more times than expected.  Each
+  // iteration will recompute the wait time from deadline -
+  // float_steady_clock::now(), and each such computation will bump
+  // float_steady_clock::call_count, so the call_count check below
+  // will fail spuriously.  Setting the epoch just before running this
+  // test makes this failure mode far less likely.
+  float_steady_clock::epoch = chrono::steady_clock::now();
   float_steady_clock::time_point const now = float_steady_clock::now();
 
   std::chrono::duration const wait_time = std::chrono::seconds(1);
@@ -225,7 +238,7 @@ void test_pr91486_wait_until()
   VERIFY( expire > now );
 
   auto const start_steady = chrono::steady_clock::now();
-  auto status = f1.wait_until(expire);
+  auto status __attribute__ ((__unused__)) = f1.wait_until(expire);
   auto const elapsed_steady = chrono::steady_clock::now() - start_steady;
 
   // This checks that we didn't come back too soon


[gcc(refs/users/aoliva/heads/testme)] [libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

2024-08-30 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:73bc0445c988397251bc6b7e36df58d91ee7c869

commit 73bc0445c988397251bc6b7e36df58d91ee7c869
Author: Alexandre Oliva 
Date:   Fri Aug 30 09:06:40 2024 -0300

[libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

30_threads/future/members/poll.cc has calibration code that, on
systems with very low clock resolution, may spuriously fail to run.
Even when it does run, low resolution and reasonable
timeouts limit severely the viability of increasing the loop counts so
as to reduce measurement noise, so we end up with very noisy results.

On various vxworks targets, high iteration count (low-noise)
measurements confirmed that some of the operations that we expected to
be up to 100x slower than the fastest ones can run a little slower
than that and, with significant noise, may seem to be even slower,
comparatively.

Bump the factors up to 200x, so that we have plenty of margin over
measured results.


for  libstdc++-v3/ChangeLog

* testsuite/30_threads/future/members/poll.cc: Factor out
calibration, and run it unconditionally.  Lower its
strictness.  Bump wait_until_*'s slowness factor.

Diff:
---
 .../testsuite/30_threads/future/members/poll.cc| 111 +
 1 file changed, 70 insertions(+), 41 deletions(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc 
b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 2bdbe7a48ce5..2d10ef718215 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -41,52 +41,75 @@ print(const char* desc, Duration dur)
   return d;
 }
 
+static void
+calibrate()
+{
+  /* After set_value, wait_for is faster, so use that for the
+ calibration loops to avoid zero at low clock resultions.  */
+  promise p = {};
+  future f = p.get_future();
+  p.set_value(1);
+
+  auto start = chrono::high_resolution_clock::now();
+  auto stop = start;
+  /* Loop until the clock advances, so that start is right after a
+ time increment.  */
+  do
+stop = chrono::high_resolution_clock::now();
+  while (start == stop);
+
+  /* This approximates the smallest time increment we may expect to be
+ able to measure.  It doesn't have to be very precise, just a
+ ballpart of the right magnitude.  */
+  auto tick = stop - start;
+
+  int i = 0;
+  start = stop;
+  /* Now until the clock advances again, so that stop is right
+ after another time increment.  */
+  do
+{
+  f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+  i++;
+}
+  while (start == stop);
+
+  /* Aim for some 10 ticks.  This won't be quite right if now() takes
+ up a significant portion of the loop time, but we'll measure
+ without that and adjust in the loop below.  */
+  if (iterations < i * 10)
+iterations = i * 10;
+
+  /* We aim for some 10 ticks for the loop that's expected to be fastest,
+ but even if we don't get quite that many, we're still fine.  */
+  iteration /= 2;
+  do
+{
+  iterations *= 2;
+  start = chrono::high_resolution_clock::now();
+  for(int i = 0; i < iterations; i++)
+   f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+}
+  while (stop - start < 5 * tick);
+}
+
 int main()
 {
+  /* First, calibrate the iteration count so that we don't get any of
+ the actual measurement loops to complete in less than the clock
+ granularity.  */
+  calibrate ();
+
   promise p;
   future f = p.get_future();
 
- start_over:
   auto start = chrono::high_resolution_clock::now();
   for(int i = 0; i < iterations; i++)
 f.wait_for(chrono::seconds(0));
   auto stop = chrono::high_resolution_clock::now();
 
-  /* We've run too few iterations for the clock resolution.
- Attempt to calibrate it.  */
-  if (start == stop)
-{
-  /* After set_value, wait_for is faster, so use that for the
-calibration to avoid zero at low clock resultions.  */
-  promise pc;
-  future fc = pc.get_future();
-  pc.set_value(1);
-
-  /* Loop until the clock advances, so that start is right after a
-time increment.  */
-  do
-   start = chrono::high_resolution_clock::now();
-  while (start == stop);
-  int i = 0;
-  /* Now until the clock advances again, so that stop is right
-after another time increment.  */
-  do
-   {
- fc.wait_for(chrono::seconds(0));
- stop = chrono::high_resolution_clock::now();
- i++;
-   }
-  while (start == stop);
-  /* Go for some 10 cycles, but if we're already past that and
-still get into the calibration loop, double the iteration
-count and try again.  */
-  if (iterations < i * 10)
-   iterations = i * 10;
-  else
-   iterations *= 2;
-  goto start_over;
-}

[gcc(refs/users/aoliva/heads/testme)] [libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

2024-08-30 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:beba216fee9f07a3c3cf5e85ddf2ef72f38893c7

commit beba216fee9f07a3c3cf5e85ddf2ef72f38893c7
Author: Alexandre Oliva 
Date:   Fri Aug 30 09:06:40 2024 -0300

[libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

30_threads/future/members/poll.cc has calibration code that, on
systems with very low clock resolution, may spuriously fail to run.
Even when it does run, low resolution and reasonable
timeouts limit severely the viability of increasing the loop counts so
as to reduce measurement noise, so we end up with very noisy results.

On various vxworks targets, high iteration count (low-noise)
measurements confirmed that some of the operations that we expected to
be up to 100x slower than the fastest ones can run a little slower
than that and, with significant noise, may seem to be even slower,
comparatively.

Bump the factors up to 200x, so that we have plenty of margin over
measured results.


for  libstdc++-v3/ChangeLog

* testsuite/30_threads/future/members/poll.cc: Factor out
calibration, and run it unconditionally.  Lower its
strictness.  Bump wait_until_*'s slowness factor.

Diff:
---
 .../testsuite/30_threads/future/members/poll.cc| 111 +
 1 file changed, 70 insertions(+), 41 deletions(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc 
b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 2bdbe7a48ce5..6b7062c61cfd 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -41,52 +41,75 @@ print(const char* desc, Duration dur)
   return d;
 }
 
+static void
+calibrate()
+{
+  /* After set_value, wait_for is faster, so use that for the
+ calibration loops to avoid zero at low clock resultions.  */
+  promise p = {};
+  future f = p.get_future();
+  p.set_value(1);
+
+  auto start = chrono::high_resolution_clock::now();
+  auto stop = start;
+  /* Loop until the clock advances, so that start is right after a
+ time increment.  */
+  do
+stop = chrono::high_resolution_clock::now();
+  while (start == stop);
+
+  /* This approximates the smallest time increment we may expect to be
+ able to measure.  It doesn't have to be very precise, just a
+ ballpart of the right magnitude.  */
+  auto tick = stop - start;
+
+  int i = 0;
+  start = stop;
+  /* Now until the clock advances again, so that stop is right
+ after another time increment.  */
+  do
+{
+  f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+  i++;
+}
+  while (start == stop);
+
+  /* Aim for some 10 ticks.  This won't be quite right if now() takes
+ up a significant portion of the loop time, but we'll measure
+ without that and adjust in the loop below.  */
+  if (iterations < i * 10)
+iterations = i * 10;
+
+  /* We aim for some 10 ticks for the loop that's expected to be fastest,
+ but even if we don't get quite that many, we're still fine.  */
+  iterations /= 2;
+  do
+{
+  iterations *= 2;
+  start = chrono::high_resolution_clock::now();
+  for(int i = 0; i < iterations; i++)
+   f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+}
+  while (stop - start < 5 * tick);
+}
+
 int main()
 {
+  /* First, calibrate the iteration count so that we don't get any of
+ the actual measurement loops to complete in less than the clock
+ granularity.  */
+  calibrate ();
+
   promise p;
   future f = p.get_future();
 
- start_over:
   auto start = chrono::high_resolution_clock::now();
   for(int i = 0; i < iterations; i++)
 f.wait_for(chrono::seconds(0));
   auto stop = chrono::high_resolution_clock::now();
 
-  /* We've run too few iterations for the clock resolution.
- Attempt to calibrate it.  */
-  if (start == stop)
-{
-  /* After set_value, wait_for is faster, so use that for the
-calibration to avoid zero at low clock resultions.  */
-  promise pc;
-  future fc = pc.get_future();
-  pc.set_value(1);
-
-  /* Loop until the clock advances, so that start is right after a
-time increment.  */
-  do
-   start = chrono::high_resolution_clock::now();
-  while (start == stop);
-  int i = 0;
-  /* Now until the clock advances again, so that stop is right
-after another time increment.  */
-  do
-   {
- fc.wait_for(chrono::seconds(0));
- stop = chrono::high_resolution_clock::now();
- i++;
-   }
-  while (start == stop);
-  /* Go for some 10 cycles, but if we're already past that and
-still get into the calibration loop, double the iteration
-count and try again.  */
-  if (iterations < i * 10)
-   iterations = i * 10;
-  else
-   iterations *= 2;
-  goto start_over;
-}

[gcc r15-3385] [libstdc++] [testsuite] avoid async.cc loss of precision [PR91486]

2024-09-02 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:410061b15a9b0a464c851173fa568e49c85570dc

commit r15-3385-g410061b15a9b0a464c851173fa568e49c85570dc
Author: Alexandre Oliva 
Date:   Mon Sep 2 11:31:59 2024 -0300

[libstdc++] [testsuite] avoid async.cc loss of precision [PR91486]

When we get to test_pr91486_wait_until(), we're about 10s past the
float_steady_clock epoch.  This is enough for the 1s delta for the
timeout to come out slightly lower when the futex-less wait_until
converts the deadline from float_steady_clock to __clock_t.  So we may
wake up a little too early, and end up looping one extra time to sleep
for e.g. another 954ns until we hit the deadline.

Each iteration calls float_steady_clock::now(), bumping the call_count
that we VERIFY() at the end of the subtest.  Since we expect at most 3
calls, and we're going to have at the very least 3 on futex-less
targets (one in the test proper, one before wait_until_impl to compute
the deadline, and one after wait_until_impl to check whether the
deadline was hit), any such imprecision that causes an extra iteration
will reach 5 and cause the test to fail.

Initializing the epoch in the beginning of the test makes such
spurious fails due to loss of precision far less likely.  I don't
suppose allowing for an extra couple of calls would be desirable.

While at that, I'm annotating unused status variables as such.


for  libstdc++-v3/ChangeLog

PR libstdc++/91486
* testsuite/30_threads/async/async.cc
(test_pr91486_wait_for): Mark status as unused.
(test_pr91486_wait_until): Likewise.  Initialize epoch later.

Diff:
---
 libstdc++-v3/testsuite/30_threads/async/async.cc | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/testsuite/30_threads/async/async.cc 
b/libstdc++-v3/testsuite/30_threads/async/async.cc
index 3b157ed9c568..2474d318d7b1 100644
--- a/libstdc++-v3/testsuite/30_threads/async/async.cc
+++ b/libstdc++-v3/testsuite/30_threads/async/async.cc
@@ -173,7 +173,7 @@ void test_pr91486_wait_for()
 
   std::chrono::duration const wait_time = std::chrono::seconds(1);
   auto const start_steady = chrono::steady_clock::now();
-  auto status = f1.wait_for(wait_time);
+  auto status __attribute__ ((__unused__)) = f1.wait_for(wait_time);
   auto const elapsed_steady = chrono::steady_clock::now() - start_steady;
 
   VERIFY( elapsed_steady >= std::chrono::seconds(1) );
@@ -209,7 +209,7 @@ struct float_steady_clock
   }
 };
 
-chrono::steady_clock::time_point float_steady_clock::epoch = 
chrono::steady_clock::now();
+chrono::steady_clock::time_point float_steady_clock::epoch;
 int float_steady_clock::call_count = 0;
 
 void test_pr91486_wait_until()
@@ -218,6 +218,19 @@ void test_pr91486_wait_until()
   std::this_thread::sleep_for(std::chrono::seconds(1));
 });
 
+  // When we don't _GLIBCXX_HAVE_LINUX_FUTEX, we use
+  // condition_variables, whose wait_until converts times using
+  // deltas, and if too much time has elapsed since we set the epoch
+  // during program initialization, say if the other tests took over
+  // 8s and we're unlucky with the numbers, we may lose enough
+  // precision from the 1s delta that we don't sleep until the
+  // deadline, and then we may loop more times than expected.  Each
+  // iteration will recompute the wait time from deadline -
+  // float_steady_clock::now(), and each such computation will bump
+  // float_steady_clock::call_count, so the call_count check below
+  // will fail spuriously.  Setting the epoch just before running this
+  // test makes this failure mode far less likely.
+  float_steady_clock::epoch = chrono::steady_clock::now();
   float_steady_clock::time_point const now = float_steady_clock::now();
 
   std::chrono::duration const wait_time = std::chrono::seconds(1);
@@ -225,7 +238,7 @@ void test_pr91486_wait_until()
   VERIFY( expire > now );
 
   auto const start_steady = chrono::steady_clock::now();
-  auto status = f1.wait_until(expire);
+  auto status __attribute__ ((__unused__)) = f1.wait_until(expire);
   auto const elapsed_steady = chrono::steady_clock::now() - start_steady;
 
   // This checks that we didn't come back too soon


[gcc r15-3386] [libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

2024-09-02 Thread Alexandre Oliva via Libstdc++-cvs
https://gcc.gnu.org/g:af1500dd8c00df4541f7aa393ab7cf57db18241b

commit r15-3386-gaf1500dd8c00df4541f7aa393ab7cf57db18241b
Author: Alexandre Oliva 
Date:   Mon Sep 2 11:32:03 2024 -0300

[libstdc++-v3] [testsuite] improve future/*/poll.cc calibration

30_threads/future/members/poll.cc has calibration code that, on
systems with very low clock resolution, may spuriously fail to run.
Even when it does run, low resolution and reasonable
timeouts limit severely the viability of increasing the loop counts so
as to reduce measurement noise, so we end up with very noisy results.

On various vxworks targets, high iteration count (low-noise)
measurements confirmed that some of the operations that we expected to
be up to 100x slower than the fastest ones can run a little slower
than that and, with significant noise, may seem to be even slower,
comparatively.

Bump the factors up to 200x, so that we have plenty of margin over
measured results.


for  libstdc++-v3/ChangeLog

* testsuite/30_threads/future/members/poll.cc: Factor out
calibration, and run it unconditionally.  Lower its
strictness.  Bump wait_until_*'s slowness factor.

Diff:
---
 .../testsuite/30_threads/future/members/poll.cc| 111 +
 1 file changed, 70 insertions(+), 41 deletions(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc 
b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 2bdbe7a48ce5..6b7062c61cfd 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -41,52 +41,75 @@ print(const char* desc, Duration dur)
   return d;
 }
 
+static void
+calibrate()
+{
+  /* After set_value, wait_for is faster, so use that for the
+ calibration loops to avoid zero at low clock resultions.  */
+  promise p = {};
+  future f = p.get_future();
+  p.set_value(1);
+
+  auto start = chrono::high_resolution_clock::now();
+  auto stop = start;
+  /* Loop until the clock advances, so that start is right after a
+ time increment.  */
+  do
+stop = chrono::high_resolution_clock::now();
+  while (start == stop);
+
+  /* This approximates the smallest time increment we may expect to be
+ able to measure.  It doesn't have to be very precise, just a
+ ballpart of the right magnitude.  */
+  auto tick = stop - start;
+
+  int i = 0;
+  start = stop;
+  /* Now until the clock advances again, so that stop is right
+ after another time increment.  */
+  do
+{
+  f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+  i++;
+}
+  while (start == stop);
+
+  /* Aim for some 10 ticks.  This won't be quite right if now() takes
+ up a significant portion of the loop time, but we'll measure
+ without that and adjust in the loop below.  */
+  if (iterations < i * 10)
+iterations = i * 10;
+
+  /* We aim for some 10 ticks for the loop that's expected to be fastest,
+ but even if we don't get quite that many, we're still fine.  */
+  iterations /= 2;
+  do
+{
+  iterations *= 2;
+  start = chrono::high_resolution_clock::now();
+  for(int i = 0; i < iterations; i++)
+   f.wait_for(chrono::seconds(0));
+  stop = chrono::high_resolution_clock::now();
+}
+  while (stop - start < 5 * tick);
+}
+
 int main()
 {
+  /* First, calibrate the iteration count so that we don't get any of
+ the actual measurement loops to complete in less than the clock
+ granularity.  */
+  calibrate ();
+
   promise p;
   future f = p.get_future();
 
- start_over:
   auto start = chrono::high_resolution_clock::now();
   for(int i = 0; i < iterations; i++)
 f.wait_for(chrono::seconds(0));
   auto stop = chrono::high_resolution_clock::now();
 
-  /* We've run too few iterations for the clock resolution.
- Attempt to calibrate it.  */
-  if (start == stop)
-{
-  /* After set_value, wait_for is faster, so use that for the
-calibration to avoid zero at low clock resultions.  */
-  promise pc;
-  future fc = pc.get_future();
-  pc.set_value(1);
-
-  /* Loop until the clock advances, so that start is right after a
-time increment.  */
-  do
-   start = chrono::high_resolution_clock::now();
-  while (start == stop);
-  int i = 0;
-  /* Now until the clock advances again, so that stop is right
-after another time increment.  */
-  do
-   {
- fc.wait_for(chrono::seconds(0));
- stop = chrono::high_resolution_clock::now();
- i++;
-   }
-  while (start == stop);
-  /* Go for some 10 cycles, but if we're already past that and
-still get into the calibration loop, double the iteration
-count and try again.  */
-  if (iterations < i * 10)
-   iterations = i * 10;
-  else
-   iterations *= 2;
-  goto start_ove