From d1babeb32de5dae8893c640bd925357b218d846c Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Thu, 22 Sep 2022 15:32:40 +0100 Subject: Use C11 atomics instead of atomic_increment(_val) 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 --- nscd/cache.c | 2 +- nscd/nscd_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'nscd') diff --git a/nscd/cache.c b/nscd/cache.c index b66c35334a..21af9a0f95 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -192,7 +192,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet, /* 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. */ diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 0651817a99..fc41bfdb6e 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -425,7 +425,7 @@ __nscd_get_map_ref (request_type type, const char *name, 0)) cur = NO_MAPPING; else - atomic_increment (&cur->counter); + atomic_fetch_add_relaxed (&cur->counter, 1); } } -- cgit 1.4.1