about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2022-09-09 14:22:26 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2022-09-09 14:22:26 +0100
commita364a3a7090b82ddd30e9209df2af56e781d51e4 (patch)
tree90412a565deeeb7aef54205159c0422af71771c9 /nscd
parent53b251c9ff03ab59ba58fcddb9dc97c69f25fadc (diff)
downloadglibc-a364a3a7090b82ddd30e9209df2af56e781d51e4.tar.gz
glibc-a364a3a7090b82ddd30e9209df2af56e781d51e4.tar.xz
glibc-a364a3a7090b82ddd30e9209df2af56e781d51e4.zip
Use C11 atomics instead of atomic_decrement(_val)
Replace atomic_decrement and atomic_decrement_val with
atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd-client.h2
-rw-r--r--nscd/nscd_getai.c2
-rw-r--r--nscd/nscd_getgr_r.c2
-rw-r--r--nscd/nscd_gethst_r.c2
-rw-r--r--nscd/nscd_getpw_r.c2
-rw-r--r--nscd/nscd_getserv_r.c2
-rw-r--r--nscd/nscd_helper.c2
-rw-r--r--nscd/nscd_initgroups.c2
-rw-r--r--nscd/nscd_netgroup.c4
9 files changed, 10 insertions, 10 deletions
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index fee2a15dcc..ca9e6def1a 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -421,7 +421,7 @@ __nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle)
 	  return -1;
 	}
 
-      if (atomic_decrement_val (&map->counter) == 0)
+      if (atomic_fetch_add_relaxed (&map->counter, -1) == 1)
 	__nscd_unmap (map);
     }
 
diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c
index a99a4d8142..8e4650ebae 100644
--- a/nscd/nscd_getai.c
+++ b/nscd/nscd_getai.c
@@ -198,7 +198,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index 3636c031ec..bde3b588a0 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -312,7 +312,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 9becb62033..31d13580a1 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -440,7 +440,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index 20986f4433..82fdd17d8c 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -225,7 +225,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
index 42b875d024..de843b3363 100644
--- a/nscd/nscd_getserv_r.c
+++ b/nscd/nscd_getserv_r.c
@@ -365,7 +365,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index 8e66fa2548..0651817a99 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -390,7 +390,7 @@ __nscd_get_mapping (request_type type, const char *key,
   struct mapped_database *oldval = *mappedp;
   *mappedp = result;
 
-  if (oldval != NULL && atomic_decrement_val (&oldval->counter) == 0)
+  if (oldval != NULL && atomic_fetch_add_relaxed (&oldval->counter, -1) == 1)
     __nscd_unmap (oldval);
 
   return result;
diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c
index dfce76a060..47b6deb069 100644
--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -166,7 +166,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c
index 7e51dd3d94..11b7f3214c 100644
--- a/nscd/nscd_netgroup.c
+++ b/nscd/nscd_netgroup.c
@@ -148,7 +148,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}
@@ -272,7 +272,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user,
       if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1)
 	{
 	  /* nscd is just running gc now.  Disable using the mapping.  */
-	  if (atomic_decrement_val (&mapped->counter) == 0)
+	  if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1)
 	    __nscd_unmap (mapped);
 	  mapped = NO_MAPPING;
 	}