Upgrade Boehm GC to 7.2alpha4.
[cacao.git] / src / mm / boehm-gc / include / gc_pthread_redirects.h
1 /*
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-2009 by Hewlett-Packard Development Company.
6  * All rights reserved.
7  *
8  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
10  *
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.
16  */
17
18 /* Our pthread support normally needs to intercept a number of thread   */
19 /* calls.  We arrange to do that here, if appropriate.                  */
20
21 /* Included from gc.h only.  Included only if GC_PTHREADS.              */
22
23 /* We need to intercept calls to many of the threads primitives, so     */
24 /* that we can locate thread stacks and stop the world.                 */
25 /* Note also that the collector cannot always see thread specific data. */
26 /* Thread specific data should generally consist of pointers to         */
27 /* uncollectable objects (allocated with GC_malloc_uncollectable,       */
28 /* not the system malloc), which are deallocated using the destructor   */
29 /* facility in thr_keycreate.  Alternatively, keep a redundant pointer  */
30 /* to thread specific data on the thread stack.                         */
31
32 #include <pthread.h>
33
34 #ifndef GC_DARWIN_THREADS
35 # include <signal.h>
36 # include <dlfcn.h>
37
38 # ifndef GC_OPENBSD_THREADS
39     GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
40                                   sigset_t * /* oset */);
41 # endif
42   GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
43 #endif
44
45 GC_API int GC_pthread_create(pthread_t *, const pthread_attr_t *,
46                              void *(*)(void *), void * /* arg */);
47 GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
48 GC_API int GC_pthread_detach(pthread_t);
49
50 #if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP)
51   /* Unless the compiler supports #pragma extern_prefix, the Tru64    */
52   /* UNIX <pthread.h> redefines some POSIX thread functions to use    */
53   /* mangled names.  Anyway, it's safe to undef them before           */
54   /* redefining.                                                      */
55 # undef pthread_create
56 # undef pthread_join
57 # undef pthread_detach
58
59 # define pthread_create GC_pthread_create
60 # define pthread_join GC_pthread_join
61 # define pthread_detach GC_pthread_detach
62
63 # ifndef GC_DARWIN_THREADS
64 #   ifndef GC_OPENBSD_THREADS
65 #     undef pthread_sigmask
66 #     define pthread_sigmask GC_pthread_sigmask
67 #   endif
68 #   undef dlopen
69 #   define dlopen GC_dlopen
70 # endif
71 #endif /* !GC_NO_THREAD_REDIRECTS */