From 53b251c9ff03ab59ba58fcddb9dc97c69f25fadc Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Fri, 9 Sep 2022 14:11:23 +0100 Subject: Use C11 atomics instead atomic_add(_zero) Replace atomic_add and atomic_add_zero with atomic_fetch_add_relaxed. Reviewed-by: DJ Delorie --- sysdeps/unix/sysv/linux/check_pf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sysdeps/unix/sysv') diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index fe73fe3ba8..4d486ca9b5 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -278,7 +278,7 @@ make_request (int fd, pid_t pid) { free (result); - atomic_add (&noai6ai_cached.usecnt, 2); + atomic_fetch_add_relaxed (&noai6ai_cached.usecnt, 2); noai6ai_cached.seen_ipv4 = seen_ipv4; noai6ai_cached.seen_ipv6 = seen_ipv6; result = &noai6ai_cached; @@ -349,7 +349,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, *in6ai = data->in6ai; if (olddata != NULL && olddata->usecnt > 0 - && atomic_add_zero (&olddata->usecnt, -1)) + && atomic_fetch_add_relaxed (&olddata->usecnt, -1) == 1) free (olddata); return; @@ -377,7 +377,7 @@ __free_in6ai (struct in6addrinfo *ai) (struct cached_data *) ((char *) ai - offsetof (struct cached_data, in6ai)); - if (atomic_add_zero (&data->usecnt, -1)) + if (atomic_fetch_add_relaxed (&data->usecnt, -1) == 1) { __libc_lock_lock (lock); -- cgit 1.4.1