Fix the build for N3DS
authorJosh Peterson <petersonjm1@gmail.com>
Wed, 1 Aug 2018 20:53:06 +0000 (23:53 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 1 Aug 2018 20:53:06 +0000 (23:53 +0300)
(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.

include/gc.h
include/private/gc_locks.h
include/private/gc_priv.h
pthread_support.c

index b8b0692..d043942 100644 (file)
@@ -161,7 +161,7 @@ GC_API GC_on_collection_event_proc GC_CALL GC_get_on_collection_event(void);
                         /* 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        */
index 59f5bf4..f6e45d5 100644 (file)
 #    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) \
index e7fc871..43f4698 100644 (file)
@@ -250,7 +250,8 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 # 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
 
index 475bcc2..071e27c 100644 (file)
@@ -1937,7 +1937,11 @@ STATIC void GC_pause(void)
 
     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