summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-12-08 11:30:40 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-12-22 10:45:04 +0300
commitdcef32a97167a3e60db0112bd56ee9bd2227fb48 (patch)
tree15952c462c883bcacbeb218eeb35389e3fa09d25 /src
parent66eabd882fb9545d2d941d5ea21631274d78959e (diff)
downloadlibatomic_ops-dcef32a97167a3e60db0112bd56ee9bd2227fb48.tar.gz
Simplify '#if' expressions in gcc/x86.h
(code refactoring) * src/atomic_ops/sysdeps/gcc/x86.h [AO_GCC_ATOMIC_TEST_AND_SET] (AO_SKIPATOMIC_double_compare_and_swap_ANY, AO_SKIPATOMIC_double_load, AO_SKIPATOMIC_double_load_acquire, AO_SKIPATOMIC_double_store, AO_SKIPATOMIC_double_store_release): Simplify "#if" condition expressions.
Diffstat (limited to 'src')
-rw-r--r--src/atomic_ops/sysdeps/gcc/x86.h86
1 files changed, 47 insertions, 39 deletions
diff --git a/src/atomic_ops/sysdeps/gcc/x86.h b/src/atomic_ops/sysdeps/gcc/x86.h
index f1e927f..7a7c689 100644
--- a/src/atomic_ops/sysdeps/gcc/x86.h
+++ b/src/atomic_ops/sysdeps/gcc/x86.h
@@ -21,50 +21,58 @@
&& !defined(AO_DISABLE_GCC_ATOMICS)
# define AO_GCC_ATOMIC_TEST_AND_SET
-/* TODO: Refine for newer clang releases. */
-# if defined(__clang__) \
- && (!(defined(__x86_64__) || defined(__APPLE_CC__) \
- || defined(__CYGWIN__) || defined(AO_PREFER_BUILTIN_ATOMICS)) \
- || (defined(__x86_64__) && !defined(__ILP32__) \
- && (!(AO_CLANG_PREREQ(3, 5) \
- || defined(AO_PREFER_BUILTIN_ATOMICS)) \
- || defined(AO_ADDRESS_SANITIZER) \
- || defined(AO_THREAD_SANITIZER))))
- /* As of clang-3.8 i686 (NDK r11c), it requires -latomic for all */
- /* the double-wide operations. Same for clang-3.4/x64. For now, */
- /* we fall back to the non-intrinsic implementation by default. */
- /* As of clang-4.0, double-wide arguments are incorrectly passed to */
- /* atomic intrinsic operations for x64 target if ASan/TSan enabled. */
-# define AO_SKIPATOMIC_double_compare_and_swap_ANY
-# define AO_SKIPATOMIC_double_load
-# define AO_SKIPATOMIC_double_load_acquire
-# define AO_SKIPATOMIC_double_store
-# define AO_SKIPATOMIC_double_store_release
-# elif defined(__APPLE_CC__) && defined(__x86_64__)
- /* As of Apple clang-600 (based on LLVM 3.5svn), it has some bug in */
- /* double-wide CAS implementation for x64 target. */
-# define AO_SKIPATOMIC_double_compare_and_swap_ANY
-# endif
-
# if defined(__APPLE_CC__)
/* OS X 10.7 clang-425 lacks __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n */
/* predefined macro (unlike e.g. OS X 10.11 clang-703). */
# define AO_GCC_FORCE_HAVE_CAS
-# endif
-# if !defined(__x86_64__) && defined(__APPLE__) && defined(__MACH__)
- /* OS X 10.8 lacks __atomic_load/store symbols for arch i386 (even */
- /* with non-Apple clang). */
-# ifndef MAC_OS_X_VERSION_MIN_REQUIRED
- /* Include this header just to import the version macro. */
-# include <AvailabilityMacros.h>
-# endif
-# if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 /* MAC_OS_X_VERSION_10_9 */
-# define AO_SKIPATOMIC_double_load
-# define AO_SKIPATOMIC_double_load_acquire
-# define AO_SKIPATOMIC_double_store
-# define AO_SKIPATOMIC_double_store_release
-# endif
+# ifdef __x86_64__
+ /* As of Apple clang-600 (based on LLVM 3.5svn), it has some bug */
+ /* in the double-wide CAS implementation for x64 target. */
+ /* TODO: Refine for newer Apple clang releases. */
+# define AO_SKIPATOMIC_double_compare_and_swap_ANY
+
+# elif defined(__MACH__)
+ /* OS X 10.8 lacks __atomic_load/store symbols for arch i386 */
+ /* (even with a non-Apple clang). */
+# ifndef MAC_OS_X_VERSION_MIN_REQUIRED
+ /* Include this header just to import the version macro. */
+# include <AvailabilityMacros.h>
+# endif
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 /* MAC_OS_X_VERSION_10_9 */
+# define AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY
+# endif
+# endif /* __i386__ */
+
+# elif defined(__clang__)
+# if !defined(__x86_64__)
+# if !defined(AO_PREFER_BUILTIN_ATOMICS) && !defined(__CYGWIN__)
+ /* As of clang-3.8/i686 (NDK r11c), it requires -latomic for */
+ /* all the double-wide operations. For now, we fall back to */
+ /* the non-intrinsic implementation by default. */
+ /* TODO: Refine for newer clang releases. */
+# define AO_SKIPATOMIC_double_compare_and_swap_ANY
+# define AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY
+# endif /* !AO_PREFER_BUILTIN_ATOMICS */
+
+# elif !defined(__ILP32__)
+# if (!AO_CLANG_PREREQ(3, 5) && !defined(AO_PREFER_BUILTIN_ATOMICS)) \
+ || defined(AO_ADDRESS_SANITIZER) || defined(AO_THREAD_SANITIZER)
+ /* Same as above but for clang-3.4/x64. As of clang-4.0, */
+ /* double-wide arguments are incorrectly passed to atomic */
+ /* intrinsic operations for x64 target if ASan/TSan enabled. */
+# define AO_SKIPATOMIC_double_compare_and_swap_ANY
+# define AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY
+# endif
+# endif /* __x86_64__ */
+# endif /* __clang__ */
+
+# ifdef AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY
+# define AO_SKIPATOMIC_double_load
+# define AO_SKIPATOMIC_double_load_acquire
+# define AO_SKIPATOMIC_double_store
+# define AO_SKIPATOMIC_double_store_release
+# undef AO_SKIPATOMIC_DOUBLE_LOAD_STORE_ANY
# endif
#else /* AO_DISABLE_GCC_ATOMICS */