From e9f26e6de5a1a4b4ded6d55f1a09838da5056c07 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 23 Jan 2018 05:38:02 +0300 Subject: [PATCH] Use HOST_ANDROID define instead of PLATFORM_ANDROID (a cherry-pick of commit 5d819c8 from 'mono_libgc') * doc/README.macros (PLATFORM_ANDROID): Rename to HOST_ANDROID. * dyn_load.c: Rename PLATFORM_ANDROID to HOST_ANDROID. * include/gc.h: Likewise. * include/gc_config_macros.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * tests/initsecondarythread.c: Likewise. * tests/test.c: Likewise. * tools/threadlibs.c: Likewise. --- doc/README.macros | 2 +- dyn_load.c | 16 ++++++++-------- include/gc.h | 2 +- include/gc_config_macros.h | 4 ++-- include/private/gcconfig.h | 28 ++++++++++++++-------------- include/private/thread_local_alloc.h | 4 ++-- os_dep.c | 4 ++-- pthread_support.c | 4 ++-- tests/initsecondarythread.c | 2 +- tests/test.c | 2 +- tools/threadlibs.c | 2 +- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/doc/README.macros b/doc/README.macros index 3e9f179..58fc964 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -586,7 +586,7 @@ NO_CANCEL_SAFE (Posix platforms with threads only) Don't bother trying UNICODE (Win32 only) Use the Unicode variant ('W') of the Win32 API instead of ANSI/ASCII one ('A'). Useful for WinCE. -PLATFORM_ANDROID (or __ANDROID__) Compile for Android NDK platform. +HOST_ANDROID (or __ANDROID__) Compile for Android NDK platform. SN_TARGET_PS3 Compile for Sony PS/3. diff --git a/dyn_load.c b/dyn_load.c index 0271d71..e15c2cc 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -91,12 +91,12 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0; || defined(NACL) || defined(NETBSD) \ || defined(OPENBSD))) # include -# if !defined(OPENBSD) && !defined(PLATFORM_ANDROID) +# if !defined(OPENBSD) && !defined(HOST_ANDROID) /* OpenBSD does not have elf.h file; link.h below is sufficient. */ /* Exclude Android because linker.h below includes its own version. */ # include # endif -# ifdef PLATFORM_ANDROID +# ifdef HOST_ANDROID /* If you don't need the "dynamic loading" feature, you may build */ /* the collector with -D IGNORE_DYNAMIC_LOADING. */ # ifdef BIONIC_ELFDATA_REDEF_BUG @@ -411,16 +411,16 @@ GC_INNER GC_bool GC_register_main_static_data(void) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)) \ - || defined(PLATFORM_ANDROID) /* Are others OK here, too? */ + || defined(HOST_ANDROID) /* Are others OK here, too? */ # ifndef HAVE_DL_ITERATE_PHDR # define HAVE_DL_ITERATE_PHDR # endif -# ifdef PLATFORM_ANDROID +# ifdef HOST_ANDROID /* Android headers might have no such definition for some targets. */ int dl_iterate_phdr(int (*cb)(struct dl_phdr_info *, size_t, void *), void *data); # endif -#endif /* __GLIBC__ >= 2 || PLATFORM_ANDROID */ +#endif /* __GLIBC__ >= 2 || HOST_ANDROID */ #if (defined(FREEBSD) && __FreeBSD__ >= 7) || defined(__DragonFly__) /* On the FreeBSD system, any target system at major version 7 shall */ @@ -670,11 +670,11 @@ STATIC GC_bool GC_register_dynamic_libraries_dl_iterate_phdr(void) # ifndef PF_W # define PF_W 2 # endif -# elif !defined(PLATFORM_ANDROID) +# elif !defined(HOST_ANDROID) # include # endif -# ifndef PLATFORM_ANDROID +# ifndef HOST_ANDROID # include # endif @@ -750,7 +750,7 @@ GC_INNER void GC_register_dynamic_libraries(void) int i; e = (ElfW(Ehdr) *) lm->l_addr; -# ifdef PLATFORM_ANDROID +# ifdef HOST_ANDROID if (e == NULL) continue; # endif diff --git a/include/gc.h b/include/gc.h index cfb0fd9..3f7c9d5 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1832,7 +1832,7 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); # define GC_DATASTART ((void *)((ulong)_data)) # define GC_DATAEND ((void *)((ulong)_end)) # define GC_INIT_CONF_ROOTS GC_add_roots(GC_DATASTART, GC_DATAEND) -#elif (defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \ +#elif (defined(HOST_ANDROID) || defined(__ANDROID__)) \ && !defined(GC_NOT_DLL) # pragma weak _etext # pragma weak __data_start diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index f99a11f..d1dc5e6 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -329,7 +329,7 @@ /* retrieve the call chain. */ #if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \ || defined(__FreeBSD__) || defined(__DragonFly__) \ - || defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \ + || defined(HOST_ANDROID) || defined(__ANDROID__)) \ && !defined(GC_CAN_SAVE_CALL_STACKS) # define GC_ADD_CALLER # if GC_GNUC_PREREQ(2, 95) @@ -378,7 +378,7 @@ # endif # if !defined(GC_HAVE_PTHREAD_EXIT) \ - && !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) \ + && !defined(HOST_ANDROID) && !defined(__ANDROID__) \ && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS)) # define GC_HAVE_PTHREAD_EXIT /* Intercept pthread_exit on Linux and Solaris. */ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index e01e017..c1d4c0e 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -62,9 +62,9 @@ /* Machine specific parts contributed by various people. See README file. */ -#if defined(__ANDROID__) && !defined(PLATFORM_ANDROID) +#if defined(__ANDROID__) && !defined(HOST_ANDROID) /* __ANDROID__ macro is defined by Android NDK gcc. */ -# define PLATFORM_ANDROID 1 +# define HOST_ANDROID 1 #endif #if defined(TIZEN) && !defined(HOST_TIZEN) @@ -79,7 +79,7 @@ #endif /* First a unified test for Linux: */ -# if (defined(linux) || defined(__linux__) || defined(PLATFORM_ANDROID)) \ +# if (defined(linux) || defined(__linux__) || defined(HOST_ANDROID)) \ && !defined(LINUX) && !defined(__native_client__) # define LINUX # endif @@ -1371,7 +1371,7 @@ # define DYNAMIC_LOADING # include # if defined(__GLIBC__) && __GLIBC__ >= 2 \ - || defined(PLATFORM_ANDROID) || defined(HOST_TIZEN) + || defined(HOST_ANDROID) || defined(HOST_TIZEN) # define SEARCH_FOR_DATA_START # else extern char **__environ; @@ -1388,7 +1388,7 @@ extern int _end[]; # define DATAEND ((ptr_t)(_end)) # if !defined(GC_NO_SIGSETJMP) && (defined(HOST_TIZEN) \ - || (defined(PLATFORM_ANDROID) \ + || (defined(HOST_ANDROID) \ && !(GC_GNUC_PREREQ(4, 8) || GC_CLANG_PREREQ(3, 2) \ || __ANDROID_API__ >= 18))) /* Older Android NDK releases lack sigsetjmp in x86 libc */ @@ -2199,7 +2199,7 @@ # define DYNAMIC_LOADING # include # if defined(__GLIBC__) && __GLIBC__ >= 2 \ - || defined(PLATFORM_ANDROID) || defined(HOST_TIZEN) + || defined(HOST_ANDROID) || defined(HOST_TIZEN) # define SEARCH_FOR_DATA_START # else extern char **__environ; @@ -2674,14 +2674,14 @@ /* Workaround for Android NDK clang 3.5+ (as of NDK r10e) which does */ /* not provide correct _end symbol. Unfortunately, alternate __end__ */ /* symbol is provided only by NDK "bfd" linker. */ -#if defined(PLATFORM_ANDROID) && defined(__clang__) +#if defined(HOST_ANDROID) && defined(__clang__) # undef DATAEND # pragma weak __end__ extern int __end__[]; # define DATAEND (__end__ != 0 ? (ptr_t)__end__ : (ptr_t)_end) #endif -#if (defined(SVR4) || defined(PLATFORM_ANDROID) || defined(HOST_TIZEN)) \ +#if (defined(SVR4) || defined(HOST_ANDROID) || defined(HOST_TIZEN)) \ && !defined(GETPAGESIZE) # include # define GETPAGESIZE() (unsigned)sysconf(_SC_PAGESIZE) @@ -2695,7 +2695,7 @@ # define GETPAGESIZE() (unsigned)getpagesize() #endif -#if defined(PLATFORM_ANDROID) && !(__ANDROID_API__ >= 23) \ +#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \ || defined(ARM32) || defined(I386) /* but not x32 */) /* tkill() exists only on arm32/mips(32)/x86. */ @@ -2883,7 +2883,7 @@ || defined(MIPS) || defined(AVR32) \ || defined(OR1K) || defined(NIOS2))) \ || (defined(LINUX) && !defined(__gnu_linux__)) \ - || (defined(RTEMS) && defined(I386)) || defined(PLATFORM_ANDROID)) \ + || (defined(RTEMS) && defined(I386)) || defined(HOST_ANDROID)) \ && !defined(NO_GETCONTEXT) # define NO_GETCONTEXT #endif @@ -3017,7 +3017,7 @@ # define MIN_STACK_SIZE (8 * HBLKSIZE * sizeof(word)) #endif -#if defined(PLATFORM_ANDROID) && !defined(THREADS) \ +#if defined(HOST_ANDROID) && !defined(THREADS) \ && !defined(USE_GET_STACKBASE_FOR_MAIN) /* Always use pthread_attr_getstack on Android ("-lpthread" option is */ /* not needed to be specified manually) since GC_linux_main_stack_base */ @@ -3027,7 +3027,7 @@ /* Outline pthread primitives to use in GC_get_[main_]stack_base. */ #if ((defined(FREEBSD) && defined(__GLIBC__)) /* kFreeBSD */ \ - || defined(LINUX) || defined(NETBSD) || defined(PLATFORM_ANDROID)) \ + || defined(LINUX) || defined(NETBSD) || defined(HOST_ANDROID)) \ && !defined(NO_PTHREAD_GETATTR_NP) # define HAVE_PTHREAD_GETATTR_NP 1 #elif defined(FREEBSD) && !defined(__GLIBC__) \ @@ -3037,7 +3037,7 @@ #endif #if defined(UNIX_LIKE) && defined(THREADS) && !defined(NO_CANCEL_SAFE) \ - && !defined(PLATFORM_ANDROID) + && !defined(HOST_ANDROID) /* Make the code cancellation-safe. This basically means that we */ /* ensure that cancellation requests are ignored while we are in */ /* the collector. This applies only to Posix deferred cancellation; */ @@ -3071,7 +3071,7 @@ #if defined(CAN_HANDLE_FORK) && !defined(CAN_CALL_ATFORK) \ && !defined(HURD) && !defined(HOST_TIZEN) \ - && (!defined(PLATFORM_ANDROID) || __ANDROID_API__ >= 21) + && (!defined(HOST_ANDROID) || __ANDROID_API__ >= 21) /* Have working pthread_atfork(). */ # define CAN_CALL_ATFORK #endif diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h index cc0ec9f..9f61d8d 100644 --- a/include/private/thread_local_alloc.h +++ b/include/private/thread_local_alloc.h @@ -50,8 +50,8 @@ # endif /* !GNU */ # elif (defined(LINUX) && !defined(ARM32) && !defined(AVR32) \ && GC_GNUC_PREREQ(3, 3) \ - && !(defined(__clang__) && defined(PLATFORM_ANDROID))) \ - || (defined(PLATFORM_ANDROID) && defined(ARM32) \ + && !(defined(__clang__) && defined(HOST_ANDROID))) \ + || (defined(HOST_ANDROID) && defined(ARM32) \ && (GC_GNUC_PREREQ(4, 6) || GC_CLANG_PREREQ_FULL(3, 8, 256229))) # define USE_COMPILER_TLS # elif defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) \ diff --git a/os_dep.c b/os_dep.c index 5827706..aff0899 100644 --- a/os_dep.c +++ b/os_dep.c @@ -409,7 +409,7 @@ GC_INNER char * GC_get_maps(void) # pragma weak __data_start # pragma weak data_start extern int __data_start[], data_start[]; -# ifdef PLATFORM_ANDROID +# ifdef HOST_ANDROID # pragma weak _etext # pragma weak __dso_handle extern int _etext[], __dso_handle[]; @@ -426,7 +426,7 @@ GC_INNER char * GC_get_maps(void) # if (defined(LINUX) || defined(HURD)) && !defined(IGNORE_PROG_DATA_START) /* Try the easy approaches first: */ -# ifdef PLATFORM_ANDROID +# ifdef HOST_ANDROID /* Workaround for "gold" (default) linker (as of Android NDK r10e). */ if ((word)__data_start < (word)_etext && (word)_etext < (word)__dso_handle) { diff --git a/pthread_support.c b/pthread_support.c index f22570d..9813553 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -893,7 +893,7 @@ STATIC void GC_remove_all_threads_but_me(void) #elif defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \ || defined(GC_SOLARIS_THREADS) || defined(HURD) \ - || defined(PLATFORM_ANDROID) || defined(NACL) + || defined(HOST_ANDROID) || defined(NACL) GC_INLINE int GC_get_nprocs(void) { int nprocs = (int)sysconf(_SC_NPROCESSORS_ONLN); @@ -907,7 +907,7 @@ STATIC void GC_remove_all_threads_but_me(void) return nprocs > 0 ? nprocs : 1; /* ignore error silently */ } -#elif defined(GC_LINUX_THREADS) /* && !PLATFORM_ANDROID && !NACL */ +#elif defined(GC_LINUX_THREADS) /* && !HOST_ANDROID && !NACL */ /* Return the number of processors. */ STATIC int GC_get_nprocs(void) { diff --git a/tests/initsecondarythread.c b/tests/initsecondarythread.c index 9893fb5..96a21e2 100644 --- a/tests/initsecondarythread.c +++ b/tests/initsecondarythread.c @@ -72,7 +72,7 @@ int main(void) || defined(CYGWIN32) || defined(GC_OPENBSD_UTHREADS) \ || (defined(DARWIN) && !defined(NO_PTHREAD_GET_STACKADDR_NP)) \ || ((defined(FREEBSD) || defined(LINUX) || defined(NETBSD) \ - || defined(PLATFORM_ANDROID)) && !defined(NO_PTHREAD_GETATTR_NP) \ + || defined(HOST_ANDROID)) && !defined(NO_PTHREAD_GETATTR_NP) \ && !defined(NO_PTHREAD_ATTR_GET_NP)) \ || (defined(GC_SOLARIS_THREADS) && !defined(_STRICT_STDC)) \ || (!defined(STACKBOTTOM) && (defined(HEURISTIC1) \ diff --git a/tests/test.c b/tests/test.c index c8d6204..5ba97c5 100644 --- a/tests/test.c +++ b/tests/test.c @@ -148,7 +148,7 @@ /* Call GC_INIT only on platforms on which we think we really need it, */ /* so that we can test automatic initialization on the rest. */ #if defined(TEST_EXPLICIT_GC_INIT) || defined(AIX) || defined(CYGWIN32) \ - || defined(DARWIN) || defined(PLATFORM_ANDROID) \ + || defined(DARWIN) || defined(HOST_ANDROID) \ || (defined(MSWINCE) && !defined(GC_WINMAIN_REDIRECT)) # define GC_OPT_INIT GC_INIT() #else diff --git a/tools/threadlibs.c b/tools/threadlibs.c index 851e7e5..832b3d1 100644 --- a/tools/threadlibs.c +++ b/tools/threadlibs.c @@ -27,7 +27,7 @@ int main(void) "-Wl,--wrap -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask " "-Wl,--wrap -Wl,pthread_exit -Wl,--wrap -Wl,pthread_cancel\n"); # endif -# if (defined(GC_LINUX_THREADS) && !defined(PLATFORM_ANDROID)) \ +# if (defined(GC_LINUX_THREADS) && !defined(HOST_ANDROID)) \ || defined(GC_IRIX_THREADS) || defined(GC_DARWIN_THREADS) \ || defined(GC_AIX_THREADS) || (defined(HURD) && defined(GC_THREADS)) # ifdef GC_USE_DLOPEN_WRAP -- 2.7.4