[PATCH 00/22] Cleanup internal atomic definitions
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Sep 11 15:51:30 GMT 2025
Hi Uros,
> A patch, following removals of unused target atomic macros could
> remove #undefs from <include/atomic.h>:
>
> # undef atomic_compare_and_exchange_val_acq
> # undef atomic_compare_and_exchange_val_rel
> # undef atomic_compare_and_exchange_bool_acq
Yes, also the #undefs for atomic_*_barrier should be removable now.
> Also, I wonder what is the purpose of:
>
> # define atomic_forced_read(x) \
> ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; })
>
> This is *not* a scheduling barrier to prevent the compiler from
> reordering memory accesses (let alone the CPU), because it lacks
> "memory" clobber and/or volatile qualifier. To guarantee read to a
> register, this asm should use "memory" clobber, or it should be
> redefined to use atomic_load_acquire().
It's often redundant, mostly a relaxed load and a few cases load acquire
in combination with badly written barriers (dl-lookup.c). It's literally
unbelievable how such broken code still works most of the time...
See https://sourceware.org/pipermail/libc-alpha/2022-July/140844.html
Cheers,
Wilco
More information about the Libc-alpha
mailing list