On 21/11/20 16:16 +0100, Andreas Schwab wrote:
In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h: In member function 'void std::atomic_flag::wait(bool, std::memory_order) const': /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: error: no matching function for call to '__atomic_wait(const __atomic_flag_data_type*, bool&, std::atomic_flag::wait(bool, std::memory_order) const::<lambda()>)' In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:41, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: candidate: 'template<class _Tp, class _Pred> void std::__atomic_wait(const _Tp*, _Tp, _Pred)' /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: template argument deduction/substitution failed: In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: note: deduced conflicting types for parameter '_Tp' ('unsigned char' and 'bool')
I'm testing this.
commit 613ac97bed57eb0edb1803b66d5ce3510e665b3d Author: Jonathan Wakely <jwak...@redhat.com> Date: Sat Nov 21 16:52:22 2020 libstdc++: Fix atomic waiting for non-linux targets This fixes some UNRESOLVED tests on (at least) Solaris and Darwin, and disables some tests that hang forever on Solaris. A proper fix is still needed. libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (atomic_flag::wait): Use correct type for __atomic_wait call. * include/bits/atomic_timed_wait.h (__atomic_wait_until): Check _GLIBCXX_HAVE_LINUX_FUTEX. * include/bits/atomic_wait.h (__atomic_notify): Likewise. * include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE): Only define if SEM_VALUE_MAX or _POSIX_SEM_VALUE_MAX is defined. * testsuite/29_atomics/atomic/wait_notify/bool.cc: Disable on non-linux targes. * testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise. * testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise. * testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise. diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index dd4db926592e..7de02f169977 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -234,7 +234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION wait(bool __old, memory_order __m = memory_order_seq_cst) const noexcept { - std::__atomic_wait(&_M_i, __old, + std::__atomic_wait(&_M_i, static_cast<__atomic_flag_data_type>(__old), [__m, this, __old]() { return this->test(__m) != __old; }); } diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h b/libstdc++-v3/include/bits/atomic_timed_wait.h index 7712a6c591dc..405f7e93ca85 100644 --- a/libstdc++-v3/include/bits/atomic_timed_wait.h +++ b/libstdc++-v3/include/bits/atomic_timed_wait.h @@ -240,12 +240,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION do { __atomic_wait_status __res; +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX if constexpr (__platform_wait_uses_type<_Tp>) { __res = __detail::__platform_wait_until((__platform_wait_t*)(void*) __addr, __old, __atime); } else +#endif { __res = __w._M_do_wait_until(__version, __atime); } diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 2d08e5325fb2..7b2682a577ef 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -292,11 +292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (!__w._M_waiting()) return; +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX if constexpr (__platform_wait_uses_type<_Tp>) { __platform_notify((__platform_wait_t*)(void*) __addr, __all); } else +#endif { __w._M_notify(__all); } diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h index da6dc4b91858..78a0b6ba26e6 100644 --- a/libstdc++-v3/include/bits/semaphore_base.h +++ b/libstdc++-v3/include/bits/semaphore_base.h @@ -39,8 +39,10 @@ #include <ext/numeric_traits.h> #if __has_include(<semaphore.h>) -#define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 -#include <semaphore.h> +# include <semaphore.h> +# if defined SEM_VALUE_MAX || _POSIX_SEM_VALUE_MAX +# define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 +# endif #endif #include <chrono> @@ -54,7 +56,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __platform_semaphore { using __clock_t = chrono::system_clock; +#ifdef SEM_VALUE_MAX static constexpr ptrdiff_t _S_max = SEM_VALUE_MAX; +#else + static constexpr ptrdiff_t _S_max = _POSIX_SEM_VALUE_MAX; +#endif explicit __platform_semaphore(ptrdiff_t __count) noexcept { diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/bool.cc b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/bool.cc index 5f1e30a710fe..29781c6e1357 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/bool.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/bool.cc @@ -1,7 +1,8 @@ -// { dg-options "-std=gnu++2a -pthread" } +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target pthread } // { dg-require-gthreads "" } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-skip-if "broken" { ! *-*-*linux } } // Copyright (C) 2020 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/pointers.cc b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/pointers.cc index 8531bb2e7880..f54961f893d4 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/pointers.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/wait_notify/pointers.cc @@ -1,7 +1,8 @@ -// { dg-options "-std=gnu++2a -pthread" } +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target pthread } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } +// { dg-skip-if "broken" { ! *-*-*linux } } // Copyright (C) 2020 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/wait_notify/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/wait_notify/1.cc index 4f026e1dc9c1..763d3e77159c 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_flag/wait_notify/1.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/wait_notify/1.cc @@ -1,7 +1,8 @@ -// { dg-options "-std=gnu++2a -pthread" } +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target pthread } // { dg-require-gthreads "" } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-skip-if "broken" { ! *-*-*linux } } // Copyright (C) 2020 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/wait_notify.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/wait_notify.cc index 640a84e0342e..27d9b601c2f4 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_float/wait_notify.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/wait_notify.cc @@ -1,7 +1,8 @@ -// { dg-options "-std=gnu++2a -pthread" } +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target pthread } // { dg-require-gthreads "" } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-skip-if "broken" { ! *-*-*linux } } // Copyright (C) 2020 Free Software Foundation, Inc. //