about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2022-09-22 15:32:40 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2022-09-23 15:59:56 +0100
commitd1babeb32de5dae8893c640bd925357b218d846c (patch)
treec5ee8e42e03e6a4caf2eb645d5f9b7a8bdbdb6e1 /sysdeps/unix/sysv
parent8114b95cef10a5a1fc3e529ab8b3a75f56fe889a (diff)
downloadglibc-d1babeb32de5dae8893c640bd925357b218d846c.tar.gz
glibc-d1babeb32de5dae8893c640bd925357b218d846c.tar.xz
glibc-d1babeb32de5dae8893c640bd925357b218d846c.zip
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  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 4d486ca9b5..0b77a2d897 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -72,8 +72,8 @@ static uint32_t nl_timestamp;
 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;
 }
@@ -309,7 +309,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
   if (cache_valid_p ())
     {
       data = cache;
-      atomic_increment (&cache->usecnt);
+      atomic_fetch_add_relaxed (&cache->usecnt, 1);
     }
   else
     {