From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2062) id 4E44A3846079; Thu, 22 Apr 2021 01:32:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E44A3846079 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Thomas Rodgers To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-8277] [libstdc++] Fix test timeout in stop_calback/destroy.cc X-Act-Checkin: gcc X-Git-Author: Thomas Rodgers X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 3a8437df2918114dae03f5614a250ff8a150050d X-Git-Newrev: c0ffafb343ac80654e87b459492c575b7916d60c Message-Id: <20210422013243.4E44A3846079@sourceware.org> Date: Thu, 22 Apr 2021 01:32:43 +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: Thu, 22 Apr 2021 01:32:43 -0000 https://gcc.gnu.org/g:c0ffafb343ac80654e87b459492c575b7916d60c commit r11-8277-gc0ffafb343ac80654e87b459492c575b7916d60c Author: Thomas Rodgers Date: Wed Apr 21 10:01:06 2021 -0700 [libstdc++] Fix test timeout in stop_calback/destroy.cc A change was made to __atomic_semaphore::_S_do_try_acquire() to (ideally) let the compare_exchange reload the value of __old rather than always reloading it twice. This causes _M_acquire to spin indefinitely if the value of __old is already 0. libstdc++-v3/ChangeLog: * include/bits/semaphore_base.h: Always reload __old in __atomic_semaphore::_S_do_try_acquire(). * testsuite/30_threads/stop_token/stop_callback/destroy.cc: re-enable testcase. (cherry picked from commit 7eeb8c04e53fa880ee559efb727517ce778d17a0) Diff: --- libstdc++-v3/include/bits/semaphore_base.h | 16 ++++++---------- .../30_threads/stop_token/stop_callback/destroy.cc | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h index 35469e443b0..84b33423fff 100644 --- a/libstdc++-v3/include/bits/semaphore_base.h +++ b/libstdc++-v3/include/bits/semaphore_base.h @@ -196,9 +196,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __atomic_semaphore& operator=(const __atomic_semaphore&) = delete; static _GLIBCXX_ALWAYS_INLINE bool - _S_do_try_acquire(__detail::__platform_wait_t* __counter, - __detail::__platform_wait_t& __old) noexcept + _S_do_try_acquire(__detail::__platform_wait_t* __counter) noexcept { + auto __old = __atomic_impl::load(__counter, memory_order::acquire); if (__old == 0) return false; @@ -211,18 +211,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_ALWAYS_INLINE void _M_acquire() noexcept { - auto __old = __atomic_impl::load(&_M_counter, memory_order::acquire); auto const __pred = - [this, &__old] { return _S_do_try_acquire(&this->_M_counter, __old); }; + [this] { return _S_do_try_acquire(&this->_M_counter); }; std::__atomic_wait_address_bare(&_M_counter, __pred); } bool _M_try_acquire() noexcept { - auto __old = __atomic_impl::load(&_M_counter, memory_order::acquire); auto const __pred = - [this, &__old] { return _S_do_try_acquire(&this->_M_counter, __old); }; + [this] { return _S_do_try_acquire(&this->_M_counter); }; return std::__detail::__atomic_spin(__pred); } @@ -231,9 +229,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_try_acquire_until(const chrono::time_point<_Clock, _Duration>& __atime) noexcept { - auto __old = __atomic_impl::load(&_M_counter, memory_order_relaxed); auto const __pred = - [this, &__old] { return _S_do_try_acquire(&this->_M_counter, __old); }; + [this] { return _S_do_try_acquire(&this->_M_counter); }; return __atomic_wait_address_until_bare(&_M_counter, __pred, __atime); } @@ -243,9 +240,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_try_acquire_for(const chrono::duration<_Rep, _Period>& __rtime) noexcept { - auto __old = __atomic_impl::load(&_M_counter, memory_order_relaxed); auto const __pred = - [this, &__old] { return _S_do_try_acquire(&this->_M_counter, __old); }; + [this] { return _S_do_try_acquire(&this->_M_counter); }; return __atomic_wait_address_for_bare(&_M_counter, __pred, __rtime); } diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc index c2cfba027cb..061ed448c33 100644 --- a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc @@ -21,8 +21,6 @@ // { dg-require-effective-target pthread } // { dg-require-gthreads "" } -// { dg-skip-if "FIXME: times out" { *-*-* } } - #include #include #include