[PATCH v2] atomic: Use standard atomic fences for barriers

Wilco Dijkstra Wilco.Dijkstra@arm.com
Fri Oct 3 19:47:49 GMT 2025


v2: do full replacement of barriers

Replace atomic barriers based on sync primitives with atomic_thread_fence.
Many uses appear suspect and in the future fixing these to use load_acquire
or store_release would be useful.

---

diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 1504f8d60621c6df4c09fe3d73d891a55162a32e..125e6d691273f212781411ab76012309e86d7d1e 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -430,7 +430,7 @@ _dl_map_object_deps (struct link_map *map,
 	  memcpy (&l_initfini[1], needed, nneeded * sizeof needed[0]);
 	  memcpy (&l_initfini[nneeded + 1], l_initfini,
 		  nneeded * sizeof needed[0]);
-	  atomic_write_barrier ();
+	  atomic_thread_fence_release ();
 	  l->l_initfini = l_initfini;
 	  l->l_free_initfini = 1;
 	}
@@ -555,12 +555,12 @@ _dl_map_object_deps (struct link_map *map,
 
   /* Terminate the list of dependencies.  */
   l_initfini[nlist] = NULL;
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
   map->l_initfini = l_initfini;
   map->l_free_initfini = 1;
   if (l_reldeps != NULL)
     {
-      atomic_write_barrier ();
+      atomic_thread_fence_release ();
       void *old_l_reldeps = map->l_reldeps;
       map->l_reldeps = l_reldeps;
       _dl_scope_free (old_l_reldeps);
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 2f5cd674f58b816d2f0317fe3aaab4bb8ac163ef..3a9ad47ceae7005f8a1da058afeb961ee831f0ea 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -545,7 +545,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags)
     = atomic_forced_read (undef_map->l_reldeps);
 
   /* Make sure l_reldeps is read before l_initfini.  */
-  atomic_read_barrier ();
+  atomic_thread_fence_acquire ();
 
   /* Determine whether UNDEF_MAP already has a reference to MAP.  First
      look in the normal dependencies.  */
@@ -710,7 +710,7 @@ marking %s [%lu] as NODELETE due to memory allocation failure\n",
 			l_reldepsact * sizeof (struct link_map *));
 	      newp->list[l_reldepsact] = map;
 	      newp->act = l_reldepsact + 1;
-	      atomic_write_barrier ();
+	      atomic_thread_fence_release ();
 	      void *old = undef_map->l_reldeps;
 	      undef_map->l_reldeps = newp;
 	      undef_map->l_reldepsmax = max;
@@ -721,7 +721,7 @@ marking %s [%lu] as NODELETE due to memory allocation failure\n",
       else
 	{
 	  undef_map->l_reldeps->list[l_reldepsact] = map;
-	  atomic_write_barrier ();
+	  atomic_thread_fence_release ();
 	  undef_map->l_reldeps->act = l_reldepsact + 1;
 	}
 
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 5526065352230dbd7f42c86257268f6e6fa5d54e..044f02eeb560478490765517f433dbc93becb7e4 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -201,7 +201,7 @@ add_to_global_update (struct link_map *new)
   assert (added <= ns->_ns_global_scope_pending_adds);
   ns->_ns_global_scope_pending_adds -= added;
 
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
   ns->_ns_main_searchlist->r_nlist = new_nlist;
 }
 
@@ -341,7 +341,7 @@ update_scopes (struct link_map *new)
 	     might use the new last element and then use the garbage
 	     at offset IDX+1.  */
 	  imap->l_scope[cnt + 1] = NULL;
-	  atomic_write_barrier ();
+	  atomic_thread_fence_release ();
 	  imap->l_scope[cnt] = &new->l_searchlist;
 
 	  from_scope = cnt;
diff --git a/include/atomic.h b/include/atomic.h
index a9eb4d740bce204e7745d09ef2e08c1ea834a4c6..a97786565645ca2d95ba1cea42f5e502832ab487 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -102,21 +102,6 @@
 #endif
 
 
-#ifndef atomic_full_barrier
-# define atomic_full_barrier() __asm ("" ::: "memory")
-#endif
-
-
-#ifndef atomic_read_barrier
-# define atomic_read_barrier() atomic_full_barrier ()
-#endif
-
-
-#ifndef atomic_write_barrier
-# define atomic_write_barrier() atomic_full_barrier ()
-#endif
-
-
 #ifndef atomic_forced_read
 # define atomic_forced_read(x) \
   ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; })
@@ -158,12 +143,9 @@ void __atomic_link_error (void);
      __atomic_link_error ();
 # endif
 
-# define atomic_thread_fence_acquire() \
-  __atomic_thread_fence (__ATOMIC_ACQUIRE)
-# define atomic_thread_fence_release() \
-  __atomic_thread_fence (__ATOMIC_RELEASE)
-# define atomic_thread_fence_seq_cst() \
-  __atomic_thread_fence (__ATOMIC_SEQ_CST)
+# define atomic_thread_fence_acquire() __atomic_thread_fence (__ATOMIC_ACQUIRE)
+# define atomic_thread_fence_release() __atomic_thread_fence (__ATOMIC_RELEASE)
+# define atomic_thread_fence_seq_cst() __atomic_thread_fence (__ATOMIC_SEQ_CST)
 
 # define atomic_load_relaxed(mem) \
   ({ __atomic_check_size_ls((mem));					      \
diff --git a/include/list.h b/include/list.h
index 4c68de61a9f9f2cacff059675c01485d392e3c43..4812918b3d4de34727b475ad202e0aa6ee76aaa2 100644
--- a/include/list.h
+++ b/include/list.h
@@ -43,7 +43,7 @@ list_add (list_t *newp, list_t *head)
   newp->next = head->next;
   newp->prev = head;
   head->next->prev = newp;
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
   head->next = newp;
 }
 
diff --git a/malloc/arena.c b/malloc/arena.c
index 4cd79d7244bf62d2a97af2b09241a7d23e73a82a..6eaf6e0857eb84bd77a3f13a1106c28a060b53be 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -103,7 +103,7 @@ static mstate free_list;
    malloc_state objects.
 
    Read access to the next member is supposed to synchronize with the
-   atomic_write_barrier and the write to the next member in
+   atomic_thread_fence_release and the write to the next member in
    _int_new_arena.  This suffers from data races; see the FIXME
    comments in _int_new_arena and reused_arena.
 
@@ -661,7 +661,7 @@ _int_new_arena (size_t size)
   /* FIXME: The barrier is an attempt to synchronize with read access
      in reused_arena, which does not acquire list_lock while
      traversing the list.  */
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
   main_arena.next = a;
 
   __libc_lock_unlock (list_lock);
diff --git a/manual/llio.texi b/manual/llio.texi
index 806ff0a27d5e0f05e861a032a9ed8e820931def4..a429bb5d40c0d53d99788891f3009128dc38da2c 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -2771,14 +2771,14 @@ aiocb64}, since the LFS transparently replaces the old interface.
 @c    deallocate_stack @asulock @ascuheap @aculock @acsmem
 @c     lll_lock (state_cache_lock) @asulock @aculock
 @c     stack_list_del ok
-@c      atomic_write_barrier ok
+@c      atomic_thread_fence_release ok
 @c      list_del ok
-@c      atomic_write_barrier ok
+@c      atomic_thread_fence_release ok
 @c     queue_stack @ascuheap @acsmem
 @c      stack_list_add ok
-@c       atomic_write_barrier ok
+@c       atomic_thread_fence_release ok
 @c       list_add ok
-@c       atomic_write_barrier ok
+@c       atomic_thread_fence_release ok
 @c      free_stacks @ascuheap @acsmem
 @c       list_for_each_prev_safe ok
 @c       list_entry ok
diff --git a/manual/memory.texi b/manual/memory.texi
index 6a70168e616734ecc588094d04300fc8fecbec9b..e69f377a070b1bea692a6fcc7d03336d7eb07d64 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -395,7 +395,7 @@ this function is in @file{stdlib.h}.
 @c     mutex_init ok
 @c     mutex_lock (just-created mutex) ok, returns locked
 @c     mutex_lock (list_lock) dup @asulock @aculock
-@c     atomic_write_barrier ok
+@c     atomic_thread_fence_release ok
 @c     mutex_unlock (list_lock) @aculock
 @c    atomic_fetch_add ok
 @c    reused_arena @asulock @aculock
diff --git a/manual/startup.texi b/manual/startup.texi
index 9545fcc5263f21c8e88dcdb1e1e38b4f69143ce2..320f172b5a37fb2bc2d5b37498ff16df9aa5d0e4 100644
--- a/manual/startup.texi
+++ b/manual/startup.texi
@@ -970,7 +970,7 @@ using @code{atexit} or @code{on_exit}.
 @c     __libc_lock_lock @asulock @aculock
 @c     calloc dup @ascuheap @acsmem
 @c     __libc_lock_unlock @aculock
-@c    atomic_write_barrier dup ok
+@c    atomic_thread_fence_release dup ok
 The @code{atexit} function registers the function @var{function} to be
 called at normal program termination.  The @var{function} is called with
 no arguments.
@@ -984,7 +984,7 @@ the function cannot be registered.
 @safety{@prelim{}@mtsafe{}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{}}}
 @c on_exit @ascuheap @asulock @aculock @acsmem
 @c  new_exitfn dup @ascuheap @asulock @aculock @acsmem
-@c  atomic_write_barrier dup ok
+@c  atomic_thread_fence_release dup ok
 This function is a somewhat more powerful variant of @code{atexit}.  It
 accepts two arguments, a function @var{function} and an arbitrary
 pointer @var{arg}.  At normal program termination, the @var{function} is
diff --git a/nptl/nptl-stack.c b/nptl/nptl-stack.c
index c049c5133c6933748532a6c4c076a7ec8b171ea7..70c3769ebb1a8888598341c1d29fd1af31c50437 100644
--- a/nptl/nptl-stack.c
+++ b/nptl/nptl-stack.c
@@ -28,11 +28,11 @@ __nptl_stack_list_del (list_t *elem)
 {
   GL (dl_in_flight_stack) = (uintptr_t) elem;
 
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
 
   list_del (elem);
 
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
 
   GL (dl_in_flight_stack) = 0;
 }
@@ -43,11 +43,11 @@ __nptl_stack_list_add (list_t *elem, list_t *list)
 {
   GL (dl_in_flight_stack) = (uintptr_t) elem | 1;
 
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
 
   list_add (elem, list);
 
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
 
   GL (dl_in_flight_stack) = 0;
 }
diff --git a/nptl/pthread_mutex_setprioceiling.c b/nptl/pthread_mutex_setprioceiling.c
index a02d1a2c9bea416d4c9d635dd13abbd3b2a7f2b7..4d79c6ea2c205c1f1d7e026d053c2a27f0130b0c 100644
--- a/nptl/pthread_mutex_setprioceiling.c
+++ b/nptl/pthread_mutex_setprioceiling.c
@@ -113,7 +113,7 @@ __pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prioceiling,
     newlock = (mutex->__data.__lock & ~PTHREAD_MUTEX_PRIO_CEILING_MASK);
   mutex->__data.__lock = newlock
 			 | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT);
-  atomic_full_barrier ();
+  atomic_thread_fence_seq_cst ();
 
   futex_wake ((unsigned int *)&mutex->__data.__lock, INT_MAX,
 	      PTHREAD_MUTEX_PSHARED (mutex));
diff --git a/nptl/sem_post.c b/nptl/sem_post.c
index 659e931417e6fc3089511293e954f46395c5297d..44f8bae90afbc1d0a1cba8e5b0b8fa3776d72d17 100644
--- a/nptl/sem_post.c
+++ b/nptl/sem_post.c
@@ -90,7 +90,7 @@ __old_sem_post (sem_t *sem)
 
   /* We must need to synchronize with consumers of this token, so the atomic
      increment must have release MO semantics.  */
-  atomic_write_barrier ();
+  atomic_thread_fence_release ();
   atomic_fetch_add_release (futex, 1);
   /* We always have to assume it is a shared semaphore.  */
   futex_wake (futex, 1, LLL_SHARED);
diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h
index ede7c0ddc46fb82fa92d7abac2d5b208eeafb7d4..3d0be119e9b385f983f376a5b6f4f1d8659e0a24 100644
--- a/sysdeps/aarch64/nptl/tls.h
+++ b/sysdeps/aarch64/nptl/tls.h
@@ -108,7 +108,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h
index 1a323e426c79beebff75d14c92b221d6f1060edd..522e711a624b23358a6c9056e3cc2d4364473aea 100644
--- a/sysdeps/alpha/nptl/tls.h
+++ b/sysdeps/alpha/nptl/tls.h
@@ -105,7 +105,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
index 6b25e8c4bf97210d23fbf8b2a38d94fc2cc5d22d..b2024cf16751eafb311c79667a7fc5bce3328495 100644
--- a/sysdeps/arc/nptl/tls.h
+++ b/sysdeps/arc/nptl/tls.h
@@ -112,7 +112,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/arm/nptl/tls.h b/sysdeps/arm/nptl/tls.h
index 65a5f2d3e8061c2be0732caff5befa246d9169b6..48e5db2177a32444e85802a9d61557f70534832e 100644
--- a/sysdeps/arm/nptl/tls.h
+++ b/sysdeps/arm/nptl/tls.h
@@ -99,7 +99,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
index afce12009bd9b1c40a52bbe7fb1332157c9954a3..a196b2e145f782ca15a63416c1003574fb4baa6b 100644
--- a/sysdeps/csky/nptl/tls.h
+++ b/sysdeps/csky/nptl/tls.h
@@ -127,7 +127,7 @@ typedef struct
   do									      \
     {									      \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	      \
-      atomic_write_barrier ();						      \
+      atomic_thread_fence_release ();					      \
     }									      \
   while (0)
 
diff --git a/sysdeps/generic/malloc-machine.h b/sysdeps/generic/malloc-machine.h
index 1bbe03bf5d780e93d2d8d58c83722674a5b5e3b8..9b5e9b2dd108cfa835e8497072b9b13bf779d6b3 100644
--- a/sysdeps/generic/malloc-machine.h
+++ b/sysdeps/generic/malloc-machine.h
@@ -22,18 +22,6 @@
 
 #include <atomic.h>
 
-#ifndef atomic_full_barrier
-# define atomic_full_barrier() __asm ("" ::: "memory")
-#endif
-
-#ifndef atomic_read_barrier
-# define atomic_read_barrier() atomic_full_barrier ()
-#endif
-
-#ifndef atomic_write_barrier
-# define atomic_write_barrier() atomic_full_barrier ()
-#endif
-
 #ifndef DEFAULT_TOP_PAD
 # define DEFAULT_TOP_PAD 131072
 #endif
diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c
index 843511cc697ff750ba98b39b513302197ca681f6..0c46415bbb753ac688532551db0614b051f01de2 100644
--- a/sysdeps/hppa/dl-fptr.c
+++ b/sysdeps/hppa/dl-fptr.c
@@ -371,7 +371,7 @@ _dl_lookup_address (const void *address)
 
   /* First load the relocation offset.  */
   reloc_arg = (ElfW(Word)) desc[1];
-  atomic_full_barrier();
+  atomic_thread_fence_seq_cst ();
 
   /* Then load first word of candidate descriptor.  It should be a pointer
      with word alignment and point to memory that can be read.  */
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index dd2cf0a050435f00f27fd5534974d2bb7e866c89..cdffa7bff3a387e9e0b632931581f8afe1be9533 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -136,7 +136,7 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
       /* Need to ensure that the gp is visible before the code
          entry point is updated */
       rfdesc[1] = value.gp;
-      atomic_full_barrier();
+      atomic_thread_fence_seq_cst ();
       rfdesc[0] = value.ip;
     }
   else
diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
index b10abbe3993f19898497f5b04b906c07496841fb..ddfa485fca96b31892cbcda429940052818e0037 100644
--- a/sysdeps/hppa/nptl/tls.h
+++ b/sysdeps/hppa/nptl/tls.h
@@ -119,7 +119,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/htl/pt-once.c b/sysdeps/htl/pt-once.c
index 1f999ce4926f3b794d1c4ad2e30b0f01735ceb67..b0719852f99c0ad46e3e779324caa8d38e6e865c 100644
--- a/sysdeps/htl/pt-once.c
+++ b/sysdeps/htl/pt-once.c
@@ -34,7 +34,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
 {
   ASSERT_TYPE_SIZE (pthread_once_t, __SIZEOF_PTHREAD_ONCE_T);
 
-  atomic_full_barrier ();
+  atomic_thread_fence_seq_cst ();
   if (once_control->__run == 0)
     {
       __pthread_spin_wait (&once_control->__lock);
@@ -45,7 +45,7 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
 	  init_routine ();
 	  pthread_cleanup_pop (0);
 
-	  atomic_full_barrier ();
+	  atomic_thread_fence_seq_cst ();
 	  once_control->__run = 1;
 	}
 
diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
index 61acb6145f238b6e04f7ac2a2b2faaf91308ac17..9d16cea0e9c64c1306f68dd1509b8629e63f0916 100644
--- a/sysdeps/loongarch/nptl/tls.h
+++ b/sysdeps/loongarch/nptl/tls.h
@@ -129,7 +129,7 @@ typedef struct
   do \
     { \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
-      atomic_write_barrier (); \
+      atomic_thread_fence_release (); \
     } \
   while (0)
 
diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
index cdf558232e73050267f6581b3858be0309a78944..b3c8bff1816bd281d7328ee1be94ae15d5da09c9 100644
--- a/sysdeps/m68k/nptl/tls.h
+++ b/sysdeps/m68k/nptl/tls.h
@@ -132,7 +132,7 @@ extern void * __m68k_read_tp (void);
   do									\
     {									\
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
-      atomic_write_barrier ();						\
+      atomic_thread_fence_release ();					\
     }									\
   while (0)
 
diff --git a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
index c0624ec72f7dc346dc8e7acd00ef3caeec348519..b59faa8786306a816431fba47c36df5c378990d5 100644
--- a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
+++ b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
@@ -27,7 +27,7 @@
 int
 __pthread_mutex_destroy (pthread_mutex_t *mtxp)
 {
-  atomic_read_barrier ();
+  atomic_thread_fence_acquire ();
   if (*(volatile unsigned int *) &mtxp->__lock != 0)
     return EBUSY;
 
diff --git a/sysdeps/mach/hurd/htl/pt-mutex.h b/sysdeps/mach/hurd/htl/pt-mutex.h
index 1e5e00b1d4c19a6d735046245a0c1c9b5ed63df8..24834bd8dfab257a854ac58a8dedac66bb60b428 100644
--- a/sysdeps/mach/hurd/htl/pt-mutex.h
+++ b/sysdeps/mach/hurd/htl/pt-mutex.h
@@ -54,7 +54,7 @@
           if (ret == EOWNERDEAD)   \
             {   \
               mtxp->__lock = mtxp->__lock | LLL_DEAD_OWNER;   \
-              atomic_write_barrier ();   \
+              atomic_thread_fence_release ();   \
             }   \
         }   \
     }   \
diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h
index 368188481704c027b4a7c7cde7af8febeb2f96ed..c20e3772ca82785c47f19c87dd3efe286e4bd969 100644
--- a/sysdeps/microblaze/nptl/tls.h
+++ b/sysdeps/microblaze/nptl/tls.h
@@ -110,7 +110,7 @@ typedef struct
   do                                                                        \
     {                                                                       \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;            \
-      atomic_write_barrier ();                                              \
+      atomic_thread_fence_release ();                                       \
     }                                                                       \
   while (0)
 
diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
index 77d620e0f1dd820e960d67e6c0be2716ca99e966..018c770b74d423299ead4b2fd98fd1b42d97e034 100644
--- a/sysdeps/mips/nptl/tls.h
+++ b/sysdeps/mips/nptl/tls.h
@@ -159,7 +159,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
index f93fcb893bf3f93f051fc9d1a8927fb7b05bbd1b..a60c12a1551a07426c21de7ccb4f681c94e02085 100644
--- a/sysdeps/or1k/nptl/tls.h
+++ b/sysdeps/or1k/nptl/tls.h
@@ -175,7 +175,7 @@ register tcbhead_t *__thread_self __asm__("r10");
   do									\
     {									\
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	\
-      atomic_write_barrier ();						\
+      atomic_thread_fence_release ();					\
     }									\
   while (0)
 
diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
index 683d5b3960b251c600db8451511fa6bc1d3d3ccd..467068c67165bdca33dfee3d7ddf69984a04165e 100644
--- a/sysdeps/powerpc/nptl/tls.h
+++ b/sysdeps/powerpc/nptl/tls.h
@@ -237,7 +237,7 @@ extern tcbhead_t __tcb attribute_hidden;
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
index 11a1b0897215c8e0dad7588b684870fc69792033..6b44b8cd8bc2e853dd90a95f4d0befdb5dae0aba 100644
--- a/sysdeps/riscv/nptl/tls.h
+++ b/sysdeps/riscv/nptl/tls.h
@@ -123,7 +123,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
index dbdf5f2da40ddd92b220adc9db2a1767e8b7e0ce..d4e96209d7344e873ece6263585ae5e439a83a94 100644
--- a/sysdeps/s390/nptl/tls.h
+++ b/sysdeps/s390/nptl/tls.h
@@ -167,7 +167,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h
index 0eef214daa481ea1f56da87b35ca23d689ef4689..5095a134b62b21579205cc86a2217659e37e647f 100644
--- a/sysdeps/sh/nptl/tls.h
+++ b/sysdeps/sh/nptl/tls.h
@@ -139,7 +139,7 @@ typedef struct
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 
diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
index 0fe5167b7d62098394680a97b7cb1c2818725997..16473ec2bb9baecf7ecd961ccce83a43dc340feb 100644
--- a/sysdeps/sparc/nptl/tls.h
+++ b/sysdeps/sparc/nptl/tls.h
@@ -140,7 +140,7 @@ register struct pthread *__thread_self __asm__("%g7");
   do									     \
     {									     \
       THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
-      atomic_write_barrier ();						     \
+      atomic_thread_fence_release ();					     \
     }									     \
   while (0)
 


More information about the Libc-alpha mailing list