From: Jonathan Wakely <jwakely@redhat.com>
To: Thomas Rodgers <rodgert@appliantology.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org,
trodgers@redhat.com, Thomas Rodgers <rodgert@twrodgers.com>
Subject: Re: [PATCH] [libstdc++] Refactor/cleanup of atomic wait implementation
Date: Tue, 20 Apr 2021 14:50:09 +0100 [thread overview]
Message-ID: <20210420135009.GM3008@redhat.com> (raw)
In-Reply-To: <20210419192305.406972-1-rodgert@appliantology.com>
On 19/04/21 12:23 -0700, Thomas Rodgers wrote:
>+#if __cpp_lib_atomic_wait
>+ struct __atomic_semaphore
>+ {
>+ static constexpr ptrdiff_t _S_max = __gnu_cxx::__int_traits<int>::__max;
>+ explicit __atomic_semaphore(__detail::__platform_wait_t __count) noexcept
>+ : _M_counter(__count)
> {
>- static_assert(std::is_integral_v<_Tp>);
>- static_assert(__gnu_cxx::__int_traits<_Tp>::__max
>- <= __gnu_cxx::__int_traits<ptrdiff_t>::__max);
>- static constexpr ptrdiff_t _S_max = __gnu_cxx::__int_traits<_Tp>::__max;
>+ __glibcxx_assert(__count >= 0 && __count <= _S_max);
>+ }
>
>- explicit __atomic_semaphore(_Tp __count) noexcept
>- : _M_counter(__count)
>+ __atomic_semaphore(const __atomic_semaphore&) = delete;
>+ __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
>+ {
>+ if (__old == 0)
>+ return false;
>+
>+ return __atomic_impl::compare_exchange_strong(__counter,
>+ __old, __old - 1,
>+ memory_order::acquire,
>+ memory_order::release);
This violates the compare_exchange precondition:
Preconditions: The failure argument is neither memory_order::release nor memory_order::acq_rel.
Should this be relaxed? I don't think a failed try_acquire has to
synchronize, does it?
prev parent reply other threads:[~2021-04-20 13:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 21:53 Thomas Rodgers
2021-02-23 21:57 ` Thomas Rodgers
2021-03-03 15:14 ` Jonathan Wakely
2021-03-03 17:31 ` Jonathan Wakely
2021-03-23 19:00 ` Thomas Rodgers
2021-04-15 12:46 ` Jonathan Wakely
2021-04-19 19:23 ` Thomas Rodgers
2021-04-20 9:18 ` Jonathan Wakely
2021-04-20 11:04 ` Jonathan Wakely
2021-04-20 11:41 ` Jonathan Wakely
2021-04-20 14:25 ` Jonathan Wakely
2021-04-20 14:26 ` Jonathan Wakely
2021-04-20 12:02 ` Jonathan Wakely
2021-04-20 13:20 ` Jonathan Wakely
2021-04-20 13:28 ` Jonathan Wakely
2021-04-20 13:38 ` Jonathan Wakely
2021-04-20 13:50 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210420135009.GM3008@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=rodgert@appliantology.com \
--cc=rodgert@twrodgers.com \
--cc=trodgers@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).