implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / 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-2010 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 #if defined(GC_H) && defined(GC_PTHREADS)
23
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.                         */
32
33 #include <pthread.h>
34
35 #ifndef GC_NO_DLOPEN
36 # include <dlfcn.h>
37   GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
38 #endif /* !GC_NO_DLOPEN */
39
40 #ifndef GC_NO_PTHREAD_SIGMASK
41 # include <signal.h>
42   GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
43                                 sigset_t * /* oset */);
44 #endif /* !GC_NO_PTHREAD_SIGMASK */
45
46 #ifndef GC_PTHREAD_CREATE_CONST
47   /* This is used for pthread_create() only.    */
48 # define GC_PTHREAD_CREATE_CONST const
49 #endif
50
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);
56
57 #ifndef GC_NO_PTHREAD_CANCEL
58   GC_API int GC_pthread_cancel(pthread_t);
59 #endif
60
61 #ifdef GC_PTHREAD_EXIT_ATTRIBUTE
62   GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
63 #endif
64
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
70 # undef pthread_join
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
75
76 # ifndef GC_NO_PTHREAD_SIGMASK
77 #   undef pthread_sigmask
78 #   define pthread_sigmask GC_pthread_sigmask
79 # endif
80 # ifndef GC_NO_DLOPEN
81 #   undef dlopen
82 #   define dlopen GC_dlopen
83 # endif
84 # ifndef GC_NO_PTHREAD_CANCEL
85 #   undef pthread_cancel
86 #   define pthread_cancel GC_pthread_cancel
87 # endif
88 # ifdef GC_PTHREAD_EXIT_ATTRIBUTE
89 #   undef pthread_exit
90 #   define pthread_exit GC_pthread_exit
91 # endif
92 #endif /* !GC_NO_THREAD_REDIRECTS */
93
94 #endif /* GC_PTHREADS */