+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
# 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. */
/* 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
}
#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 ... */
void *alt_path;
} ext_ex_regn;
-
static EXCEPTION_DISPOSITION mark_ex_handler(
struct _EXCEPTION_RECORD *ex_rec,
void *est_frame,
/* FIXME: We should probably add a header word to address */
/* this. */
}
+# undef source
# ifdef TRACE_BUF
# 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)
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)
/* 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;
return(KERN_INVALID_ARGUMENT);
}
-
#endif /* DARWIN && MPROTECT_VDB */
# ifndef HAVE_INCREMENTAL_PROTECTION_NEEDS
}
# 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.
/* 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];