Initial support of Orbis target
authorJonathan Chambers <joncham@gmail.com>
Sun, 28 Jan 2018 07:13:10 +0000 (10:13 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 29 Jan 2018 07:04:29 +0000 (10:04 +0300)
(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.

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 c8e2ef2..83d7fb3 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -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
index e136820..2047fa3 100644 (file)
@@ -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
 
index 16a23f5..bc0e2e6 100644 (file)
@@ -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
index 11cf6f2..b7ff8b9 100644 (file)
@@ -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
index c401aa3..fae2888 100644 (file)
@@ -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
index 7c6977c..6ddc98e 100644 (file)
 
 /* 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: */
 #    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
 #   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
 #   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
 /* 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
 
 
 #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
 
 #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
                                             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)
index 1029141..48f19eb 100644 (file)
@@ -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 */
diff --git a/misc.c b/misc.c
index a69f448..73d24d2 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -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); */
index d7f1652..a4f4a92 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -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
 
index 5188cdc..5ee6ce8 100644 (file)
@@ -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
 
index 22d4a8d..dec53b3 100644 (file)
 # 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     */