From cfc23845108c8efc185a1393405e5fb4c0d4619d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 26 Jan 2012 20:36:57 +0400 Subject: [PATCH] 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. --- include/gc.h | 5 +++++ tests/test.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- 2.40.0