mirror of
https://github.com/encounter/bdwgc.git
synced 2026-03-30 10:57:55 -07:00
Initial support of Nintendo platform
(part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/gc_config_macros.h [(!GC_WIN32_THREADS || GC_WIN32_PTHREADS || __CYGWIN32__ || __CYGWIN__) && GC_THREADS] (GC_PTHREADS): Do not define if NN_PLATFORM_CTR or NN_BUILD_TARGET_PLATFORM_NX. * include/private/gc_priv.h [NN_PLATFORM_CTR] (CLOCK_TYPE, GET_TIME, MS_TIME_DIFF): Define macro. * include/private/gc_priv.h [!PCR && (NN_PLATFORM_CTR || NINTENDO_SWITCH)] (STOP_WORLD, START_WORLD): Likewise. * include/private/gcconfig.h [NN_PLATFORM_CTR] (ARM32, mach_type_known): Likewise. * include/private/gcconfig.h [NN_BUILD_TARGET_PLATFORM_NX] (NINTENDO_SWITCH, mach_type_known): Likewise. * include/private/gcconfig.h [NN_PLATFORM_CTR] (DATASTART, DATAEND, STACKBOTTOM): Likewise. * include/private/gcconfig.h [NINTENDO_SWITCH] (NO_HANDLE_FORK, DATASTART, DATAEND, STACKBOTTOM): Likewise. * include/private/gcconfig.h [NN_PLATFORM_CTR || NINTENDO_SWITCH] (THREADS): Likewise. * include/private/gcconfig.h [NINTENDO_SWITCH] (GET_MEM): Likewise. * misc.c [NN_PLATFORM_CTR || NINTENDO_SWITCH] (WRITE): Likewise. * include/private/gc_priv.h [NN_PLATFORM_CTR] (n3ds_get_system_tick n3ds_convert_tick_to_ms): Declare external function. * include/private/gc_priv.h [!PCR && (NN_PLATFORM_CTR || NINTENDO_SWITCH)] (GC_stop_world, GC_start_world): Declare. * include/private/gcconfig.h [NN_PLATFORM_CTR] (Image$$ZI$$ZI$$Base, Image$$ZI$$ZI$$Limit, n3ds_get_stack_bottom): Likewise. * include/private/gcconfig.h [NINTENDO_SWITCH] (__bss_end, switch_get_stack_bottom): Likewise. * include/private/gcconfig.h [NINTENDO_SWITCH] (switch_get_mem): Likewise. * misc.c [NN_PLATFORM_CTR] (n3ds_log_write): Likewise. * misc.c [NINTENDO_SWITCH] (switch_log_write): Likewise. * include/private/gcconfig.h [__aarch64__ && !LINUX && !DARWIN && !FREEBSD] (NOSYS): Do not define if NN_BUILD_TARGET_PLATFORM_NX. * include/private/gcconfig.h [(__arm || __arm__ || __thumb__) && !NACL && !LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !SYMBIAN] (NOSYS): Do not define if NN_PLATFORM_CTR or NN_BUILD_TARGET_PLATFORM_NX. * misc.c [!OS2 && !MACOS && !GC_ANDROID_LOG && !MSWIN32 && !MSWINCE] (GC_stdout, GC_stderr, GC_log, GC_set_log_fd): Do not define if NN_PLATFORM_CTR or NINTENDO_SWITCH. * misc.c [NN_PLATFORM_CTR] (GC_init): Call GC_get_main_stack_base() to set GC_stackbottom. * os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, GC_unix_get_mem): Do not define if NINTENDO_SWITCH. * os_dep.c [USE_MUNMAP]: Do not include unistd.h, sys/mman.h, sys/stat.h, sys/types.h if NN_PLATFORM_CTR. * os_dep.c [NN_PLATFORM_CTR || NINTENDO_SWITCH] (GC_default_push_other_roots): Redirect to GC_push_all_stacks.
This commit is contained in:
committed by
Ivan Maidanski
parent
3049fdb8fc
commit
97182297e6
@@ -128,7 +128,8 @@
|
||||
|
||||
#undef GC_PTHREADS
|
||||
#if (!defined(GC_WIN32_THREADS) || defined(GC_WIN32_PTHREADS) \
|
||||
|| defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS)
|
||||
|| defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS) \
|
||||
&& !defined(NN_PLATFORM_CTR) && !defined(NN_BUILD_TARGET_PLATFORM_NX)
|
||||
/* Posix threads. */
|
||||
# define GC_PTHREADS
|
||||
#endif
|
||||
|
||||
@@ -434,7 +434,13 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
|
||||
# define CLOCK_TYPE DWORD
|
||||
# define GET_TIME(x) (void)(x = GetTickCount())
|
||||
# define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
|
||||
#else /* !MSWIN32, !MSWINCE, !BSD_TIME */
|
||||
#elif defined(NN_PLATFORM_CTR)
|
||||
# define CLOCK_TYPE long long
|
||||
CLOCK_TYPE n3ds_get_system_tick(void);
|
||||
CLOCK_TYPE n3ds_convert_tick_to_ms(CLOCK_TYPE tick);
|
||||
# define GET_TIME(x) (void)(x = n3ds_get_system_tick())
|
||||
# define MS_TIME_DIFF(a,b) ((long)n3ds_convert_tick_to_ms((a)-(b)))
|
||||
#else /* !BSD_TIME && !NN_PLATFORM_CTR && !MSWIN32 && !MSWINCE */
|
||||
# include <time.h>
|
||||
# if defined(FREEBSD) && !defined(CLOCKS_PER_SEC)
|
||||
# include <machine/limits.h>
|
||||
@@ -513,7 +519,8 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
|
||||
PCR_allSigsBlocked, \
|
||||
PCR_waitForever)
|
||||
# else
|
||||
# if defined(GC_WIN32_THREADS) || defined(GC_PTHREADS)
|
||||
# if defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
|
||||
|| defined(GC_WIN32_THREADS) || defined(GC_PTHREADS)
|
||||
GC_INNER void GC_stop_world(void);
|
||||
GC_INNER void GC_start_world(void);
|
||||
# define STOP_WORLD() GC_stop_world()
|
||||
|
||||
@@ -131,7 +131,8 @@
|
||||
# endif
|
||||
# if defined(__aarch64__)
|
||||
# define AARCH64
|
||||
# if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD)
|
||||
# if !defined(LINUX) && !defined(DARWIN) && !defined(FREEBSD) \
|
||||
&& !defined(NN_BUILD_TARGET_PLATFORM_NX)
|
||||
# define NOSYS
|
||||
# define mach_type_known
|
||||
# endif
|
||||
@@ -141,8 +142,9 @@
|
||||
# if defined(NACL)
|
||||
# define mach_type_known
|
||||
# elif !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) \
|
||||
&& !defined(OPENBSD) && !defined(DARWIN) \
|
||||
&& !defined(_WIN32) && !defined(__CEGCC__) && !defined(SYMBIAN)
|
||||
&& !defined(OPENBSD) && !defined(DARWIN) && !defined(_WIN32) \
|
||||
&& !defined(__CEGCC__) && !defined(NN_PLATFORM_CTR) \
|
||||
&& !defined(NN_BUILD_TARGET_PLATFORM_NX) && !defined(SYMBIAN)
|
||||
# define NOSYS
|
||||
# define mach_type_known
|
||||
# endif
|
||||
@@ -616,6 +618,16 @@
|
||||
# define mach_type_known
|
||||
# endif
|
||||
|
||||
# if defined(NN_PLATFORM_CTR)
|
||||
# define ARM32
|
||||
# define mach_type_known
|
||||
# endif
|
||||
|
||||
# if defined(NN_BUILD_TARGET_PLATFORM_NX)
|
||||
# define NINTENDO_SWITCH
|
||||
# define mach_type_known
|
||||
# endif
|
||||
|
||||
# if defined(SYMBIAN)
|
||||
# define mach_type_known
|
||||
# endif
|
||||
@@ -2312,6 +2324,22 @@
|
||||
# define DATAEND ((ptr_t)(&_end))
|
||||
# define DYNAMIC_LOADING
|
||||
# endif
|
||||
# ifdef NN_PLATFORM_CTR
|
||||
extern unsigned char Image$$ZI$$ZI$$Base[];
|
||||
# define DATASTART (ptr_t)(Image$$ZI$$ZI$$Base)
|
||||
extern unsigned char Image$$ZI$$ZI$$Limit[];
|
||||
# define DATAEND (ptr_t)(Image$$ZI$$ZI$$Limit)
|
||||
void *n3ds_get_stack_bottom(void);
|
||||
# define STACKBOTTOM ((ptr_t)n3ds_get_stack_bottom())
|
||||
# endif
|
||||
# ifdef NINTENDO_SWITCH
|
||||
extern int __bss_end[];
|
||||
# define NO_HANDLE_FORK
|
||||
# define DATASTART (ptr_t)ALIGNMENT /* cannot be null */
|
||||
# define DATAEND (ptr_t)(&__bss_end)
|
||||
void *switch_get_stack_bottom(void);
|
||||
# define STACKBOTTOM ((ptr_t)switch_get_stack_bottom())
|
||||
# endif
|
||||
# ifdef NOSYS
|
||||
/* __data_start is usually defined in the target linker script. */
|
||||
extern int __data_start[];
|
||||
@@ -3036,6 +3064,7 @@
|
||||
#endif /* !CPPCHECK */
|
||||
|
||||
#if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \
|
||||
|| defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
|
||||
|| defined(SN_TARGET_PS3)
|
||||
# define THREADS
|
||||
#endif
|
||||
@@ -3358,6 +3387,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(NINTENDO_SWITCH)
|
||||
void *switch_get_mem(size_t bytes);
|
||||
# define GET_MEM(bytes) (struct hblk*)switch_get_mem(bytes)
|
||||
# elif defined(HAIKU)
|
||||
ptr_t GC_haiku_get_mem(size_t bytes);
|
||||
# define GET_MEM(bytes) (struct hblk*)GC_haiku_get_mem(bytes)
|
||||
|
||||
@@ -764,6 +764,7 @@ GC_API int GC_CALL GC_is_init_called(void)
|
||||
#define GC_DEFAULT_STDERR_FD 2
|
||||
|
||||
#if !defined(OS2) && !defined(MACOS) && !defined(GC_ANDROID_LOG) \
|
||||
&& !defined(NN_PLATFORM_CTR) && !defined(NINTENDO_SWITCH) \
|
||||
&& !defined(MSWIN32) && !defined(MSWINCE)
|
||||
STATIC int GC_stdout = GC_DEFAULT_STDOUT_FD;
|
||||
STATIC int GC_stderr = GC_DEFAULT_STDERR_FD;
|
||||
@@ -1147,6 +1148,7 @@ GC_API void GC_CALL GC_init(void)
|
||||
GC_init_netbsd_elf();
|
||||
# endif
|
||||
# if !defined(THREADS) || defined(GC_PTHREADS) \
|
||||
|| defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
|
||||
|| defined(GC_WIN32_THREADS) || defined(GC_SOLARIS_THREADS)
|
||||
if (GC_stackbottom == 0) {
|
||||
GC_stackbottom = GC_get_main_stack_base();
|
||||
@@ -1539,6 +1541,13 @@ GC_API void GC_CALL GC_enable_incremental(void)
|
||||
# define WRITE(level, buf, unused_len) \
|
||||
__android_log_write(level, GC_ANDROID_LOG_TAG, buf)
|
||||
|
||||
# elif defined(NN_PLATFORM_CTR)
|
||||
int n3ds_log_write(const char* text, int length);
|
||||
# define WRITE(level, buf, len) n3ds_log_write(buf, len)
|
||||
# elif defined(NINTENDO_SWITCH)
|
||||
int switch_log_write(const char* text, int length);
|
||||
# define WRITE(level, buf, len) switch_log_write(buf, len)
|
||||
|
||||
#else
|
||||
# if !defined(AMIGA) && !defined(__CC_ARM)
|
||||
# include <unistd.h>
|
||||
|
||||
@@ -2082,8 +2082,8 @@ void GC_register_data_segments(void)
|
||||
|
||||
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \
|
||||
&& !defined(USE_WINALLOC) && !defined(MACOS) && !defined(DOS4GW) \
|
||||
&& !defined(NONSTOP) && !defined(SN_TARGET_PS3) && !defined(RTEMS) \
|
||||
&& !defined(__CC_ARM)
|
||||
&& !defined(NINTENDO_SWITCH) && !defined(NONSTOP) \
|
||||
&& !defined(SN_TARGET_PS3) && !defined(RTEMS) && !defined(__CC_ARM)
|
||||
|
||||
# define SBRK_ARG_T ptrdiff_t
|
||||
|
||||
@@ -2447,7 +2447,7 @@ void * os2_alloc(size_t bytes)
|
||||
/* systems. If you have something else, don't define */
|
||||
/* USE_MUNMAP. */
|
||||
|
||||
#if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
#if !defined(NN_PLATFORM_CTR) && !defined(MSWIN32) && !defined(MSWINCE)
|
||||
# include <unistd.h>
|
||||
# ifdef SN_TARGET_PS3
|
||||
# include <sys/memory.h>
|
||||
@@ -2711,12 +2711,13 @@ STATIC void GC_CALLBACK GC_default_push_other_roots(void)
|
||||
|
||||
# endif /* PCR */
|
||||
|
||||
# if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
|
||||
# if defined(NN_PLATFORM_CTR) || defined(NINTENDO_SWITCH) \
|
||||
|| defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
|
||||
STATIC void GC_CALLBACK GC_default_push_other_roots(void)
|
||||
{
|
||||
GC_push_all_stacks();
|
||||
}
|
||||
# endif /* GC_WIN32_THREADS || GC_PTHREADS */
|
||||
# endif
|
||||
|
||||
# ifdef SN_TARGET_PS3
|
||||
STATIC void GC_CALLBACK GC_default_push_other_roots(void)
|
||||
|
||||
Reference in New Issue
Block a user