Fix test failures for Clang-3.8 and older (Aarch64)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 6 Dec 2017 08:42:35 +0000 (11:42 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 22 Dec 2017 07:44:43 +0000 (10:44 +0300)
For older Clang/aarch64 releases, double-wide atomics are no longer
supported.

* src/atomic_ops/sysdeps/gcc/aarch64.h [__clang__
&& !AO_CLANG_PREREQ(3, 9)]: Do not include standard_ao_double_t.h file;
add comment.
* src/atomic_ops/sysdeps/gcc/aarch64.h [__clang__
&& !AO_CLANG_PREREQ(3, 8)] (AO_SKIPATOMIC_double_load,
AO_SKIPATOMIC_double_load_acquire): Do not define and do not undefine
(since generic.h is included only for GCC and for Clang v3.9+).
* src/atomic_ops/sysdeps/gcc/aarch64.h [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): Do not define if __clang__
&& !AO_CLANG_PREREQ(3, 9).
* src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_HAVE_double_SYNC_CAS):
Likewise.

src/atomic_ops/sysdeps/gcc/aarch64.h

index 6f1d5d8..e63a6a1 100644 (file)
@@ -15,8 +15,6 @@
  *
  */
 
-#include "../standard_ao_double_t.h"
-
 /* As of clang-5.0 (and gcc-5.4), __atomic_thread_fence is always       */
 /* translated to DMB (which is inefficient for AO_nop_write).           */
 /* TODO: Update it for newer Clang and GCC releases. */
 # define AO_HAVE_nop_write
 #endif
 
-/* Atomics for loading double word in Clang were translated to an       */
-/* incorrect code lacking STXP (see the note in AO_double_load below).  */
-#if defined(AO_PREFER_BUILTIN_ATOMICS) \
-    && defined(__clang__) && !AO_CLANG_PREREQ(3, 8)
-# define AO_SKIPATOMIC_double_load
-# define AO_SKIPATOMIC_double_load_acquire
-#endif
+/* There were some bugs in the older clang releases (related to         */
+/* optimization of functions dealing with __int128 values, supposedly), */
+/* so even asm-based implementation did not work correctly.             */
+#if !defined(__clang__) || AO_CLANG_PREREQ(3, 9)
+
+# 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         */
 /* macro is still missing (while the double-word CAS is available).     */
 # define AO_GCC_HAVE_double_SYNC_CAS
 
+#endif /* !__clang__ || AO_CLANG_PREREQ(3, 9) */
+
 #if (defined(__clang__) && !AO_CLANG_PREREQ(3, 8)) || defined(__APPLE_CC__)
   /* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros are missing.     */
 # define AO_GCC_FORCE_HAVE_CAS
 
 #undef AO_GCC_FORCE_HAVE_CAS
 #undef AO_GCC_HAVE_double_SYNC_CAS
-#undef AO_SKIPATOMIC_double_load
-#undef AO_SKIPATOMIC_double_load_acquire