[PATCH] atomic: Use standard atomic fences for barriers
Uros Bizjak
ubizjak@gmail.com
Thu Sep 11 14:50:06 GMT 2025
On 11. 09. 25 11:07, Wilco Dijkstra wrote:
>
> Use standard atomic fences for the barriers.
>
> Passes buildmanyglibc, OK for commit?
>
> ---
>
> diff --git a/include/atomic.h b/include/atomic.h
> index ac04e135a7187d049e3291cb64c32510215366bf..88c03d1d049090128c34a0fee510375ec7c032c1 100644
> --- a/include/atomic.h
> +++ b/include/atomic.h
> @@ -83,19 +83,14 @@
> #endif
>
>
> -#ifndef atomic_full_barrier
> -# define atomic_full_barrier() __asm ("" ::: "memory")
> -#endif
> -
> +#undef atomic_full_barrier
> +#define atomic_full_barrier() __atomic_thread_fence (__ATOMIC_SEQ_CST)
Maybe you should use atomic_thread_fence_seq_cst() here to be consistent
with e.g. atomic_compare_and_exchange_val_acq(), which uses
atomic_compare_exchange_acquire()...
> -#ifndef atomic_read_barrier
> -# define atomic_read_barrier() atomic_full_barrier ()
> -#endif
> +#undef atomic_read_barrier
> +#define atomic_read_barrier() __atomic_thread_fence (__ATOMIC_ACQUIRE)
>
> -
> -#ifndef atomic_write_barrier
> -# define atomic_write_barrier() atomic_full_barrier ()
> -#endif
> +#undef atomic_write_barrier
> +#define atomic_write_barrier() __atomic_thread_fence (__ATOMIC_RELEASE)
... and similar apporach fot the two above macros.
Uros.
More information about the Libc-alpha
mailing list