]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use C11 atomics instead atomic_add(_zero)
authorWilco Dijkstra <wdijkstr@arm.com>
Fri, 9 Sep 2022 13:11:23 +0000 (14:11 +0100)
committerWilco Dijkstra <wdijkstr@arm.com>
Fri, 9 Sep 2022 13:11:23 +0000 (14:11 +0100)
Replace atomic_add and atomic_add_zero with atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
malloc/malloc.c
sysdeps/unix/sysv/linux/check_pf.c

index ecec901b14f602e3c93da1a847f043ffee41a1f4..aea4993f1b9a6f14d2694da737bd7d89e07385a3 100644 (file)
@@ -3034,7 +3034,7 @@ munmap_chunk (mchunkptr p)
     malloc_printerr ("munmap_chunk(): invalid pointer");
 
   atomic_decrement (&mp_.n_mmaps);
-  atomic_add (&mp_.mmapped_mem, -total_size);
+  atomic_fetch_add_relaxed (&mp_.mmapped_mem, -total_size);
 
   /* If munmap failed the process virtual memory address space is in a
      bad shape.  Just leave the block hanging around, the process will
index fe73fe3ba84db02b1d7188de8f29d55019a69ff3..4d486ca9b5026c7a7950bd7c7155212966df3c44 100644 (file)
@@ -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);