summary refs log tree commit diff
path: root/htl
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2022-09-22 15:40:37 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2022-09-23 15:59:56 +0100
commit4a07fbb689eeec30e7d71a0d144c26e0d1e424ac (patch)
tree85d53e165fb64b144ce9ac3018cd90afdd70bf4f /htl
parentd1babeb32de5dae8893c640bd925357b218d846c (diff)
downloadglibc-4a07fbb689eeec30e7d71a0d144c26e0d1e424ac.tar.gz
glibc-4a07fbb689eeec30e7d71a0d144c26e0d1e424ac.tar.xz
glibc-4a07fbb689eeec30e7d71a0d144c26e0d1e424ac.zip
Use C11 atomics instead of atomic_decrement_and_test
Replace atomic_decrement_and_test with atomic_fetch_add_relaxed.
These are simple counters which do not protect any shared data from
concurrent accesses. Also remove the unused file cond-perf.c.

Passes regress on AArch64.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'htl')
-rw-r--r--htl/pt-dealloc.c2
-rw-r--r--htl/pt-exit.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/htl/pt-dealloc.c b/htl/pt-dealloc.c
index c776e3471d..86bbb3091f 100644
--- a/htl/pt-dealloc.c
+++ b/htl/pt-dealloc.c
@@ -33,7 +33,7 @@ extern pthread_mutex_t __pthread_free_threads_lock;
 void
 __pthread_dealloc (struct __pthread *pthread)
 {
-  if (!atomic_decrement_and_test (&pthread->nr_refs))
+  if (atomic_fetch_add_relaxed (&pthread->nr_refs, -1) != 1)
     return;
 
   /* Withdraw this thread from the thread ID lookup table.  */
diff --git a/htl/pt-exit.c b/htl/pt-exit.c
index f0759c8738..3c0a8c52f3 100644
--- a/htl/pt-exit.c
+++ b/htl/pt-exit.c
@@ -50,7 +50,7 @@ __pthread_exit (void *status)
 
   /* Decrease the number of threads.  We use an atomic operation to
      make sure that only the last thread calls `exit'.  */
-  if (atomic_decrement_and_test (&__pthread_total))
+  if (atomic_fetch_add_relaxed (&__pthread_total, -1) == 1)
     /* We are the last thread.  */
     exit (0);