From a364a3a7090b82ddd30e9209df2af56e781d51e4 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Fri, 9 Sep 2022 14:22:26 +0100 Subject: Use C11 atomics instead of atomic_decrement(_val) Replace atomic_decrement and atomic_decrement_val with atomic_fetch_add_relaxed. Reviewed-by: DJ Delorie --- nscd/nscd_netgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nscd/nscd_netgroup.c') 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; } -- cgit 1.4.1