[LTP] [PATCH v3 1/3] tst_atomic: drop legacy inline assembly and use __atomic or __sync builtins

Petr Vorel pvorel@suse.cz
Fri Jun 6 16:39:36 CEST 2025


Hi Li, Cyril,

> Refactor tst_atomic.h to remove all legacy architecture-specific inline
> assembly and fallback code paths. The new implementation supports only
> two well-defined interfaces: __atomic_* built-ins (GCC ≥ 4.7) and __sync_*
> built-ins (GCC ≥ 4.1).

> This simplification improves maintainability, clarity, and portability
> across platforms.

> The memory order is explicitly set to __ATOMIC_SEQ_CST to preserve strict
> sequential consistency, which aligns with the C++11 memory model.

> Reference: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
+1

Thanks for the work!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

> Signed-off-by: Li Wang <liwang@redhat.com>
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>

> +
> +/* Use __atomic built-ins (GCC >= 4.7), with sequential consistency. */

+1 for documenting this. Hopefully these are old enough to not having to mention
it in the docs. But if you think it's not that old, it might be worth later to
document it in doc/users/supported_systems.rst.
https://linux-test-project.readthedocs.io/en/latest/users/supported_systems.html

In that case minimal clang version should be noted as well.

BTW I tried to search, should it be clang 3.5?
I tried to search but not found.
https://clang.llvm.org/docs/LanguageExtensions.html#c11-atomic-builtins

Kind regards,
Petr

> +# error "Your compiler does not support atomic operations (__atomic or __sync)"
>  #endif


More information about the ltp mailing list