summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--gc_dlopen.c21
-rw-r--r--mark.c2
-rw-r--r--os_dep.c19
-rw-r--r--pthread_support.c7
5 files changed, 52 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 29933cb1..c1d17e6e 100644
--- 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
diff --git a/gc_dlopen.c b/gc_dlopen.c
index 98c699f2..d8d6e1d9 100644
--- a/gc_dlopen.c
+++ b/gc_dlopen.c
@@ -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);
@@ -64,22 +66,23 @@
#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 fecec5e0..5320a49a 100644
--- 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
diff --git a/os_dep.c b/os_dep.c
index fa4a8c97..ea266e63 100644
--- 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.
diff --git a/pthread_support.c b/pthread_support.c
index 12fb106f..6b1770c1 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -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];