2009-10-17 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sat, 17 Oct 2009 21:54:30 +0000 (21:54 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:50 +0000 (21:06 +0400)
* gc_dlopen.c (GC_MUST_RESTORE_REDEFINED_DLOPEN): Define if dlopen
redirection is turned off; turn it on later when dlopen real
symbol is no longer needed (according to the comment and the same
as in dyn_load.c).
* gc_dlopen.c (WRAP_FUNC, REAL_FUNC): Rename to WRAP_DLFUNC and
REAL_DLFUNC, respectively (to have unique names since the
definitions may differ from that of the similar ones in
pthread_support.c).
* mark.c (source): Undefine the macro when no longer needed.
* os_dep.c (handler): Rename the type to GC_fault_handler_t (to
have the unique name across the project).
* os_dep.c (STAT_BUF_SIZE, STAT_READ); Guard with ifndef; add the
comment.
* pthread_support.c (STAT_BUF_SIZE, STAT_READ): Ditto.
* os_dep.c (sbrk): Undo sbrk() redirection (for ECOS) when no
longer needed.

ChangeLog
gc_dlopen.c
mark.c
os_dep.c
pthread_support.c

index 29933cb..c1d17e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2009-10-17  Ivan Maidanski <ivmai@mail.ru>
 
+       * gc_dlopen.c (GC_MUST_RESTORE_REDEFINED_DLOPEN): Define if dlopen
+       redirection is turned off; turn it on later when dlopen real
+       symbol is no longer needed (according to the comment and the same
+       as in dyn_load.c).
+       * gc_dlopen.c (WRAP_FUNC, REAL_FUNC): Rename to WRAP_DLFUNC and
+       REAL_DLFUNC, respectively (to have unique names since the
+       definitions may differ from that of the similar ones in
+       pthread_support.c).
+       * mark.c (source): Undefine the macro when no longer needed.
+       * os_dep.c (handler): Rename the type to GC_fault_handler_t (to
+       have the unique name across the project).
+       * os_dep.c (STAT_BUF_SIZE, STAT_READ); Guard with ifndef; add the
+       comment.
+       * pthread_support.c (STAT_BUF_SIZE, STAT_READ): Ditto.
+       * os_dep.c (sbrk): Undo sbrk() redirection (for ECOS) when no
+       longer needed.
+
+2009-10-17  Ivan Maidanski <ivmai@mail.ru>
+
        * pthread_stop_world.c (pthread_sigmask): Undefine before using
        in GC_print_sig_mask() (only if DEBUG_THREADS); add the comment.
        * win32_threads.c (dlopen, _beginthread): Don't undefine (since
index 98c699f..d8d6e1d 100644 (file)
@@ -28,6 +28,7 @@
 # if (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) && !defined(GC_WIN32_PTHREADS)\
       || defined(GC_SOLARIS_THREADS)
 
+# undef GC_MUST_RESTORE_REDEFINED_DLOPEN
 # if defined(dlopen) && !defined(GC_USE_LD_WRAP)
     /* To support various threads pkgs, gc.h interposes on dlopen by     */
     /* defining "dlopen" to be "GC_dlopen", which is implemented below.  */
@@ -35,6 +36,7 @@
     /* real system dlopen() in their implementation. We first remove     */
     /* gc.h's dlopen definition and restore it later, after GC_dlopen(). */
 #   undef dlopen
+#   define GC_MUST_RESTORE_REDEFINED_DLOPEN
 # endif
 
   GC_bool GC_collection_in_progress(void);
 
 #include <dlfcn.h>
 
+/* This is similar to WRAP/REAL_FUNC() in pthread_support.c. */
 #ifdef GC_USE_LD_WRAP
-#   define WRAP_FUNC(f) __wrap_##f
-#   define REAL_FUNC(f) __real_##f
+#   define WRAP_DLFUNC(f) __wrap_##f
+#   define REAL_DLFUNC(f) __real_##f
 #else
-#   define WRAP_FUNC(f) GC_##f
-#   define REAL_FUNC(f) f
+#   define WRAP_DLFUNC(f) GC_##f
+#   define REAL_DLFUNC(f) f
 #endif
 
-GC_API void * WRAP_FUNC(dlopen)(const char *path, int mode)
+GC_API void * WRAP_DLFUNC(dlopen)(const char *path, int mode)
 {
     void * result;
 
 #   ifndef USE_PROC_FOR_LIBRARIES
       disable_gc_for_dlopen();
 #   endif
-    result = (void *)REAL_FUNC(dlopen)(path, mode);
+    result = (void *)REAL_DLFUNC(dlopen)(path, mode);
 #   ifndef USE_PROC_FOR_LIBRARIES
       GC_enable(); /* undoes disable_gc_for_dlopen */
 #   endif
@@ -96,4 +99,8 @@ GC_API void * WRAP_FUNC(dlopen)(const char *path, int mode)
   }
 #endif /* Linker-based interception. */
 
-# endif  /* GC_PTHREADS || GC_SOLARIS_THREADS ... */
+# ifdef GC_MUST_RESTORE_REDEFINED_DLOPEN
+#   define dlopen GC_dlopen
+# endif
+
+#endif  /* GC_PTHREADS || GC_SOLARIS_THREADS ... */
diff --git a/mark.c b/mark.c
index fecec5e..5320a49 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -443,7 +443,6 @@ static void alloc_mark_stack(size_t);
       void *alt_path;
     } ext_ex_regn;
 
-
     static EXCEPTION_DISPOSITION mark_ex_handler(
         struct _EXCEPTION_RECORD *ex_rec,
         void *est_frame,
@@ -1440,6 +1439,7 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj,
     /* FIXME: We should probably add a header word to address   */
     /* this.                                                    */
 }
+# undef source
 
 # ifdef TRACE_BUF
 
index fa4a8c9..ea266e6 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -756,7 +756,7 @@ ptr_t GC_get_main_stack_base(void)
 
 # if defined(NEED_FIND_LIMIT) || defined(UNIX_LIKE)
 
-    typedef void (*handler)(int);
+    typedef void (*GC_fault_handler_t)(int);
 
 #   if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \
     || defined(HURD) || defined(NETBSD)
@@ -766,10 +766,10 @@ ptr_t GC_get_main_stack_base(void)
             static struct sigaction old_bus_act;
 #       endif
 #   else
-        static handler old_segv_handler, old_bus_handler;
+        static GC_fault_handler_t old_segv_handler, old_bus_handler;
 #   endif
 
-    void GC_set_and_save_fault_handler(handler h)
+    void GC_set_and_save_fault_handler(GC_fault_handler_t h)
     {
 #       if defined(SUNOS5SIGS) || defined(IRIX5)  \
         || defined(OSF1) || defined(HURD) || defined(NETBSD)
@@ -966,8 +966,11 @@ ptr_t GC_get_main_stack_base(void)
     /* We read the stack base value from /proc/self/stat.  We do this   */
     /* using direct I/O system calls in order to avoid calling malloc   */
     /* in case REDIRECT_MALLOC is defined.                              */
-#   define STAT_BUF_SIZE 4096
-#   define STAT_READ read
+#   ifndef STAT_READ
+      /* Also defined in pthread_support.c. */
+#     define STAT_BUF_SIZE 4096
+#     define STAT_READ read
+#   endif
           /* Should probably call the real read, if read is wrapped.    */
     char stat_buf[STAT_BUF_SIZE];
     int f;
@@ -4027,7 +4030,6 @@ catch_exception_raise_state_identity(mach_port_name_t exception_port,
   return(KERN_INVALID_ARGUMENT);
 }
 
-
 #endif /* DARWIN && MPROTECT_VDB */
 
 # ifndef HAVE_INCREMENTAL_PROTECTION_NEEDS
@@ -4037,6 +4039,11 @@ catch_exception_raise_state_identity(mach_port_name_t exception_port,
   }
 # endif /* !HAVE_INCREMENTAL_PROTECTION_NEEDS */
 
+#ifdef ECOS
+  /* Undo sbrk() redirection. */
+# undef sbrk
+#endif
+
 /*
  * Call stack save code for debugging.
  * Should probably be in mach_dep.c, but that requires reorganization.
index 12fb106..6b1770c 100644 (file)
@@ -617,8 +617,11 @@ STATIC int GC_get_nprocs(void)
     /* Should be "return sysconf(_SC_NPROCESSORS_ONLN);" but that       */
     /* appears to be buggy in many cases.                               */
     /* We look for lines "cpu<n>" in /proc/stat.                        */
-#   define STAT_BUF_SIZE 4096
-#   define STAT_READ read
+#   ifndef STAT_READ
+      /* Also defined in os_dep.c. */
+#     define STAT_BUF_SIZE 4096
+#     define STAT_READ read
+#   endif
         /* If read is wrapped, this may need to be redefined to call    */
         /* the real one.                                                */
     char stat_buf[STAT_BUF_SIZE];