From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2062) id 2FF64398B8AC; Thu, 22 Apr 2021 14:34:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FF64398B8AC 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 r12-62] libstdc++: Fix "bare" notifications dropped by waiters check X-Act-Checkin: gcc X-Git-Author: Thomas Rodgers X-Git-Refname: refs/heads/master X-Git-Oldrev: 0cda606d08d6196b76524c7b6ad51d87fed0d54b X-Git-Newrev: ae2f6e01749f39b8b8ccc211fc29e5e6ec8b57cd Message-Id: <20210422143409.2FF64398B8AC@sourceware.org> Date: Thu, 22 Apr 2021 14:34:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2021 14:34:09 -0000 https://gcc.gnu.org/g:ae2f6e01749f39b8b8ccc211fc29e5e6ec8b57cd commit r12-62-gae2f6e01749f39b8b8ccc211fc29e5e6ec8b57cd Author: Thomas Rodgers Date: Wed Apr 21 18:12:03 2021 -0700 libstdc++: Fix "bare" notifications dropped by waiters check For types that track whether or not there extant waiters (e.g. semaphore) internally, the __atomic_notify_address_bare() call was introduced to avoid the overhead of loading the atomic count of waiters. For platforms that don't have Futex, however, there was still a check for waiters, and seeing that there are none (because in the bare case, the count is not incremented), the notification is dropped. This commit addresses that case. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h: Always notify waiters in the case of 'bare' address notification. Diff: --- libstdc++-v3/include/bits/atomic_wait.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 0ac5575190c..984ed70f16c 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -226,9 +226,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } void - _M_notify(const __platform_wait_t* __addr, bool __all) noexcept + _M_notify(const __platform_wait_t* __addr, bool __all, bool __bare) noexcept { - if (!_M_waiting()) + if (!(__bare || _M_waiting())) return; #ifdef _GLIBCXX_HAVE_PLATFORM_WAIT @@ -304,11 +304,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } void - _M_notify(bool __all) + _M_notify(bool __all, bool __bare = false) { if (_M_addr == &_M_w._M_ver) __atomic_fetch_add(_M_addr, 1, __ATOMIC_ACQ_REL); - _M_w._M_notify(_M_addr, __all); + _M_w._M_notify(_M_addr, __all, __bare); } template