]> granicus.if.org Git - gc/commitdiff
Initial support of Sony PlayStation Portable 2
authorJonathan Chambers <joncham@gmail.com>
Thu, 1 Feb 2018 08:17:24 +0000 (11:17 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 1 Feb 2018 08:25:21 +0000 (11:25 +0300)
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* alloc.c [!MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]:
Do not include sys/types.h if SN_TARGET_PSP2.
* dyn_load.c [!MACOS && !_WIN32_WCE && !SN_TARGET_ORBIS && !__CC_ARM]:
Likewise.
* os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE
&& !SN_TARGET_ORBIS && !__CC_ARM]: Likewise.
* include/gc_config_macros.h [SN_TARGET_PSP2] (GC_THREADS): Define
macro.
* include/private/gcconfig.h [SN_TARGET_PSP2] (mach_type_known):
Likewise.
* include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (NO_HANDLE_FORK,
DATASTART, DATAEND, STACKBOTTOM): Likewise.
* include/private/gcconfig.h [SN_TARGET_PSP2] (THREADS, GET_MEM):
Likewise.
* include/private/gc_locks.h [GC_PTHREADS && !GC_WIN32_THREADS
&& !SN_TARGET_ORBIS]: Do not include gc_atomic_ops.h if SN_TARGET_PSP2.
* include/private/gc_locks.h [SN_TARGET_PSP2]: Include psp2-support.h.
* include/private/gc_locks.h [SN_TARGET_PSP2] (GC_allocate_ml_PSP2):
Declare GC_EXTERN variable.
* include/private/gc_locks.h [SN_TARGET_PSP2] (UNCOND_LOCK,
UNCOND_UNLOCK): Define (using GC_allocate_ml_PSP2 instead of
GC_allocate_ml).
* include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG
|| !SMALL_CONFIG) && SN_TARGET_PSP2] (CPP_LOG_HBLKSIZE): Define to 16
(instead of 12).
* include/private/gcconfig.h [ARM32] (NOSYS): Do not define if
SN_TARGET_PSP2.
* os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem,
GC_unix_sbrk_get_mem, GC_unix_get_mem): Likewise.
* pthread_support.c (GC_pthread_join, GC_pthread_detach,
GC_pthread_create): Likewise.
* include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2]
(psp2_get_stack_bottom): Declare external function.
* include/private/gcconfig.h [SN_TARGET_PSP2] (psp2_get_mem): Likewise.
* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_PSP2] (MUNMAP_THRESHOLD): Define to 2.
* mach_dep.c: Skip everything in this file if SN_TARGET_PSP2.
* pthread_stop_world.c: Likewise.
* misc.c [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Define global varible
(instead of GC_allocate_ml).
* misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG
&& !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS
&& !__CC_ARM]: Do not include unistd.h if SN_TARGET_PSP2.
* misc.c [SN_TARGET_PSP2] (GC_write): Define to no-op.
* pthread_support.c: Do not include sys/mman.h if SN_TARGET_PSP2.

alloc.c
dyn_load.c
include/gc_config_macros.h
include/private/gc_locks.h
include/private/gc_priv.h
include/private/gcconfig.h
mach_dep.c
misc.c
os_dep.c
pthread_stop_world.c
pthread_support.c

diff --git a/alloc.c b/alloc.c
index 83d7fb354e3173ad7fe736137beb87a15f7e0794..7247336c35674a7cddcff25d8d7494d6301e95b0 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -20,7 +20,8 @@
 #include <stdio.h>
 #if !defined(MACOS) && !defined(MSWINCE)
 # include <signal.h>
-# if !defined(__CC_ARM) && !defined(SN_TARGET_ORBIS)
+# if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2) \
+     && !defined(__CC_ARM)
 #   include <sys/types.h>
 # endif
 #endif
index 2047fa3a829d742d4b7a4c0a8dbb17c1b9aacb6b..a5051d449be6bda0ada4bf399f0006a22aea2384 100644 (file)
@@ -26,8 +26,8 @@
  * But then not much of anything is safe in the presence of dlclose.
  */
 
-#if !defined(MACOS) && !defined(SN_TARGET_ORBIS) && !defined(_WIN32_WCE) \
-    && !defined(__CC_ARM)
+#if !defined(MACOS) && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2) \
+    && !defined(_WIN32_WCE) && !defined(__CC_ARM)
 # include <sys/types.h>
 #endif
 
index bc0e2e6c20924a60de2af4a09052c0404cf5edd5..7e4f9a58c22aaf73a4f382e015dd3fe458cc2dcd 100644 (file)
@@ -77,7 +77,7 @@
     || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \
     || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \
     || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS) \
-    || defined(SN_TARGET_ORBIS)
+    || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PSP2)
 # ifndef GC_THREADS
 #   define GC_THREADS
 # endif
index b7ff8b967c77df739156f83407f4d41e3de2d0cc..82bb252228eb835ac83102b568d92d18c31609f9 100644 (file)
@@ -29,7 +29,7 @@
 # ifdef THREADS
 
 #  if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) \
-      && !defined(SN_TARGET_ORBIS)
+      && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
 #    include "gc_atomic_ops.h"
 #  endif
 
 #    define NO_THREAD ((unsigned long)(-1l))
                 /* != NUMERIC_THREAD_ID(pthread_self()) for any thread */
 
-#    if (!defined(THREAD_LOCAL_ALLOC) || defined(USE_SPIN_LOCK)) \
-        && !defined(USE_PTHREAD_LOCKS)
+#    ifdef SN_TARGET_PSP2
+#      include "psp2-support.h"
+       GC_EXTERN WapiMutex GC_allocate_ml_PSP2;
+#      define UNCOND_LOCK() { int res; GC_ASSERT(I_DONT_HOLD_LOCK()); \
+                              res = PSP2_MutexLock(&GC_allocate_ml_PSP2); \
+                              GC_ASSERT(0 == res); (void)res; \
+                              SET_LOCK_HOLDER(); }
+#      define UNCOND_UNLOCK() { int res; GC_ASSERT(I_HOLD_LOCK()); \
+                              UNSET_LOCK_HOLDER(); \
+                              res = PSP2_MutexUnlock(&GC_allocate_ml_PSP2); \
+                              GC_ASSERT(0 == res); (void)res; }
+
+#    elif (!defined(THREAD_LOCAL_ALLOC) || defined(USE_SPIN_LOCK)) \
+          && !defined(USE_PTHREAD_LOCKS)
       /* In the THREAD_LOCAL_ALLOC case, the allocation lock tends to   */
       /* be held for long periods, if it is held at all.  Thus spinning */
       /* and sleeping for fixed periods are likely to result in         */
index 14a4926f338cfefd283154590c04ea600539fb71..333969f63d44fff35cc9559467e2558699da2613 100644 (file)
@@ -805,7 +805,7 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc;
 # if defined(LARGE_CONFIG) || !defined(SMALL_CONFIG)
 #   ifdef ALPHA
 #     define CPP_LOG_HBLKSIZE 13
-#   elif defined(SN_TARGET_ORBIS)
+#   elif defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PSP2)
 #     define CPP_LOG_HBLKSIZE 16    /* page size is set to 64K  */
 #   else
 #     define CPP_LOG_HBLKSIZE 12
index 40c870b187449272c77ff4de83999795600b9f7d..b69a420fdcf924c8f46e79b4ecca5293c3290ab2 100644 (file)
           && !defined(OPENBSD) && !defined(DARWIN) && !defined(_WIN32) \
           && !defined(__CEGCC__) && !defined(NN_PLATFORM_CTR) \
           && !defined(NN_BUILD_TARGET_PLATFORM_NX) \
-          && !defined(SN_TARGET_ORBIS) && !defined(SYMBIAN)
+          && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2) \
+          && !defined(SYMBIAN)
 #      define NOSYS
 #      define mach_type_known
 #    endif
 #   define mach_type_known
 # endif
 
+# if defined(SN_TARGET_PSP2)
+#   define mach_type_known
+# endif
+
 # if defined(NN_PLATFORM_CTR)
 #   define mach_type_known
 # endif
 #     define DATAEND ((ptr_t)(&_end))
 #     define DYNAMIC_LOADING
 #   endif
+#   ifdef SN_TARGET_PSP2
+#     define NO_HANDLE_FORK
+#     define DATASTART (ptr_t)ALIGNMENT
+#     define DATAEND (ptr_t)ALIGNMENT
+      void *psp2_get_stack_bottom(void);
+#     define STACKBOTTOM ((ptr_t)psp2_get_stack_bottom())
+#   endif
 #   ifdef NN_PLATFORM_CTR
       extern unsigned char Image$$ZI$$ZI$$Base[];
 #     define DATASTART (ptr_t)(Image$$ZI$$ZI$$Base)
 /* have a large virtual address space that a standard x64 platform has. */
 #if defined(USE_MUNMAP) && !defined(MUNMAP_THRESHOLD) \
     && (defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3) \
-        || defined(MSWIN_XBOX1))
+        || defined(SN_TARGET_PSP2) || defined(MSWIN_XBOX1))
 # define MUNMAP_THRESHOLD 2
 #endif
 
 
 #if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \
     || defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
-    || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3)
+    || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3) \
+    || defined(SN_TARGET_PSP2)
 # define THREADS
 #endif
 
 # elif defined(SN_TARGET_PS3)
     void *ps3_get_mem(size_t bytes);
 #   define GET_MEM(bytes) (struct hblk*)ps3_get_mem(bytes)
+# elif defined(SN_TARGET_PSP2)
+    void *psp2_get_mem(size_t bytes);
+#   define GET_MEM(bytes) (struct hblk*)psp2_get_mem(bytes)
 # elif defined(NINTENDO_SWITCH)
     void *switch_get_mem(size_t bytes);
 #   define GET_MEM(bytes) (struct hblk*)switch_get_mem(bytes)
index 48f19eb089c42149c061624dc29badfb3961ae57..2c62cc63f6e1e847b063f897f1ebc60d7e94e7dc 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "private/gc_priv.h"
 
-#if !defined(SN_TARGET_ORBIS)
+#if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
 
 #include <stdio.h>
 
@@ -328,4 +328,4 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
   GC_noop1((word)(&dummy));
 }
 
-#endif /* !SN_TARGET_ORBIS */
+#endif /* !SN_TARGET_ORBIS && !SN_TARGET_PSP2 */
diff --git a/misc.c b/misc.c
index 66f1d97ae63cb7c4dc9bd65c8d21e0f42efcbaaf..11275acdbeab76ddb51214cc513c8f4ead0186d9 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -50,6 +50,8 @@
 # ifdef PCR
 #   include "il/PCR_IL.h"
     GC_INNER PCR_Th_ML GC_allocate_ml;
+# elif defined(SN_TARGET_PSP2)
+    GC_INNER WapiMutex GC_allocate_ml_PSP2 = { 0, NULL };
 # elif defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3)
 #   include <pthread.h>
     GC_INNER pthread_mutex_t GC_allocate_ml;
@@ -1565,13 +1567,14 @@ GC_API void GC_CALL GC_enable_incremental(void)
 
 #else
 # if !defined(AMIGA) && !defined(MSWIN_XBOX1) && !defined(SN_TARGET_ORBIS) \
-     && !defined(__CC_ARM)
+     && !defined(SN_TARGET_PSP2) && !defined(__CC_ARM)
 #   include <unistd.h>
 # endif
 
   STATIC int GC_write(int fd, const char *buf, size_t len)
   {
-#   if defined(ECOS) || defined(SN_TARGET_ORBIS) || defined(NOSYS)
+#   if defined(ECOS) || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PSP2) \
+       || defined(NOSYS)
 #     ifdef ECOS
         /* FIXME: This seems to be defined nowhere at present.  */
         /* _Jv_diag_write(buf, len); */
index dda1abe6cb4c560ec326e3091884b38269be9925..cd089c7ad37fdfd4ea38b145757386eae801f2e6 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -17,7 +17,8 @@
 #include "private/gc_priv.h"
 
 #if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
-    && !defined(MSWINCE) && !defined(SN_TARGET_ORBIS) && !defined(__CC_ARM)
+    && !defined(MSWINCE) && !defined(SN_TARGET_ORBIS) \
+    && !defined(SN_TARGET_PSP2) && !defined(__CC_ARM)
 # include <sys/types.h>
 # if !defined(MSWIN32) && !defined(MSWIN_XBOX1)
 #   include <unistd.h>
@@ -2084,7 +2085,7 @@ void GC_register_data_segments(void)
      && !defined(USE_WINALLOC) && !defined(MACOS) && !defined(DOS4GW) \
      && !defined(NINTENDO_SWITCH) && !defined(NONSTOP) \
      && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PS3) \
-     && !defined(RTEMS) && !defined(__CC_ARM)
+     && !defined(SN_TARGET_PSP2) && !defined(RTEMS) && !defined(__CC_ARM)
 
 # define SBRK_ARG_T ptrdiff_t
 
index 5ee6ce8dc80400ce5c0ff7b5ef61b7ae926b5978..a6ca776dbc19a4c4e9520738dde714c08d76a75e 100644 (file)
@@ -18,7 +18,8 @@
 #include "private/pthread_support.h"
 
 #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && \
-    !defined(GC_DARWIN_THREADS) && !defined(SN_TARGET_ORBIS)
+    !defined(GC_DARWIN_THREADS) && !defined(SN_TARGET_ORBIS) \
+    && !defined(SN_TARGET_PSP2)
 
 #ifdef NACL
 
index dec53b3dbb5f3202e9b4ddf9c4856f70dfe67430..59d6732d05abc9b9100aea3cc823892d9bf4a14c 100644 (file)
@@ -35,7 +35,7 @@
 # include <time.h>
 # include <errno.h>
 # include <unistd.h>
-# if !defined(SN_TARGET_ORBIS)
+# if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
 #   if !defined(GC_RTEMS_PTHREADS)
 #     include <sys/mman.h>
 #   endif
@@ -1539,7 +1539,7 @@ GC_INNER_PTHRSTART void GC_thread_exit_proc(void *arg)
     UNLOCK();
 }
 
-#if !defined(SN_TARGET_ORBIS)
+#if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
   GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval)
   {
     int result;
@@ -1598,7 +1598,7 @@ GC_INNER_PTHRSTART void GC_thread_exit_proc(void *arg)
     }
     return result;
   }
-#endif /* !SN_TARGET_ORBIS */
+#endif /* !SN_TARGET_ORBIS && !SN_TARGET_PSP2 */
 
 #ifndef GC_NO_PTHREAD_CANCEL
   /* We should deal with the fact that apparently on Solaris and,       */
@@ -1813,7 +1813,7 @@ STATIC void * GC_start_routine(void * arg)
 #   endif
 }
 
-#if !defined(SN_TARGET_ORBIS)
+#if !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PSP2)
   GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread,
                        GC_PTHREAD_CREATE_CONST pthread_attr_t *attr,
                        void *(*start_routine)(void *), void *arg)
@@ -1919,7 +1919,7 @@ STATIC void * GC_start_routine(void * arg)
 
     return(result);
   }
-#endif /* !SN_TARGET_ORBIS */
+#endif /* !SN_TARGET_ORBIS && !SN_TARGET_PSP2 */
 
 #if defined(USE_SPIN_LOCK) || !defined(NO_PTHREAD_TRYLOCK)
 /* Spend a few cycles in a way that can't introduce contention with     */