2 * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
3 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
4 * Copyright (c) 1998 by Fergus Henderson. All rights reserved.
5 * Copyright (c) 2000-2010 by Hewlett-Packard Development Company.
8 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
11 * Permission is hereby granted to use or copy this program
12 * for any purpose, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
18 /* Our pthread support normally needs to intercept a number of thread */
19 /* calls. We arrange to do that here, if appropriate. */
21 /* Included from gc.h only. Included only if GC_PTHREADS. */
22 #if defined(GC_H) && defined(GC_PTHREADS)
24 /* We need to intercept calls to many of the threads primitives, so */
25 /* that we can locate thread stacks and stop the world. */
26 /* Note also that the collector cannot always see thread specific data. */
27 /* Thread specific data should generally consist of pointers to */
28 /* uncollectable objects (allocated with GC_malloc_uncollectable, */
29 /* not the system malloc), which are deallocated using the destructor */
30 /* facility in thr_keycreate. Alternatively, keep a redundant pointer */
31 /* to thread specific data on the thread stack. */
37 GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
38 #endif /* !GC_NO_DLOPEN */
40 #ifndef GC_NO_PTHREAD_SIGMASK
42 GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
43 sigset_t * /* oset */);
44 #endif /* !GC_NO_PTHREAD_SIGMASK */
46 #ifndef GC_PTHREAD_CREATE_CONST
47 /* This is used for pthread_create() only. */
48 # define GC_PTHREAD_CREATE_CONST const
51 GC_API int GC_pthread_create(pthread_t *,
52 GC_PTHREAD_CREATE_CONST pthread_attr_t *,
53 void *(*)(void *), void * /* arg */);
54 GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
55 GC_API int GC_pthread_detach(pthread_t);
57 #ifndef GC_NO_PTHREAD_CANCEL
58 GC_API int GC_pthread_cancel(pthread_t);
61 #ifdef GC_PTHREAD_EXIT_ATTRIBUTE
62 GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
65 #if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP)
66 /* Unless the compiler supports #pragma extern_prefix, the Tru64 */
67 /* UNIX <pthread.h> redefines some POSIX thread functions to use */
68 /* mangled names. Anyway, it's safe to undef them before redefining. */
69 # undef pthread_create
71 # undef pthread_detach
72 # define pthread_create GC_pthread_create
73 # define pthread_join GC_pthread_join
74 # define pthread_detach GC_pthread_detach
76 # ifndef GC_NO_PTHREAD_SIGMASK
77 # undef pthread_sigmask
78 # define pthread_sigmask GC_pthread_sigmask
82 # define dlopen GC_dlopen
84 # ifndef GC_NO_PTHREAD_CANCEL
85 # undef pthread_cancel
86 # define pthread_cancel GC_pthread_cancel
88 # ifdef GC_PTHREAD_EXIT_ATTRIBUTE
90 # define pthread_exit GC_pthread_exit
92 #endif /* !GC_NO_THREAD_REDIRECTS */
94 #endif /* GC_PTHREADS */