[PATCH] [libstdc++] Refactor/cleanup of atomic wait implementation
Jonathan Wakely
jwakely@redhat.com
Wed Mar 3 15:14:53 GMT 2021
On 23/02/21 13:57 -0800, Thomas Rodgers wrote:
>diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
>index 1a0f0943ebd..fa83ef6c231 100644
>--- a/libstdc++-v3/include/bits/atomic_wait.h
>+++ b/libstdc++-v3/include/bits/atomic_wait.h
>@@ -39,17 +39,16 @@
> #include <ext/numeric_traits.h>
>
> #ifdef _GLIBCXX_HAVE_LINUX_FUTEX
>+#define _GLIBCXX_HAVE_PLATFORM_WAIT 1
This is defined here (to 1) and then ...
> # include <cerrno>
> # include <climits>
> # include <unistd.h>
> # include <syscall.h>
> # include <bits/functexcept.h>
>-// TODO get this from Autoconf
>-# define _GLIBCXX_HAVE_LINUX_FUTEX_PRIVATE 1
>-#else
>-# include <bits/std_mutex.h> // std::mutex, std::__condvar
> #endif
>
>+# include <bits/std_mutex.h> // std::mutex, std::__condvar
>+
> #define __cpp_lib_atomic_wait 201907L
>
> namespace std _GLIBCXX_VISIBILITY(default)
>@@ -57,20 +56,27 @@ namespace std _GLIBCXX_VISIBILITY(default)
> _GLIBCXX_BEGIN_NAMESPACE_VERSION
> namespace __detail
> {
>+#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
> using __platform_wait_t = int;
>+#else
>+ using __platform_wait_t = uint64_t;
>+#endif
>+ } // namespace __detail
>
>- constexpr auto __atomic_spin_count_1 = 16;
>- constexpr auto __atomic_spin_count_2 = 12;
>-
>- template<typename _Tp>
>- inline constexpr bool __platform_wait_uses_type
>-#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
>- = is_same_v<remove_cv_t<_Tp>, __platform_wait_t>;
>+ template<typename _Tp>
>+ inline constexpr bool __platform_wait_uses_type
>+#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT
>+ = is_same_v<remove_cv_t<_Tp>, __detail::__platform_wait_t>
>+ || ((sizeof(_Tp) == sizeof(__detail::__platform_wait_t))
>+ && (alignof(_Tp*) == alignof(__detail::__platform_wait_t)));
> #else
>- = false;
>+ = false;
> #endif
>
>+ namespace __detail
>+ {
> #ifdef _GLIBCXX_HAVE_LINUX_FUTEX
>+#define _GLIBCXX_HAVE_PLATFORM_WAIT
Redefined here (to empty), after it's already been tested.
Presumably this redefinition shouldn't be here.
Also the HAVE_PLATFORM_TIMED_WAIT macro is defined to empty. I think
they should both be defined to 1 (or both empty, but not
inconsistently).
I'm still going through the rest of the patch.
More information about the Gcc-patches
mailing list