2010-03-12 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Fri, 12 Mar 2010 13:20:22 +0000 (13:20 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:53 +0000 (21:06 +0400)
* 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.

ChangeLog
doc/README.macros
os_dep.c

index c4755f4..c35fda8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-12  Ivan Maidanski <ivmai@mail.ru>
+
+       * 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 <ivmai@mail.ru> (really Burkhard Linke)
 
        * os_dep.c (GC_get_stack_base): Add LOCK/UNLOCK() (since
index 825357c..166c105 100644 (file)
@@ -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).
index 55d2311..c84e2ff 100644 (file)
--- 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