public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-5119] libstdc++: Use lock-free type for __platform_wait_t Date: Thu, 12 Jan 2023 11:01:37 +0000 (GMT) [thread overview] Message-ID: <20230112110137.1CAA33858D35@sourceware.org> (raw) https://gcc.gnu.org/g:dc22cf461278ace754042d9388a62afb002dfa0e commit r13-5119-gdc22cf461278ace754042d9388a62afb002dfa0e Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Jan 5 20:23:26 2023 +0000 libstdc++: Use lock-free type for __platform_wait_t For non-futex targets the __platform_wait_t type is currently uint64_t, but that requires a lock in libatomic for some 32-bit targets. We don't really need a 64-bit type, so use unsigned long if that is lock-free, and int otherwise. This should mean it's lock-free on a wider set of targets. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (__detail::__platform_wait_t): Define as unsigned long if always lock-free, and unsigned int otherwise. Diff: --- libstdc++-v3/include/bits/atomic_wait.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index bd1ed56d157..1d7a034a165 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // 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; +# if ATOMIC_LONG_LOCK_FREE == 2 + using __platform_wait_t = unsigned long; +# else + using __platform_wait_t = unsigned int; +# endif inline constexpr size_t __platform_wait_alignment = __alignof__(__platform_wait_t); #endif
reply other threads:[~2023-01-12 11:01 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230112110137.1CAA33858D35@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /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: linkBe 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).