From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1895) id 99C353857B8D; Fri, 23 Sep 2022 15:01:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99C353857B8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663945264; bh=2eoiKEQNJAfJHAoVIgZejKI+bRMAKFLSb+8UmFiWipM=; h=From:To:Subject:Date:From; b=xN2bw+r32oPqxzZQ7zL2r1/MsYlYrWIm1Yw8CD+yH4l5PDuw9kh2yPhzX8sBPQFtw WCer4YORynNTrn3iptU3d+40SgVfeYearjnu8NuspYykqidfzbwHlDr7EznLEyNCX3 xcIKadDOeqEJwLMvAD1UqrKUuSSy6eg8G5N0haoA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Wilco Dijkstra To: glibc-cvs@sourceware.org Subject: [glibc] Use C11 atomics instead of atomic_and/or X-Act-Checkin: glibc X-Git-Author: Wilco Dijkstra X-Git-Refname: refs/heads/master X-Git-Oldrev: 774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6 X-Git-Newrev: 8114b95cef10a5a1fc3e529ab8b3a75f56fe889a Message-Id: <20220923150104.99C353857B8D@sourceware.org> Date: Fri, 23 Sep 2022 15:01:04 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8114b95cef10a5a1fc3e529ab8b3a75f56fe889a commit 8114b95cef10a5a1fc3e529ab8b3a75f56fe889a Author: Wilco Dijkstra Date: Thu Sep 22 15:27:20 2022 +0100 Use C11 atomics instead of atomic_and/or Remove the 4 uses of atomic_and and atomic_or with atomic_fetch_and_acquire and atomic_fetch_or_acquire. This is preserves existing implied semantics, however relaxed MO on FUTEX_OWNER_DIED accesses may be correct. Passes regress on AArch64. Reviewed-by: Adhemerval Zanella Diff: --- nptl/pthread_create.c | 2 +- nptl/pthread_mutex_lock.c | 2 +- nptl/pthread_mutex_timedlock.c | 2 +- nptl/pthread_mutex_trylock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index ee29cb375d..59d8df8cd7 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 6e767a8724..439b1e6391 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 0fcaabfb48..af70a60528 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 8a7de8e598..50524942a7 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;