summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alloc.c3
-rw-r--r--dyn_load.c4
-rw-r--r--include/gc_config_macros.h2
-rw-r--r--include/private/gc_locks.h18
-rw-r--r--include/private/gc_priv.h2
-rw-r--r--include/private/gcconfig.h22
-rw-r--r--mach_dep.c4
-rw-r--r--misc.c7
-rw-r--r--os_dep.c5
-rw-r--r--pthread_stop_world.c3
-rw-r--r--pthread_support.c10
11 files changed, 57 insertions, 23 deletions
diff --git a/alloc.c b/alloc.c
index 83d7fb35..7247336c 100644
--- 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
diff --git a/dyn_load.c b/dyn_load.c
index 2047fa3a..a5051d44 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -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
diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
index bc0e2e6c..7e4f9a58 100644
--- a/include/gc_config_macros.h
+++ b/include/gc_config_macros.h
@@ -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
diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h
index b7ff8b96..82bb2522 100644
--- a/include/private/gc_locks.h
+++ b/include/private/gc_locks.h
@@ -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
@@ -122,8 +122,20 @@
# 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 */
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 14a4926f..333969f6 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -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
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 40c870b1..b69a420f 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -146,7 +146,8 @@
&& !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
@@ -625,6 +626,10 @@
# 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
@@ -2329,6 +2334,13 @@
# 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)
@@ -2934,7 +2946,7 @@
/* 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
@@ -3099,7 +3111,8 @@
#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
@@ -3427,6 +3440,9 @@
# 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)
diff --git a/mach_dep.c b/mach_dep.c
index 48f19eb0..2c62cc63 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -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 66f1d97a..11275acd 100644
--- 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); */
diff --git a/os_dep.c b/os_dep.c
index dda1abe6..cd089c7a 100644
--- 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
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 5ee6ce8d..a6ca776d 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -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
diff --git a/pthread_support.c b/pthread_support.c
index dec53b3d..59d6732d 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -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 */