From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 0B9EC3858405; Tue, 23 Nov 2021 21:17:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B9EC3858405 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9267] libstdc++: Define macro before it is first checked X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 58cd66aec9f87d742840b03206bacafbf0273a92 X-Git-Newrev: fd3f0c66e854c5cac664761b4c60fc86c69a5024 Message-Id: <20211123211740.0B9EC3858405@sourceware.org> Date: Tue, 23 Nov 2021 21:17:40 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 21:17:40 -0000 https://gcc.gnu.org/g:fd3f0c66e854c5cac664761b4c60fc86c69a5024 commit r11-9267-gfd3f0c66e854c5cac664761b4c60fc86c69a5024 Author: Jonathan Wakely Date: Tue Aug 31 15:51:09 2021 +0100 libstdc++: Define macro before it is first checked Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (_GLIBCXX_HAVE_PLATFORM_WAIT): Define before first attempt to check it. (cherry picked from commit aeaea265cea3a2b2e772af7825351a4ceef29aac) Diff: --- libstdc++-v3/include/bits/atomic_wait.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 07bb744d822..35c92644146 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -56,9 +56,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __detail { #ifdef _GLIBCXX_HAVE_LINUX_FUTEX +#define _GLIBCXX_HAVE_PLATFORM_WAIT 1 using __platform_wait_t = int; static constexpr size_t __platform_wait_alignment = 4; #else +// define _GLIBCX_HAVE_PLATFORM_WAIT and implement __platform_wait() +// and __platform_notify() if there is a more efficient primitive supported +// by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than +// a mutex/condvar based wait. using __platform_wait_t = uint64_t; static constexpr size_t __platform_wait_alignment = __alignof__(__platform_wait_t); @@ -70,7 +75,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_HAVE_PLATFORM_WAIT = is_scalar_v<_Tp> && ((sizeof(_Tp) == sizeof(__detail::__platform_wait_t)) - && (alignof(_Tp*) >= __platform_wait_alignment)); + && (alignof(_Tp*) >= __detail::__platform_wait_alignment)); #else = false; #endif @@ -78,7 +83,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __detail { #ifdef _GLIBCXX_HAVE_LINUX_FUTEX -#define _GLIBCXX_HAVE_PLATFORM_WAIT 1 enum class __futex_wait_flags : int { #ifdef _GLIBCXX_HAVE_LINUX_FUTEX_PRIVATE @@ -118,11 +122,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_cast(__futex_wait_flags::__wake_private), __all ? INT_MAX : 1); } -#else -// define _GLIBCX_HAVE_PLATFORM_WAIT and implement __platform_wait() -// and __platform_notify() if there is a more efficient primitive supported -// by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than -// a mutex/condvar based wait #endif inline void @@ -331,7 +330,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if constexpr (__platform_wait_uses_type<_Up>) { - __val == __old; + __builtin_memcpy(&__val, &__old, sizeof(__val)); } else {