From: Ivan Maidanski Date: Wed, 5 Dec 2018 22:47:19 +0000 (+0300) Subject: Do not use 'ifndef AO_CLEAR' in mark, pthread_support and gctest X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=014b13c4e434209450366e3501d557a7a17847f9;p=gc Do not use 'ifndef AO_CLEAR' in mark, pthread_support and gctest (code refactoring of commits 272283d5b, d6c7ee31d, 2178db2b6) * 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. --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 1eb3aa6c..38546960 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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 283aa2f1..72223bb6 100644 --- 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); diff --git a/pthread_support.c b/pthread_support.c index 0ebe1b48..76dab59f 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -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); diff --git a/tests/test.c b/tests/test.c index 6164aaca..69be479e 100644 --- a/tests/test.c +++ b/tests/test.c @@ -196,7 +196,7 @@ } /* 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