diff options
author | ivmai <ivmai> | 2010-08-14 08:06:17 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:54 +0400 |
commit | 9fe5bf2f4a698aeb4d24322844a113a0d0178a26 (patch) | |
tree | 76bdf6b856af7e9e5584741edf8c66c48aedeb58 /include/gc_pthread_redirects.h | |
parent | 0bf3ec4a9e0ed4ff241c57c36cb63544a6899513 (diff) | |
download | bdwgc-9fe5bf2f4a698aeb4d24322844a113a0d0178a26.tar.gz |
2010-08-14 Ivan Maidanski <ivmai@mail.ru> (with help from Hans Boehm)
* include/gc_pthread_redirects.h: Test GC_PTHREADS and GC_H at the
beginning of the file.
* include/gc_pthread_redirects.h (GC_PTHREAD_EXIT_ATTRIBUTE): New
macro (defined only for Linux and Solaris).
* include/gc_pthread_redirects.h (GC_pthread_cancel,
GC_pthread_exit): Declare new API function (only if
GC_PTHREAD_EXIT_ATTRIBUTE).
* include/gc_pthread_redirects.h (pthread_cancel, pthread_exit):
Redirect (if GC_PTHREAD_EXIT_ATTRIBUTE).
* include/private/pthread_support.h (DISABLED_GC): New macro.
* pthread_support.c (pthread_cancel, pthread_exit): Restore
original definition or declare "real" function (if needed and
GC_PTHREAD_EXIT_ATTRIBUTE).
* pthread_support.c (GC_pthread_cancel_t, GC_pthread_exit_t):
Declare new types if needed.
* pthread_support.c (GC_pthread_cancel, GC_pthread_exit): New
function definition (only if GC_PTHREAD_EXIT_ATTRIBUTE).
* pthread_support.c (GC_init_real_syms): Initialise pointers to
the "real" pthread_cancel and pthread_exit (only if
GC_PTHREAD_EXIT_ATTRIBUTE).
* pthread_support.c (GC_unregister_my_thread): Enable collections
if DISABLED_GC was set (only if GC_PTHREAD_EXIT_ATTRIBUTE).
* pthread_support.c (pthread_cancel, pthread_exit): New wrapped
function definition (only if GC_PTHREAD_EXIT_ATTRIBUTE defined).
* pthread_support.c (GC_start_routine): Refine the comment.
* extra/threadlibs.c (main): Adjust --wrap (add "read",
"pthread_exit", "pthread_cancel" but remove "sleep").
* doc/README.linux (GC_USE_LD_WRAP): Ditto.
* doc/README.linux: Expand all tabs to spaces; remove trailing
spaces at EOLn.
Diffstat (limited to 'include/gc_pthread_redirects.h')
-rw-r--r-- | include/gc_pthread_redirects.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index 7e1162b6..9405646e 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -2,7 +2,7 @@ * 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-2009 by Hewlett-Packard Development Company. + * Copyright (c) 2000-2010 by Hewlett-Packard Development Company. * All rights reserved. * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED @@ -19,6 +19,7 @@ /* calls. We arrange to do that here, if appropriate. */ /* Included from gc.h only. Included only if GC_PTHREADS. */ +#if defined(GC_H) && 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. */ @@ -47,11 +48,27 @@ GC_API int GC_pthread_create(pthread_t *, const pthread_attr_t *, GC_API int GC_pthread_join(pthread_t, void ** /* retval */); GC_API int GC_pthread_detach(pthread_t); +#if !defined(GC_PTHREAD_EXIT_ATTRIBUTE) \ + && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS)) + /* Intercept pthread_cancel and pthread_exit on Linux and Solaris. */ +# if defined(__GNUC__) /* since GCC v2.7 */ +# define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__)) +# elif defined(__NORETURN) /* used in Solaris */ +# define GC_PTHREAD_EXIT_ATTRIBUTE __NORETURN +# else +# define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ +# endif +#endif + +#ifdef GC_PTHREAD_EXIT_ATTRIBUTE + GC_API int GC_pthread_cancel(pthread_t); + GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE; +#endif + #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. */ + /* 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 @@ -68,4 +85,13 @@ GC_API int GC_pthread_detach(pthread_t); # undef dlopen # define dlopen GC_dlopen # endif + +# ifdef GC_PTHREAD_EXIT_ATTRIBUTE +# undef pthread_cancel +# define pthread_cancel GC_pthread_cancel +# undef pthread_exit +# define pthread_exit GC_pthread_exit +# endif #endif /* !GC_NO_THREAD_REDIRECTS */ + +#endif /* GC_PTHREADS */ |