summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-04-15 11:00:44 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-04-15 11:00:44 +0300
commited76ab0f2428478560d57284359c56ba3b33f2f7 (patch)
tree332dfdfa6096b85d4ec0dff222bad54832808ade
parentda949bb42a6b4934610762a6002b2ffc740ed3e0 (diff)
downloadlibatomic_ops-ed76ab0f2428478560d57284359c56ba3b33f2f7.tar.gz
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.
-rw-r--r--src/atomic_ops/sysdeps/gcc/aarch64.h3
-rw-r--r--src/atomic_ops/sysdeps/gcc/arm.h4
-rw-r--r--src/atomic_ops/sysdeps/gcc/generic.h3
-rw-r--r--src/atomic_ops/sysdeps/gcc/mips.h3
-rw-r--r--src/atomic_ops/sysdeps/gcc/nios2.h3
-rw-r--r--src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h13
6 files changed, 8 insertions, 21 deletions
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