diff options
author | Jonathan Chambers <joncham@gmail.com> | 2018-01-28 10:13:10 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-01-29 10:04:29 +0300 |
commit | d5dad58d38b8f23438ae676054aebf6d0f1ae5e8 (patch) | |
tree | dae6ea3f9eb2546081e0a1f3a793296da463b9e5 | |
parent | 62aeaf3f92abbaa9f5df4841506f13140f21ba89 (diff) | |
download | bdwgc-d5dad58d38b8f23438ae676054aebf6d0f1ae5e8.tar.gz |
Initial support of Orbis target
(part of commit 9379c66 from Unity-Technologies/bdwgc)
Issue #173 (bdwgc).
* alloc.c [!MACOS && !MSWINCE && !__CC_ARM]: Do not include
sys/types.h if SN_TARGET_ORBIS.
* dyn_load.c [!MACOS && !_WIN32_WCE && !__CC_ARM]: Likewise.
* include/gc_config_macros.h [SN_TARGET_ORBIS] (GC_THREADS): Define.
* include/gc_config_macros.h [__FreeBSD__] (GC_FREEBSD_THREADS): Do
not define if SN_TARGET_ORBIS.
* include/private/gcconfig.h [__FreeBSD__ || __DragonFly__
|| __FreeBSD_kernel__] (FREEBSD): Likewise.
* include/private/gcconfig.h [!LINUX && !NETBSD && !FREEBSD
&& !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR
!NN_BUILD_TARGET_PLATFORM_NX && !SYMBIAN] (NOSYS): Likewise.
* include/private/gc_locks.h [THREADS && GC_PTHREADS
&& !GC_WIN32_THREADS]: Do not include gc_atomic_ops.h if
SN_TARGET_ORBIS.
* include/private/gc_locks.h [SN_TARGET_ORBIS && GC_PTHREADS]
(USE_PTHREAD_LOCKS): Define.
* include/private/gc_priv.h [SN_TARGET_ORBIS] (CPP_LOG_HBLKSIZE):
Define to 16 (instead of 12).
* include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__
|| __x86_64__)] (X86_64): Define.
* include/private/gcconfig.h [X86_64] (CACHE_LINE_SIZE): Do not define
if already defined.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (DATASTART,
DATAEND, STACKBOTTOM): Define.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Include
pthread.h.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]
(ps4_get_stack_bottom): Declare.
* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_ORBIS] (MUNMAP_THRESHOLD): Define to 2.
* include/private/gcconfig.h [SN_TARGET_ORBIS] (THREADS): Define.
* pthread_support.c: Do not include sys/mman.h, sys/time.h,
sys/types.h, fcntl.h if SN_TARGET_ORBIS.
* pthread_support.c (GC_pthread_join, GC_pthread_detach,
GC_pthread_create): Do not define if SN_TARGET_ORBIS.
-rw-r--r-- | alloc.c | 2 | ||||
-rw-r--r-- | dyn_load.c | 3 | ||||
-rw-r--r-- | include/gc_config_macros.h | 6 | ||||
-rw-r--r-- | include/private/gc_locks.h | 7 | ||||
-rw-r--r-- | include/private/gc_priv.h | 2 | ||||
-rw-r--r-- | include/private/gcconfig.h | 31 | ||||
-rw-r--r-- | mach_dep.c | 4 | ||||
-rw-r--r-- | misc.c | 6 | ||||
-rw-r--r-- | os_dep.c | 5 | ||||
-rw-r--r-- | pthread_stop_world.c | 2 | ||||
-rw-r--r-- | pthread_support.c | 40 |
11 files changed, 70 insertions, 38 deletions
@@ -20,7 +20,7 @@ #include <stdio.h> #if !defined(MACOS) && !defined(MSWINCE) # include <signal.h> -# if !defined(__CC_ARM) +# if !defined(__CC_ARM) && !defined(SN_TARGET_ORBIS) # include <sys/types.h> # endif #endif @@ -26,7 +26,8 @@ * But then not much of anything is safe in the presence of dlclose. */ -#if !defined(MACOS) && !defined(_WIN32_WCE) && !defined(__CC_ARM) +#if !defined(MACOS) && !defined(SN_TARGET_ORBIS) && !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 16a23f55..bc0e2e6c 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -76,7 +76,8 @@ || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \ || 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(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS) \ + || defined(SN_TARGET_ORBIS) # ifndef GC_THREADS # define GC_THREADS # endif @@ -90,7 +91,8 @@ # define GC_HAIKU_THREADS # elif defined(__OpenBSD__) # define GC_OPENBSD_THREADS -# elif defined(__FreeBSD__) || defined(__DragonFly__) +# elif (defined(__FreeBSD__) && !defined(SN_TARGET_ORBIS)) \ + || defined(__DragonFly__) # define GC_FREEBSD_THREADS # elif defined(__NetBSD__) # define GC_NETBSD_THREADS diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 11cf6f25..b7ff8b96 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -28,7 +28,8 @@ */ # ifdef THREADS -# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) +# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) \ + && !defined(SN_TARGET_ORBIS) # include "gc_atomic_ops.h" # endif @@ -47,8 +48,8 @@ # endif # if (!defined(AO_HAVE_test_and_set_acquire) || defined(GC_RTEMS_PTHREADS) \ - || defined(SN_TARGET_PS3) || defined(GC_WIN32_THREADS) \ - || defined(LINT2)) && defined(GC_PTHREADS) + || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3) \ + || defined(GC_WIN32_THREADS) || defined(LINT2)) && defined(GC_PTHREADS) # define USE_PTHREAD_LOCKS # undef USE_SPIN_LOCK # endif diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index c401aa3c..fae2888d 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -805,6 +805,8 @@ 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) +# define CPP_LOG_HBLKSIZE 16 /* page size is set to 64K */ # else # define CPP_LOG_HBLKSIZE 12 # endif diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 7c6977c3..6ddc98ef 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -109,8 +109,9 @@ /* And one for FreeBSD: */ # if (defined(__FreeBSD__) || defined(__DragonFly__) \ - || defined(__FreeBSD_kernel__)) && !defined(FREEBSD) -# define FREEBSD + || defined(__FreeBSD_kernel__)) && !defined(FREEBSD) \ + && !defined(SN_TARGET_ORBIS) /* Orbis compiler defines __FreeBSD__ */ +# define FREEBSD # endif /* And one for Darwin: */ @@ -144,7 +145,8 @@ # elif !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) \ && !defined(OPENBSD) && !defined(DARWIN) && !defined(_WIN32) \ && !defined(__CEGCC__) && !defined(NN_PLATFORM_CTR) \ - && !defined(NN_BUILD_TARGET_PLATFORM_NX) && !defined(SYMBIAN) + && !defined(NN_BUILD_TARGET_PLATFORM_NX) \ + && !defined(SN_TARGET_ORBIS) && !defined(SYMBIAN) # define NOSYS # define mach_type_known # endif @@ -454,7 +456,8 @@ # define I386 # define mach_type_known # endif -# if defined(FREEBSD) && (defined(__amd64__) || defined(__x86_64__)) +# if (defined(FREEBSD) || defined(SN_TARGET_ORBIS)) \ + && (defined(__amd64__) || defined(__x86_64__)) # define X86_64 # define mach_type_known # endif @@ -2449,7 +2452,16 @@ # ifndef HBLKSIZE # define HBLKSIZE 4096 # endif -# define CACHE_LINE_SIZE 64 +# ifndef CACHE_LINE_SIZE +# define CACHE_LINE_SIZE 64 +# endif +# ifdef SN_TARGET_ORBIS +# define DATASTART (ptr_t)ALIGNMENT +# define DATAEND (ptr_t)ALIGNMENT +# include <pthread.h> + void *ps4_get_stack_bottom(void); +# define STACKBOTTOM ((ptr_t)ps4_get_stack_bottom()) +# endif # ifdef OPENBSD # define OS_TYPE "OPENBSD" # define ELF_CLASS ELFCLASS64 @@ -2899,7 +2911,7 @@ /* not have a virtual paging system, so it does not have a large */ /* virtual address space that a standard x64 platform has. */ #if defined(USE_MUNMAP) && !defined(MUNMAP_THRESHOLD) \ - && defined(SN_TARGET_PS3) + && (defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3)) # define MUNMAP_THRESHOLD 2 #endif @@ -3064,7 +3076,7 @@ #if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \ || defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \ - || defined(SN_TARGET_PS3) + || defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3) # define THREADS #endif @@ -3152,7 +3164,7 @@ #endif #if defined(CAN_HANDLE_FORK) && !defined(CAN_CALL_ATFORK) \ - && !defined(HURD) && !defined(HOST_TIZEN) \ + && !defined(HURD) && !defined(SN_TARGET_ORBIS) && !defined(HOST_TIZEN) \ && (!defined(HOST_ANDROID) || __ANDROID_API__ >= 21) /* Have working pthread_atfork(). */ # define CAN_CALL_ATFORK @@ -3383,6 +3395,9 @@ SIZET_SAT_ADD(bytes, \ GC_page_size)) \ + GC_page_size-1) +# elif defined(SN_TARGET_ORBIS) + void *ps4_get_mem(size_t bytes); +# define GET_MEM(bytes) (struct hblk*)ps4_get_mem(bytes) # elif defined(SN_TARGET_PS3) void *ps3_get_mem(size_t bytes); # define GET_MEM(bytes) (struct hblk*)ps3_get_mem(bytes) @@ -14,6 +14,8 @@ #include "private/gc_priv.h" +#if !defined(SN_TARGET_ORBIS) + #include <stdio.h> #ifdef AMIGA @@ -325,3 +327,5 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), /* contents before we get a chance to look at them. */ GC_noop1((word)(&dummy)); } + +#endif /* !SN_TARGET_ORBIS */ @@ -50,7 +50,7 @@ # ifdef PCR # include "il/PCR_IL.h" GC_INNER PCR_Th_ML GC_allocate_ml; -# elif defined(SN_TARGET_PS3) +# elif defined(SN_TARGET_ORBIS) || defined(SN_TARGET_PS3) # include <pthread.h> GC_INNER pthread_mutex_t GC_allocate_ml; # endif @@ -1549,13 +1549,13 @@ GC_API void GC_CALL GC_enable_incremental(void) # define WRITE(level, buf, len) switch_log_write(buf, len) #else -# if !defined(AMIGA) && !defined(__CC_ARM) +# if !defined(AMIGA) && !defined(SN_TARGET_ORBIS) && !defined(__CC_ARM) # include <unistd.h> # endif STATIC int GC_write(int fd, const char *buf, size_t len) { -# if defined(ECOS) || defined(NOSYS) +# if defined(ECOS) || defined(SN_TARGET_ORBIS) || defined(NOSYS) # ifdef ECOS /* FIXME: This seems to be defined nowhere at present. */ /* _Jv_diag_write(buf, len); */ @@ -17,7 +17,7 @@ #include "private/gc_priv.h" #if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \ - && !defined(MSWINCE) && !defined(__CC_ARM) + && !defined(MSWINCE) && !defined(SN_TARGET_ORBIS) && !defined(__CC_ARM) # include <sys/types.h> # if !defined(MSWIN32) # include <unistd.h> @@ -2083,7 +2083,8 @@ void GC_register_data_segments(void) # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \ && !defined(USE_WINALLOC) && !defined(MACOS) && !defined(DOS4GW) \ && !defined(NINTENDO_SWITCH) && !defined(NONSTOP) \ - && !defined(SN_TARGET_PS3) && !defined(RTEMS) && !defined(__CC_ARM) + && !defined(SN_TARGET_ORBIS) && !defined(SN_TARGET_PS3) \ + && !defined(RTEMS) && !defined(__CC_ARM) # define SBRK_ARG_T ptrdiff_t diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 5188cdc8..5ee6ce8d 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -18,7 +18,7 @@ #include "private/pthread_support.h" #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && \ - !defined(GC_DARWIN_THREADS) + !defined(GC_DARWIN_THREADS) && !defined(SN_TARGET_ORBIS) #ifdef NACL diff --git a/pthread_support.c b/pthread_support.c index 22d4a8d6..dec53b3d 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -35,13 +35,15 @@ # include <time.h> # include <errno.h> # include <unistd.h> -# if !defined(GC_RTEMS_PTHREADS) -# include <sys/mman.h> +# if !defined(SN_TARGET_ORBIS) +# if !defined(GC_RTEMS_PTHREADS) +# include <sys/mman.h> +# endif +# include <sys/time.h> +# include <sys/types.h> +# include <sys/stat.h> +# include <fcntl.h> # endif -# include <sys/time.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <fcntl.h> # include <signal.h> # include "gc_inline.h" @@ -1537,8 +1539,9 @@ GC_INNER_PTHRSTART void GC_thread_exit_proc(void *arg) UNLOCK(); } -GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) -{ +#if !defined(SN_TARGET_ORBIS) + GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) + { int result; GC_thread t; DCL_LOCK_STATE; @@ -1571,10 +1574,10 @@ GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) UNLOCK(); } return result; -} + } -GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) -{ + GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) + { int result; GC_thread t; DCL_LOCK_STATE; @@ -1594,7 +1597,8 @@ GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) UNLOCK(); } return result; -} + } +#endif /* !SN_TARGET_ORBIS */ #ifndef GC_NO_PTHREAD_CANCEL /* We should deal with the fact that apparently on Solaris and, */ @@ -1809,10 +1813,11 @@ STATIC void * GC_start_routine(void * arg) # endif } -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) -{ +#if !defined(SN_TARGET_ORBIS) + 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) + { int result; int detachstate; word my_flags = 0; @@ -1913,7 +1918,8 @@ GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread, UNLOCK(); return(result); -} + } +#endif /* !SN_TARGET_ORBIS */ #if defined(USE_SPIN_LOCK) || !defined(NO_PTHREAD_TRYLOCK) /* Spend a few cycles in a way that can't introduce contention with */ |