From 3cac03d5a159d0168cc93d7125452f49336e0cf5 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 6 Dec 2018 01:47:19 +0300 Subject: [PATCH] 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. --- include/private/gc_priv.h | 3 +++ mark.c | 2 +- pthread_support.c | 3 ++- tests/test.c | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) 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 61e0a10e..5a55b4cd 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1941,7 +1941,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 f43566e1..ac4679fd 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 -- 2.40.0