From 66eabd882fb9545d2d941d5ea21631274d78959e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 7 Dec 2017 00:00:18 +0300 Subject: [PATCH] Fix test_stack failure if AO_PREFER_BUILTIN_ATOMICS (GCC/Aarch64) As of gcc-5.4/aarch64, not all of the built-in double-word atomics are implemented correctly. * src/atomic_ops/sysdeps/gcc/aarch64.h [!__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS] (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): Define (asm-based implementation) even if AO_PREFER_BUILTIN_ATOMICS or AO_THREAD_SANITIZER; update comment. --- src/atomic_ops/sysdeps/gcc/aarch64.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/atomic_ops/sysdeps/gcc/aarch64.h b/src/atomic_ops/sysdeps/gcc/aarch64.h index e63a6a1..f58ad62 100644 --- a/src/atomic_ops/sysdeps/gcc/aarch64.h +++ b/src/atomic_ops/sysdeps/gcc/aarch64.h @@ -36,11 +36,10 @@ # include "../standard_ao_double_t.h" /* As of gcc-5.4, all built-in load/store and CAS atomics for double */ -/* word require -latomic (and are not lock-free), so we use the */ -/* asm-based implementation by default. */ -/* TODO: Update it when GCC has lock-free double-word load/store/CAS. */ -#if !defined(AO_PREFER_BUILTIN_ATOMICS) && !defined(AO_THREAD_SANITIZER) \ - && (!defined(__clang__) || defined(AO_AARCH64_ASM_LOAD_STORE_CAS)) +/* 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) # ifndef AO_PREFER_GENERALIZED AO_INLINE AO_double_t @@ -209,7 +208,7 @@ } # define AO_HAVE_double_compare_and_swap_full -#endif /* !AO_PREFER_BUILTIN_ATOMICS && !__clang__ */ +#endif /* !__clang__ || AO_AARCH64_ASM_LOAD_STORE_CAS */ /* As of clang-5.0 and gcc-5.4, __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 */ /* macro is still missing (while the double-word CAS is available). */ -- 2.50.1