From 4a07fbb689eeec30e7d71a0d144c26e0d1e424ac Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Thu, 22 Sep 2022 15:40:37 +0100 Subject: 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 --- htl/pt-dealloc.c | 2 +- htl/pt-exit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'htl') 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); -- cgit 1.4.1