]> granicus.if.org Git - gc/commitdiff
Do not use 'ifndef AO_CLEAR' in mark, pthread_support and gctest
authorIvan Maidanski <ivmai@mail.ru>
Wed, 5 Dec 2018 22:47:19 +0000 (01:47 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 5 Dec 2018 22:48:35 +0000 (01:48 +0300)
(code refactoring of commits 272283d5bd6c7ee31d2178db2b6)

* include/private/gc_priv.h [THREADS && !NN_PLATFORM_CTR
&& !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !AO_HAVE_compiler_barrier]
(AO_HAVE_compiler_barrier): Define private macro (after include
gc_atomic_ops.h).
* mark.c [!BASE_ATOMIC_OPS_EMULATED] (GC_noop6): Call
AO_compiler_barrier() only if AO_HAVE_compiler_barrier.
* pthread_support.c [(USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK)
&& !BASE_ATOMIC_OPS_EMULATED] (GC_pause): Likewise.
* tests/test.c (AO_t): Define only if AO_HAVE_compiler_barrier is not
defined.

include/private/gc_priv.h
mark.c
pthread_support.c
tests/test.c

index 1eb3aa6c1eda634b5096d36e8081cd40ac9c2aa4..3854696035f5364a0883697ff20129610f50197c 100644 (file)
@@ -253,6 +253,9 @@ typedef int GC_bool;
 #if defined(THREADS) && !defined(NN_PLATFORM_CTR) \
     && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
 # include "gc_atomic_ops.h"
+# ifndef AO_HAVE_compiler_barrier
+#   define AO_HAVE_compiler_barrier 1
+# endif
 #endif
 
 #include "gc_locks.h"
diff --git a/mark.c b/mark.c
index 283aa2f1ac16cbfd502ba323329e9c5159d84659..72223bb61f6b85ff1b38a6358320b2c0207d6040 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -40,7 +40,7 @@ void GC_noop6(word arg1 GC_ATTR_UNUSED, word arg2 GC_ATTR_UNUSED,
               word arg5 GC_ATTR_UNUSED, word arg6 GC_ATTR_UNUSED)
 {
   /* Avoid GC_noop6 calls to be optimized away. */
-# if defined(AO_CLEAR) && !defined(BASE_ATOMIC_OPS_EMULATED)
+# if defined(AO_HAVE_compiler_barrier) && !defined(BASE_ATOMIC_OPS_EMULATED)
     AO_compiler_barrier(); /* to serve as a special side-effect */
 # else
     GC_noop1(0);
index 0ebe1b4855f739cb6c6114da9f3d4af6ee8031bf..76dab59f068e07fdfb322d3e0f40ebd076433b87 100644 (file)
@@ -1947,7 +1947,8 @@ STATIC void GC_pause(void)
 
     for (i = 0; i < GC_PAUSE_SPIN_CYCLES; ++i) {
         /* Something that's unlikely to be optimized away. */
-#     if defined(AO_CLEAR) && !defined(BASE_ATOMIC_OPS_EMULATED)
+#     if defined(AO_HAVE_compiler_barrier) \
+         && !defined(BASE_ATOMIC_OPS_EMULATED)
         AO_compiler_barrier();
 #     else
         GC_noop1(i);
index 6164aacadf44e990a31397246d6c2632b9feaccf..69be479ef97d5e630d900b043df38ed39304ee46 100644 (file)
             }
 
 /* Define AO primitives for a single-threaded mode. */
-#ifndef AO_CLEAR
+#ifndef AO_HAVE_compiler_barrier
   /* AO_t not defined. */
 # define AO_t GC_word
 #endif