Fix AO_TS_VAL_t used for __atomic_test_and_set (gcc)
authorIvan Maidanski <ivmai@mail.ru>
Fri, 15 Apr 2016 08:00:44 +0000 (11:00 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 15 Apr 2016 08:00:44 +0000 (11:00 +0300)
* 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.

src/atomic_ops/sysdeps/gcc/aarch64.h
src/atomic_ops/sysdeps/gcc/arm.h
src/atomic_ops/sysdeps/gcc/generic.h
src/atomic_ops/sysdeps/gcc/mips.h
src/atomic_ops/sysdeps/gcc/nios2.h
src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h

index 9a6ef5a..11bc6c5 100644 (file)
@@ -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
index 9e9b701..d4bf028 100644 (file)
@@ -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"
 
 #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.                */
index ffe993d..256a97e 100644 (file)
@@ -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
index 9cfc337..13c7cc7 100644 (file)
@@ -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
index a7f2ef8..5b976be 100644 (file)
@@ -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
index d05f498..606f7ac 100644 (file)
 /*
  * 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