From dcef32a97167a3e60db0112bd56ee9bd2227fb48 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 8 Dec 2017 11:30:40 +0300 Subject: 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. --- src/atomic_ops/sysdeps/gcc/x86.h | 86 ++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 39 deletions(-) (limited to 'src') 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 -# 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 +# 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 */ -- cgit v1.2.1