Replace atomic_increment and atomic_increment_val with atomic_fetch_add_relaxed.
One case in sem_post.c uses release semantics (see comment above it).
The others are simple counters and do not protect any shared data from
concurrent accesses.
Passes regress on AArch64.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
the number of threads from within the new thread isn't an option
since this thread might return and call `pthread_exit' before the
new thread runs. */
- atomic_increment (&__pthread_total);
+ atomic_fetch_add_relaxed (&__pthread_total, 1);
/* Store a pointer to this thread in the thread ID lookup table. We
could use __thread_setid, however, we only lock for reading as no
@deftypefun int sem_wait (sem_t *@var{sem});
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-@c atomic_increment (nwaiters) acucorrupt
+@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
@c
@c Given the use atomic operations this function seems
@c to be AS-safe. It is AC-unsafe because there is still
@c _dl_allocate_tls_init ok
@c GET_DTV ok
@c mmap ok
-@c atomic_increment_val ok
+@c atomic_fetch_add_relaxed ok
@c munmap ok
@c change_stack_perm ok
@c mprotect ok
@c do_clone @asulock @ascuheap @aculock @acsmem
@c PREPARE_CREATE ok
@c lll_lock (pd->lock) @asulock @aculock
-@c atomic_increment ok
+@c atomic_fetch_add_relaxed ok
@c clone ok
@c atomic_fetch_add_relaxed ok
@c atomic_exchange_acq ok
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val))
{
- atomic_increment (&cmdp->cntr);
+ atomic_fetch_add_relaxed (&cmdp->cntr, 1);
return 1;
}
else
we momentarily store a false value; this doesn't matter because there
is no kosher thing a signal handler interrupting us right here can do
that cares whether the thread count is correct. */
- atomic_increment (&__nptl_nthreads);
+ atomic_fetch_add_relaxed (&__nptl_nthreads, 1);
/* Our local value of stopped_start and thread_ran can be accessed at
any time. The PD->stopped_start may only be accessed if we have
/* We must need to synchronize with consumers of this token, so the atomic
increment must have release MO semantics. */
atomic_write_barrier ();
- (void) atomic_increment_val (futex);
+ atomic_fetch_add_release (futex, 1);
/* We always have to assume it is a shared semaphore. */
futex_wake (futex, 1, LLL_SHARED);
return 0;
/* We depend on this value being correct and at least as high as the
real number of entries. */
- atomic_increment (&table->head->nentries);
+ atomic_fetch_add_relaxed (&table->head->nentries, 1);
/* It does not matter that we are not loading the just increment
value, this is just for statistics. */
0))
cur = NO_MAPPING;
else
- atomic_increment (&cur->counter);
+ atomic_fetch_add_relaxed (&cur->counter, 1);
}
}
uint32_t
__bump_nl_timestamp (void)
{
- if (atomic_increment_val (&nl_timestamp) == 0)
- atomic_increment (&nl_timestamp);
+ if (atomic_fetch_add_relaxed (&nl_timestamp, 1) + 1 == 0)
+ atomic_fetch_add_relaxed (&nl_timestamp, 1);
return nl_timestamp;
}
if (cache_valid_p ())
{
data = cache;
- atomic_increment (&cache->usecnt);
+ atomic_fetch_add_relaxed (&cache->usecnt, 1);
}
else
{