diff options
Diffstat (limited to 'boehm-gc/include/gc_pthread_redirects.h')
-rw-r--r-- | boehm-gc/include/gc_pthread_redirects.h | 139 |
1 files changed, 76 insertions, 63 deletions
diff --git a/boehm-gc/include/gc_pthread_redirects.h b/boehm-gc/include/gc_pthread_redirects.h index 842518cfcc4..37cb249ac04 100644 --- a/boehm-gc/include/gc_pthread_redirects.h +++ b/boehm-gc/include/gc_pthread_redirects.h @@ -1,82 +1,95 @@ -/* Our pthread support normally needs to intercept a number of thread */ -/* calls. We arrange to do that here, if appropriate. */ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * Copyright (c) 1998 by Fergus Henderson. All rights reserved. + * Copyright (c) 2000-2010 by Hewlett-Packard Development Company. + * All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ -#ifndef GC_PTHREAD_REDIRECTS_H +/* Our pthread support normally needs to intercept a number of thread */ +/* calls. We arrange to do that here, if appropriate. */ -#define GC_PTHREAD_REDIRECTS_H +/* Included from gc.h only. Included only if GC_PTHREADS. */ +#if defined(GC_H) && defined(GC_PTHREADS) -#if defined(GC_SOLARIS_THREADS) -/* 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 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 <thread.h> - int GC_thr_create(void *stack_base, size_t stack_size, - void *(*start_routine)(void *), void *arg, long flags, - thread_t *new_thread); - int GC_thr_join(thread_t wait_for, thread_t *departed, void **status); - int GC_thr_suspend(thread_t target_thread); - int GC_thr_continue(thread_t target_thread); - void * GC_dlopen(const char *path, int mode); -# define thr_create GC_thr_create -# define thr_join GC_thr_join -# define thr_suspend GC_thr_suspend -# define thr_continue GC_thr_continue -#endif /* GC_SOLARIS_THREADS */ +/* 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_SOLARIS_PTHREADS) -# include <pthread.h> +#include <pthread.h> + +#ifndef GC_NO_DLOPEN +# include <dlfcn.h> + GC_API void *GC_dlopen(const char * /* path */, int /* mode */); +#endif /* !GC_NO_DLOPEN */ + +#ifndef GC_NO_PTHREAD_SIGMASK # include <signal.h> - extern int GC_pthread_create(pthread_t *new_thread, - const pthread_attr_t *attr, - void * (*thread_execp)(void *), void *arg); - extern int GC_pthread_join(pthread_t wait_for, void **status); -# define pthread_join GC_pthread_join -# define pthread_create GC_pthread_create -#endif + GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *, + sigset_t * /* oset */); +#endif /* !GC_NO_PTHREAD_SIGMASK */ -#if defined(GC_SOLARIS_PTHREADS) || defined(GC_SOLARIS_THREADS) -# define dlopen GC_dlopen -#endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */ +#ifndef GC_PTHREAD_CREATE_CONST + /* This is used for pthread_create() only. */ +# define GC_PTHREAD_CREATE_CONST const +#endif +GC_API int GC_pthread_create(pthread_t *, + GC_PTHREAD_CREATE_CONST pthread_attr_t *, + void *(*)(void *), void * /* arg */); +GC_API int GC_pthread_join(pthread_t, void ** /* retval */); +GC_API int GC_pthread_detach(pthread_t); -#if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) && !defined(GC_SOLARIS_PTHREADS) -/* We treat these similarly. */ -# include <pthread.h> -# include <signal.h> +#ifndef GC_NO_PTHREAD_CANCEL + GC_API int GC_pthread_cancel(pthread_t); +#endif - int GC_pthread_create(pthread_t *new_thread, - const pthread_attr_t *attr, - void *(*start_routine)(void *), void *arg); -#ifndef GC_DARWIN_THREADS - int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); +#if defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(GC_PTHREAD_EXIT_DECLARED) +# define GC_PTHREAD_EXIT_DECLARED + GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE; #endif - int GC_pthread_join(pthread_t thread, void **retval); - int GC_pthread_detach(pthread_t thread); -#if defined(GC_OSF1_THREADS) \ - && defined(_PTHREAD_USE_MANGLED_NAMES_) && !defined(_PTHREAD_USE_PTDNAM_) -/* Unless the compiler supports #pragma extern_prefix, the Tru64 UNIX - <pthread.h> redefines some POSIX thread functions to use mangled names. - If so, undef them before redefining. */ +#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 -#endif - # define pthread_create GC_pthread_create # define pthread_join GC_pthread_join # define pthread_detach GC_pthread_detach -#ifndef GC_DARWIN_THREADS -# define pthread_sigmask GC_pthread_sigmask -# define dlopen GC_dlopen -#endif - -#endif /* GC_xxxxx_THREADS */ +# ifndef GC_NO_PTHREAD_SIGMASK +# undef pthread_sigmask +# define pthread_sigmask GC_pthread_sigmask +# endif +# ifndef GC_NO_DLOPEN +# undef dlopen +# define dlopen GC_dlopen +# endif +# ifndef GC_NO_PTHREAD_CANCEL +# undef pthread_cancel +# define pthread_cancel GC_pthread_cancel +# endif +# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# undef pthread_exit +# define pthread_exit GC_pthread_exit +# endif +#endif /* !GC_NO_THREAD_REDIRECTS */ -#endif /* GC_PTHREAD_REDIRECTS_H */ +#endif /* GC_PTHREADS */ |