Initial support of Sony PlayStation Portable 2

(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.
This commit is contained in:
Jonathan Chambers
2018-02-01 11:17:24 +03:00
committed by Ivan Maidanski
parent 019a5660ec
commit cd63cf1e82
11 changed files with 57 additions and 23 deletions
+2 -1
View File
@@ -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
+2 -2
View 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
+1 -1
View 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
+15 -3
View 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
@@ -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 */
+1 -1
View 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
+19 -3
View File
@@ -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)
+2 -2
View 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 */
+5 -2
View File
@@ -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); */
+3 -2
View File
@@ -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
+2 -1
View 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
+5 -5
View 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 */