From: Ivan Maidanski Date: Fri, 15 Apr 2016 08:00:44 +0000 (+0300) Subject: Fix AO_TS_VAL_t used for __atomic_test_and_set (gcc) X-Git-Tag: v7.6.0~218 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed76ab0f2428478560d57284359c56ba3b33f2f7;p=libatomic_ops Fix AO_TS_VAL_t used for __atomic_test_and_set (gcc) * src/atomic_ops/sysdeps/gcc/aarch64.h (AO_GCC_ATOMIC_TEST_AND_SET): Remove. * src/atomic_ops/sysdeps/gcc/mips.h [!AO_DISABLE_GCC_ATOMICS] (AO_GCC_ATOMIC_TEST_AND_SET): Likewise. * src/atomic_ops/sysdeps/gcc/nios2.h (AO_GCC_ATOMIC_TEST_AND_SET): Likewise. * src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h (AO_TS_SET_TRUEVAL): Likewise. * src/atomic_ops/sysdeps/gcc/aarch64.h: Remove include test_and_set_t_is_ao_t.h file. * src/atomic_ops/sysdeps/gcc/mips.h [!AO_DISABLE_GCC_ATOMICS]: Likewise. * src/atomic_ops/sysdeps/gcc/nios2.h: Likewise. * src/atomic_ops/sysdeps/gcc/arm.h: Include test_and_set_t_is_ao_t.h only if not AO_GCC_ATOMIC_TEST_AND_SET. * src/atomic_ops/sysdeps/gcc/generic.h (AO_GCC_ATOMIC_TEST_AND_SET): Define macro. * src/atomic_ops/sysdeps/gcc/generic.h: Include test_and_set_t_is_char.h file. * src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h (AO_TS_val): Define AO_TS_set to 1; update comment. --- diff --git a/src/atomic_ops/sysdeps/gcc/aarch64.h b/src/atomic_ops/sysdeps/gcc/aarch64.h index 9a6ef5a..11bc6c5 100644 --- a/src/atomic_ops/sysdeps/gcc/aarch64.h +++ b/src/atomic_ops/sysdeps/gcc/aarch64.h @@ -15,9 +15,6 @@ * */ -#define AO_GCC_ATOMIC_TEST_AND_SET -#include "../test_and_set_t_is_ao_t.h" - #include "../standard_ao_double_t.h" #ifdef AO_PREFER_BUILTIN_ATOMICS diff --git a/src/atomic_ops/sysdeps/gcc/arm.h b/src/atomic_ops/sysdeps/gcc/arm.h index 9e9b701..d4bf028 100644 --- a/src/atomic_ops/sysdeps/gcc/arm.h +++ b/src/atomic_ops/sysdeps/gcc/arm.h @@ -25,8 +25,6 @@ # define AO_GCC_ATOMIC_TEST_AND_SET #endif -#include "../test_and_set_t_is_ao_t.h" /* Probably suboptimal */ - #ifdef __native_client__ /* Mask instruction should immediately precede access instruction. */ # define AO_MASK_PTR(reg) " bical " reg ", " reg ", #0xc0000000\n" @@ -281,6 +279,8 @@ #ifndef AO_GCC_ATOMIC_TEST_AND_SET +# include "../test_and_set_t_is_ao_t.h" /* Probably suboptimal */ + #ifdef AO_ARM_HAVE_LDREX /* AO_t/char/short/int load is simple reading. */ diff --git a/src/atomic_ops/sysdeps/gcc/generic.h b/src/atomic_ops/sysdeps/gcc/generic.h index ffe993d..256a97e 100644 --- a/src/atomic_ops/sysdeps/gcc/generic.h +++ b/src/atomic_ops/sysdeps/gcc/generic.h @@ -19,6 +19,9 @@ /* For the details, see GNU Manual, chapter 6.52 (Built-in functions */ /* for memory model aware atomic operations). */ +#define AO_GCC_ATOMIC_TEST_AND_SET +#include "../test_and_set_t_is_char.h" + #if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) \ || defined(AO_GCC_FORCE_HAVE_CAS) # define AO_GCC_HAVE_char_SYNC_CAS diff --git a/src/atomic_ops/sysdeps/gcc/mips.h b/src/atomic_ops/sysdeps/gcc/mips.h index 9cfc337..13c7cc7 100644 --- a/src/atomic_ops/sysdeps/gcc/mips.h +++ b/src/atomic_ops/sysdeps/gcc/mips.h @@ -35,9 +35,6 @@ && !defined(AO_DISABLE_GCC_ATOMICS) /* Probably, it could be enabled even for earlier gcc/clang versions. */ -# define AO_GCC_ATOMIC_TEST_AND_SET -# include "../test_and_set_t_is_ao_t.h" - /* As of clang-3.6/mips[64], __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n missing. */ # if defined(__clang__) # define AO_GCC_FORCE_HAVE_CAS diff --git a/src/atomic_ops/sysdeps/gcc/nios2.h b/src/atomic_ops/sysdeps/gcc/nios2.h index a7f2ef8..5b976be 100644 --- a/src/atomic_ops/sysdeps/gcc/nios2.h +++ b/src/atomic_ops/sysdeps/gcc/nios2.h @@ -11,9 +11,6 @@ * modified is included with the above copyright notice. */ -#define AO_GCC_ATOMIC_TEST_AND_SET -#include "../test_and_set_t_is_ao_t.h" - #include "generic.h" #define AO_T_IS_INT diff --git a/src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h b/src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h index d05f498..606f7ac 100644 --- a/src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h +++ b/src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h @@ -23,17 +23,10 @@ /* * These are common definitions for architectures on which test_and_set * operates on pointer-sized quantities, the "clear" value contains - * all zeroes, and the "set" value contains only one lowest bit set typically. + * all zeroes, and the "set" value contains only one lowest bit set. + * This can be used if test_and_set is synthesized from compare_and_swap. */ - -#if defined(AO_GCC_ATOMIC_TEST_AND_SET) && !defined(AO_PREFER_GENERALIZED) \ - && defined(__GCC_ATOMIC_TEST_AND_SET_TRUEVAL) -# define AO_TS_SET_TRUEVAL __GCC_ATOMIC_TEST_AND_SET_TRUEVAL -#else -# define AO_TS_SET_TRUEVAL 1 -#endif - -typedef enum { AO_TS_clear = 0, AO_TS_set = AO_TS_SET_TRUEVAL } AO_TS_val; +typedef enum {AO_TS_clear = 0, AO_TS_set = 1} AO_TS_val; #define AO_TS_VAL_t AO_TS_val #define AO_TS_CLEAR AO_TS_clear #define AO_TS_SET AO_TS_set