From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: 'GNU C Library' <libc-alpha@sourceware.org>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: [PATCH] Use C11 atomics instead of atomic_and/or
Date: Mon, 5 Sep 2022 16:48:37 +0000 [thread overview]
Message-ID: <AS4PR08MB79017C4FC5AE484617FAC654837F9@AS4PR08MB7901.eurprd08.prod.outlook.com> (raw)
Remove the 4 uses of atomic_and and atomic_or with atomic_fetch_and_acquire and
atomic_fetch_or_acquire
Passes regress on AArch64.
---
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index d206ed7bf4c2305c0d65bc2a47baefe02969e3d2..d802c67b059af390e122e82f09e886d0c8950fd7 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -539,7 +539,7 @@ start_thread (void *arg)
# endif
this->__list.__next = NULL;
- atomic_or (&this->__lock, FUTEX_OWNER_DIED);
+ atomic_fetch_or_acquire (&this->__lock, FUTEX_OWNER_DIED);
futex_wake ((unsigned int *) &this->__lock, 1,
/* XYZ */ FUTEX_SHARED);
}
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 6e767a87247063c0ac84242ef13e72af79021104..439b1e6391c50d5922dec6c48e7f2a2a632a89d9 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -462,7 +462,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED))
{
- atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+ atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
/* We got the mutex. */
mutex->__data.__count = 1;
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 0fcaabfb482546fd6f1f9cc4b13edc82f6e6796c..af70a60528cb101c8e52d4165950ee0d11f6f895 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -392,7 +392,7 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex,
if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED))
{
- atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+ atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
/* We got the mutex. */
mutex->__data.__count = 1;
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 8a7de8e598803f606899fe1c9b8775bc24dd14ec..50524942a76c753ce4add20c35dfe7f659a1908b 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -308,7 +308,7 @@ ___pthread_mutex_trylock (pthread_mutex_t *mutex)
if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED))
{
- atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+ atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
/* We got the mutex. */
mutex->__data.__count = 1;
next reply other threads:[~2022-09-05 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 16:48 Wilco Dijkstra [this message]
2022-09-21 17:08 ` Adhemerval Zanella Netto
2022-09-22 14:06 ` Wilco Dijkstra
2022-09-23 13:34 ` Adhemerval Zanella Netto
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=AS4PR08MB79017C4FC5AE484617FAC654837F9@AS4PR08MB7901.eurprd08.prod.outlook.com \
--to=wilco.dijkstra@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.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: 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).