(part of commit
0f9ef2d from Unity-Technologies/bdwgc)
Issue #173 (bdwgc).
* include/gc.h [GC_BUILD && NN_PLATFORM_CTR] (GC_on_thread_event_proc):
Define type.
* include/private/gc_locks.h [NN_PLATFORM_CTR || NINTENDO_SWITCH]
(GC_lock, GC_unlock): Declare function.
* include/private/gc_locks.h [NN_PLATFORM_CTR || NINTENDO_SWITCH]
(UNCOND_LOCK, UNCOND_UNLOCK): Define macro.
* include/private/gc_priv.h [THREADS && !SN_TARGET_ORBIS
&& !SN_TARGET_PSP2]: Do not include gc_atomic_ops.h if NN_PLATFORM_CTR.
* pthread_support.c [USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK] (GC_pause):
Call GC_noop1 instead of AO_compiler_barrier unless AO_CLEAR defined.
/* Both the supplied setter and the getter */
/* acquire the GC lock (to avoid data races). */
-#ifdef GC_THREADS
+#if defined(GC_THREADS) || (defined(GC_BUILD) && defined(NN_PLATFORM_CTR))
typedef void (GC_CALLBACK * GC_on_thread_event_proc)(GC_EventType,
void * /* thread_id */);
/* Invoked when a thread is suspended or */
# endif
# define UNCOND_LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
# define UNCOND_UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
+# elif defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH)
+ extern void GC_lock(void);
+ extern void GC_unlock(void);
+# define UNCOND_LOCK() GC_lock()
+# define UNCOND_UNLOCK() GC_unlock()
# endif
# if (!defined(AO_HAVE_test_and_set_acquire) || defined(GC_RTEMS_PTHREADS) \
# define GC_API_PRIV GC_API
#endif
-#if defined(THREADS) && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
+#if defined(THREADS) && !defined(NN_PLATFORM_CTR) \
+ && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
# include "gc_atomic_ops.h"
#endif
for (i = 0; i < GC_PAUSE_SPIN_CYCLES; ++i) {
/* Something that's unlikely to be optimized away. */
+# ifdef AO_CLEAR
AO_compiler_barrier();
+# else
+ GC_noop1(i);
+# endif
}
}
#endif