]> granicus.if.org Git - gc/commitdiff
2006-03-07 Andrew Haley <aph@redhat.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 Apr 2006 13:40:21 +0000 (13:40 +0000)
committerguest <ivmai@mail.ru>
Fri, 29 Jul 2011 06:54:27 +0000 (10:54 +0400)
        * dyn_load.c (GC_has_static_roots): Declare.
        (GC_register_dynlib_callback): Call GC_has_static_roots.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113223 138bc75d-0d04-0410-961f-82ee72b054a4

ChangeLog
dyn_load.c
include/gc.h

index 936d3bfc2332dab687ab04a9790814b0c79d778f..a27b9f3518db7181ca55c3e280e48bbd90573437 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-07  Andrew Haley  <aph@redhat.com>
+
+       * dyn_load.c (GC_has_static_roots): Declare.
+       (GC_register_dynlib_callback): Call GC_has_static_roots.
+
 2006-04-11  Bryce McKinlay  <mckinlay@redhat.com>
 
        * darwin_stop_world.c (GC_push_all_stacks, GC_stop_world,
index 749bf824681a7d14831a8cb5a9b44c226614b158..94e66092e3133643d07661f22ff41f19291013b4 100644 (file)
 #    endif
 #  endif
 
+/* An user-supplied routine that is called to dtermine if a DSO must
+   be scanned by the gc.  */
+static int (*GC_has_static_roots)(const char *, void *, size_t);
+/* Register the routine.  */
+void
+GC_register_has_static_roots_callback 
+  (int (*callback)(const char *, void *, size_t))
+{
+  GC_has_static_roots = callback;
+}
+
 #if defined(SUNOS5DL) && !defined(USE_PROC_FOR_LIBRARIES)
 
 #ifdef LINT
@@ -371,7 +382,7 @@ GC_bool GC_register_main_static_data()
 {
   return FALSE;
 }
-  
+
 # define HAVE_REGISTER_MAIN_STATIC_DATA
 
 #endif /* USE_PROC_FOR_LIBRARIES */
@@ -411,6 +422,11 @@ static int GC_register_dynlib_callback(info, size, ptr)
        {
          if( !(p->p_flags & PF_W) ) break;
          start = ((char *)(p->p_vaddr)) + info->dlpi_addr;
+
+         if (GC_has_static_roots 
+             && !GC_has_static_roots(info->dlpi_name, start, p->p_memsz))
+           break;
+
          GC_add_roots_inner(start, start + p->p_memsz, TRUE);
        }
       break;
index cfc8658ac39962962f2b5b13717ec57cad9a0607..3507db74dc51955e813c2f8ca43f9938ff6ea526 100644 (file)
@@ -925,6 +925,15 @@ extern void GC_thr_init GC_PROTO((void));/* Needed for Solaris/X86 */
 
 #endif /* THREADS && !SRC_M3 */
 
+/* Register a callback to control the scanning of dynamic libraries.
+   When the GC scans the static data of a dynamic library, it will
+   first call a user-supplied routine with filename of the library and
+   the address and length of the memory region.  This routine should
+   return nonzero if that region should be scanned.  */
+GC_API void GC_register_has_static_roots_callback 
+  (int (*callback)(const char *, void *, size_t));
+
+
 #if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
 # include <windows.h>