Remove some redundant macro definitions from gc_atomic_ops.h
authorIvan Maidanski <ivmai@mail.ru>
Wed, 29 Nov 2017 07:47:33 +0000 (10:47 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 29 Nov 2017 08:16:09 +0000 (11:16 +0300)
(fix commit 46a2411)

* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC] (AO_HAVE_load,
AO_HAVE_store, AO_HAVE_store_release_write): Remove.
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && AO_REQUIRE_CAS]
(AO_HAVE_compare_and_swap): Likewise.
* include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Add comment.
* include/private/gc_priv.h (word_ptr_ao_u): Replace
"ifdef AO_HAVE_load" to "ifdef PARALLEL_MARK".
* tests/test_atomic_ops.c [AO_HAVE_compare_and_swap_release] (main):
Do not check whether AO_REQUIRE_CAS and AO_HAVE_compare_and_swap are
defined.
* typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]
(include gc_atomic_ops.h): Do not check whether AO_HAVE_load_acquire
is defined.

include/private/gc_atomic_ops.h
include/private/gc_priv.h
tests/test_atomic_ops.c
typd_mlc.c

index adb131a..5506dea 100644 (file)
 # define AO_HAVE_or
 
 # define AO_load(p) __atomic_load_n(p, __ATOMIC_RELAXED)
-# define AO_HAVE_load
 # define AO_load_acquire(p) __atomic_load_n(p, __ATOMIC_ACQUIRE)
 # define AO_HAVE_load_acquire
 # define AO_load_acquire_read(p) AO_load_acquire(p)
 # define AO_HAVE_load_acquire_read
 
 # define AO_store(p, v) __atomic_store_n(p, v, __ATOMIC_RELAXED)
-# define AO_HAVE_store
 # define AO_store_release(p, v) __atomic_store_n(p, v, __ATOMIC_RELEASE)
 # define AO_HAVE_store_release
 # define AO_store_release_write(p, v) AO_store_release(p, v)
-# define AO_HAVE_store_release_write
 
 # ifdef AO_REQUIRE_CAS
     AO_INLINE int
@@ -76,7 +73,6 @@
       return (int)__atomic_compare_exchange_n(p, &ov, nv, 0,
                                         __ATOMIC_RELAXED, __ATOMIC_RELAXED);
     }
-#   define AO_HAVE_compare_and_swap
 
     AO_INLINE int
     AO_compare_and_swap_release(volatile AO_t *p, AO_t ov, AO_t nv)
 #else
   /* Fallback to libatomic_ops. */
 # include "atomic_ops.h"
+
+  /* AO_compiler_barrier, AO_load and AO_store should be defined for    */
+  /* all targets; the rest of the primitives are guaranteed to exist    */
+  /* only if AO_REQUIRE_CAS is defined (or if the corresponding         */
+  /* AO_HAVE_x macro is defined).  x86/x64 targets have AO_nop_full,    */
+  /* AO_load_acquire, AO_store_release, at least.                       */
 #endif /* !GC_BUILTIN_ATOMIC */
 
 #endif /* GC_ATOMIC_OPS_H */
index 0e7d2b6..8a47bec 100644 (file)
@@ -963,7 +963,7 @@ union word_ptr_ao_u {
   word w;
   signed_word sw;
   void *vp;
-# ifdef AO_HAVE_load
+# ifdef PARALLEL_MARK
     volatile AO_t ao;
 # endif
 };
index 18ec19e..c99da72 100644 (file)
@@ -59,8 +59,7 @@
       TA_assert(AO_fetch_and_add(&x, (AO_t)(-43)) == 55);
       TA_assert(AO_fetch_and_add1(&x) == 12);
 #   endif
-#   if defined(AO_REQUIRE_CAS) && defined(AO_HAVE_compare_and_swap) \
-       && defined(AO_HAVE_compare_and_swap_release)
+#   ifdef AO_HAVE_compare_and_swap_release
       TA_assert(!AO_compare_and_swap(&x, 14, 42));
       TA_assert(x == 13);
       TA_assert(AO_compare_and_swap_release(&x, 13, 42));
index da2ca27..501e161 100644 (file)
@@ -99,8 +99,7 @@ STATIC size_t GC_avail_descr = 0;       /* Next available slot.         */
 STATIC int GC_typed_mark_proc_index = 0; /* Indices of my mark          */
 STATIC int GC_array_mark_proc_index = 0; /* procedures.                 */
 
-#if !defined(AO_HAVE_load_acquire) \
-    && (defined(GC_FORCE_INCLUDE_ATOMIC_OPS) || defined(GC_BUILTIN_ATOMIC))
+#if defined(GC_FORCE_INCLUDE_ATOMIC_OPS) || defined(GC_BUILTIN_ATOMIC)
 # include "private/gc_atomic_ops.h"
 #endif