diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | gc_dlopen.c | 10 | ||||
-rw-r--r-- | include/gc.h | 3 | ||||
-rw-r--r-- | include/gc_pthread_redirects.h | 72 |
4 files changed, 59 insertions, 39 deletions
@@ -1,3 +1,16 @@ +2009-10-01 Ivan Maidanski <ivmai@mail.ru> + + * gc_dlopen.c (GC_dlopen): Add function redirector (only if + GC_USE_LD_WRAP). + * include/gc.h: Include "gc_pthread_redirects.h" even if + GC_USE_LD_WRAP or GC_NO_THREAD_REDIRECTS. + * include/gc_pthread_redirects.h (GC_PTHREAD_REDIRECTS_H): Don't + define and check for (since included only from gc.h). + * include/gc_pthread_redirects.h: Declare "GC_" symbols even if + GC_USE_LD_WRAP or GC_NO_THREAD_REDIRECTS. + * include/gc_pthread_redirects.h: Include signal.h only to get + sigset_t definition. + 2009-09-30 Ivan Maidanski <ivmai@mail.ru> * configure: Regenerate (by autoreconf -vif, deleting libtool.m4 diff --git a/gc_dlopen.c b/gc_dlopen.c index c0ca658a..64619848 100644 --- a/gc_dlopen.c +++ b/gc_dlopen.c @@ -85,4 +85,14 @@ GC_API void * WRAP_FUNC(dlopen)(const char *path, int mode) # endif return(result); } + +#ifdef GC_USE_LD_WRAP + /* Define GC_ function as an alias for the plain one, which will be */ + /* intercepted. This allows files which include gc.h, and hence */ + /* generate references to the GC_ symbol, to see the right symbol. */ + GC_API int GC_dlopen(const char *path, int mode) { + return dlopen(path, mode); + } +#endif /* Linker-based interception. */ + # endif /* GC_PTHREADS || GC_SOLARIS_THREADS ... */ diff --git a/include/gc.h b/include/gc.h index cc774648..037bbd3f 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1179,8 +1179,7 @@ GC_API void (GC_CALLBACK * GC_is_visible_print_proc)(void *); /* For pthread support, we generally need to intercept a number of */ /* thread library calls. We do that here by macro defining them. */ -#if !defined(GC_USE_LD_WRAP) && !defined(GC_NO_THREAD_REDIRECTS) \ - && defined(GC_PTHREADS) +#ifdef GC_PTHREADS # include "gc_pthread_redirects.h" #endif diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index 270236bb..8c8a21b3 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -18,52 +18,50 @@ /* Our pthread support normally needs to intercept a number of thread */ /* calls. We arrange to do that here, if appropriate. */ -#ifndef GC_PTHREAD_REDIRECTS_H +/* Included from gc.h only. Included only if GC_PTHREADS. */ -#define GC_PTHREAD_REDIRECTS_H +/* We need to intercept calls to many of the threads primitives, so */ +/* that we can locate thread stacks and stop the world. */ +/* Note also that the collector cannot always see thread specific data. */ +/* Thread specific data should generally consist of pointers to */ +/* uncollectable objects (allocated with GC_malloc_uncollectable, */ +/* not the system malloc), which are deallocated using the destructor */ +/* facility in thr_keycreate. Alternatively, keep a redundant pointer */ +/* to thread specific data on the thread stack. */ -#if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) -/* We need to intercept calls to many of the threads primitives, so */ -/* that we can locate thread stacks and stop the world. */ -/* Note also that the collector cannot always see thread specific data. */ -/* Thread specific data should generally consist of pointers to */ -/* uncollectable objects (allocated with GC_malloc_uncollectable, */ -/* not the system malloc), which are deallocated using the destructor */ -/* facility in thr_keycreate. Alternatively, keep a redundant pointer */ -/* to thread specific data on the thread stack. */ +#include <pthread.h> -# include <pthread.h> +#ifndef GC_DARWIN_THREADS # include <signal.h> +# include <dlfcn.h> -# if !defined(GC_DARWIN_THREADS) -# include <dlfcn.h> - - GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, - sigset_t * /* oset */); - GC_API void *GC_dlopen(const char * /* path */, int /* mode */); - -# undef pthread_sigmask -# undef dlopen -# define pthread_sigmask GC_pthread_sigmask -# define dlopen GC_dlopen -# endif + GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, + sigset_t * /* oset */); + GC_API void *GC_dlopen(const char * /* path */, int /* mode */); +#endif GC_API int GC_pthread_create(pthread_t *, const pthread_attr_t *, - void *(*)(void *), void * /* arg */); + void *(*)(void *), void * /* arg */); GC_API int GC_pthread_join(pthread_t, void ** /* retval */); GC_API int GC_pthread_detach(pthread_t); -/* Unless the compiler supports #pragma extern_prefix, the Tru64 UNIX */ -/* <pthread.h> redefines some POSIX thread functions to use mangled */ -/* names. Anyway, it's safe to undef them before redefining. */ -#undef pthread_create -#undef pthread_join -#undef pthread_detach +#if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP) + /* Unless the compiler supports #pragma extern_prefix, the Tru64 */ + /* UNIX <pthread.h> redefines some POSIX thread functions to use */ + /* mangled names. Anyway, it's safe to undef them before */ + /* redefining. */ +# undef pthread_create +# undef pthread_join +# undef pthread_detach -#define pthread_create GC_pthread_create -#define pthread_join GC_pthread_join -#define pthread_detach GC_pthread_detach +# define pthread_create GC_pthread_create +# define pthread_join GC_pthread_join +# define pthread_detach GC_pthread_detach -#endif /* GC_PTHREADS && !GC_USE_LD_WRAP */ - -#endif /* GC_PTHREAD_REDIRECTS_H */ +# ifndef GC_DARWIN_THREADS +# undef pthread_sigmask +# undef dlopen +# define pthread_sigmask GC_pthread_sigmask +# define dlopen GC_dlopen +# endif +#endif /* !GC_NO_THREAD_REDIRECTS */ |