diff --git a/ChangeLog b/ChangeLog index c4755f4f7..c35fda850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-03-12 Ivan Maidanski + + * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Document. + * os_dep.c (GC_get_main_stack_base): Recognize + USE_GET_STACKBASE_FOR_MAIN (only if THREADS and LINUX_STACKBOTTOM) + and use GC_get_stack_base() in this case. + 2010-03-05 Ivan Maidanski (really Burkhard Linke) * os_dep.c (GC_get_stack_base): Add LOCK/UNLOCK() (since diff --git a/doc/README.macros b/doc/README.macros index 825357c9c..166c10523 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -511,3 +511,7 @@ UNICODE (Win32 only) Use the Unicode variant ('W') of the Win32 API instead of ANSI/ASCII one ('A'). Useful for WinCE. PLATFORM_ANDROID Compile for Android NDK platform. + +USE_GET_STACKBASE_FOR_MAIN (Linux only) Use pthread_attr_getstack() instead +of __libc_stack_end for getting the primordial thread stack base (useful if +the client modifies the program's address space). diff --git a/os_dep.c b/os_dep.c index 55d231118..c84e2ff5c 100644 --- a/os_dep.c +++ b/os_dep.c @@ -1163,6 +1163,13 @@ ptr_t GC_get_main_stack_base(void) # endif # endif /* HEURISTIC1 */ # ifdef LINUX_STACKBOTTOM +# if defined(THREADS) && defined(USE_GET_STACKBASE_FOR_MAIN) + { + struct GC_stack_base sb; + if (GC_get_stack_base(&sb) == GC_SUCCESS) + return (ptr_t)sb.mem_base; + } +# endif result = GC_linux_stack_base(); # endif # ifdef FREEBSD_STACKBOTTOM