]> granicus.if.org Git - libatomic_ops/commitdiff
Use GCC atomic primitives for aarch64-ilp32 double-wide operations
authorIvan Maidanski <ivmai@mail.ru>
Fri, 26 Oct 2018 18:33:46 +0000 (21:33 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 29 Oct 2018 05:12:51 +0000 (08:12 +0300)
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.

src/atomic_ops/sysdeps/gcc/aarch64.h

index 680e21fdfa0012ef98637a0616abbdeb099c3eb2..bcd2aeb1616af7e6675479e586db9e2bc56a9f21 100644 (file)
@@ -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
   }
 # 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) */