From: Ivan Maidanski Date: Thu, 26 Jan 2012 16:36:57 +0000 (+0400) Subject: Fix static data roots registration on Android (if GC is shared X-Git-Tag: gc7_3alpha2~177 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfc23845108c8efc185a1393405e5fb4c0d4619d;p=gc Fix static data roots registration on Android (if GC is shared library) by defining GC_INIT_CONF_ROOTS * include/gc.h (GC_INIT_CONF_ROOTS): Define to register static data root in range from "__data_start" to "_end" on Android (unless explicitly prohibited by client via GC_NOT_DLL macro) since the client data root is not registered automatically if GC is build as a shared library. * tests/test.c (GC_COND_INIT): Invoke GC_INIT also on Android. --- diff --git a/include/gc.h b/include/gc.h index cdaf39e4..5f06c384 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1439,6 +1439,11 @@ 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__)) \ + && !defined(GC_NOT_DLL) + /* Required if GC is built as shared library. */ + extern int __data_start[], _end[]; +# define GC_INIT_CONF_ROOTS GC_add_roots(__data_start, _end) #else # define GC_INIT_CONF_ROOTS /* empty */ #endif diff --git a/tests/test.c b/tests/test.c index 863d0c97..22e5118a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -92,7 +92,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(CYGWIN32) || defined (AIX) || defined(DARWIN) \ - || defined(THREAD_LOCAL_ALLOC) \ + || defined(PLATFORM_ANDROID) || defined(THREAD_LOCAL_ALLOC) \ || (defined(MSWINCE) && !defined(GC_WINMAIN_REDIRECT)) # define GC_COND_INIT() GC_INIT(); CHECH_GCLIB_VERSION #else