From: Ivan Maidanski Date: Fri, 26 Oct 2018 18:33:46 +0000 (+0300) Subject: Use GCC atomic primitives for aarch64-ilp32 double-wide operations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02250e756e494898b4ec58ab3debe35a93811460;p=libatomic_ops Use GCC atomic primitives for aarch64-ilp32 double-wide operations Issue #38 (libatomic_ops). Both gcc and clang have correct support of 64-bit atomic primitives on AArch64, so need to use inline assembly. * src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__] (AO_double_load, AO_double_load_acquire, AO_double_store, AO_double_store_release, AO_double_compare_and_swap, AO_double_compare_and_swap_acquire, AO_double_compare_and_swap_release, AO_double_compare_and_swap_full): Do not define if __ILP32__ (unless AO_AARCH64_ASM_LOAD_STORE_CAS). * src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__ || AO_CLANG_PREREQ(3,9)] (AO_GCC_HAVE_double_SYNC_CAS): Do not define if __ILP32__; update gcc version in comment. --- diff --git a/src/atomic_ops/sysdeps/gcc/aarch64.h b/src/atomic_ops/sysdeps/gcc/aarch64.h index 680e21f..bcd2aeb 100644 --- a/src/atomic_ops/sysdeps/gcc/aarch64.h +++ b/src/atomic_ops/sysdeps/gcc/aarch64.h @@ -39,7 +39,8 @@ /* word require -latomic, are not lock-free and cause test_stack */ /* failure, so the asm-based implementation is used for now. */ /* TODO: Update it for newer GCC releases. */ -#if !defined(__clang__) || defined(AO_AARCH64_ASM_LOAD_STORE_CAS) +#if (!defined(__ILP32__) && !defined(__clang__)) \ + || defined(AO_AARCH64_ASM_LOAD_STORE_CAS) # ifndef AO_PREFER_GENERALIZED AO_INLINE AO_double_t @@ -260,11 +261,13 @@ } # define AO_HAVE_double_compare_and_swap_full -#endif /* !__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS */ +#endif /* !__ILP32__ && !__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS */ -/* As of clang-5.0 and gcc-5.4, __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 */ +/* As of clang-5.0 and gcc-8.1, __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 */ /* macro is still missing (while the double-word CAS is available). */ -# define AO_GCC_HAVE_double_SYNC_CAS +# ifndef __ILP32__ +# define AO_GCC_HAVE_double_SYNC_CAS +# endif #endif /* !__clang__ || AO_CLANG_PREREQ(3, 9) */