Debian Codegraph @

external/bdwgc/include/gc_pthread_redirects.h

raw
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 /* uncollectible 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 #ifndef GC_PTHREAD_REDIRECTS_ONLY
34
35 # include <pthread.h>
36 # ifndef GC_NO_DLOPEN
37 # include <dlfcn.h>
38 # endif
39 # ifndef GC_NO_PTHREAD_SIGMASK
40 # include <signal.h> /* needed anyway for proper redirection */
41 # endif
42
43 # ifdef __cplusplus
44 extern "C" {
45 # endif
46
47 # ifndef GC_SUSPEND_THREAD_ID
48 # define GC_SUSPEND_THREAD_ID pthread_t
49 # endif
50
51 # ifndef GC_NO_DLOPEN
52 GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
53 # endif /* !GC_NO_DLOPEN */
54
55 # ifndef GC_NO_PTHREAD_SIGMASK
56 # if defined(GC_PTHREAD_SIGMASK_NEEDED) \
57 || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) \
58 || (_POSIX_C_SOURCE >= 199506L) || (_XOPEN_SOURCE >= 500)
59 GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
60 sigset_t * /* oset */);
61 # endif
62 # endif /* !GC_NO_PTHREAD_SIGMASK */
63
64 # ifndef GC_PTHREAD_CREATE_CONST
65 /* This is used for pthread_create() only. */
66 # define GC_PTHREAD_CREATE_CONST const
67 # endif
68
69 GC_API int GC_pthread_create(pthread_t *,
70 GC_PTHREAD_CREATE_CONST pthread_attr_t *,
71 void *(*)(void *), void * /* arg */);
72 GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
73 GC_API int GC_pthread_detach(pthread_t);
74
75 # ifndef GC_NO_PTHREAD_CANCEL
76 GC_API int GC_pthread_cancel(pthread_t);
77 # endif
78
79 # if defined(GC_HAVE_PTHREAD_EXIT) && !defined(GC_PTHREAD_EXIT_DECLARED)
80 # define GC_PTHREAD_EXIT_DECLARED
81 GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
82 # endif
83
84 # ifdef __cplusplus
85 } /* extern "C" */
86 # endif
87
88 #endif /* !GC_PTHREAD_REDIRECTS_ONLY */
89
90 #if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP)
91 /* Unless the compiler supports #pragma extern_prefix, the Tru64 */
92 /* UNIX <pthread.h> redefines some POSIX thread functions to use */
93 /* mangled names. Anyway, it's safe to undef them before redefining. */
94 # undef pthread_create
95 # undef pthread_join
96 # undef pthread_detach
97 # define pthread_create GC_pthread_create
98 # define pthread_join GC_pthread_join
99 # define pthread_detach GC_pthread_detach
100
101 # ifndef GC_NO_PTHREAD_SIGMASK
102 # undef pthread_sigmask
103 # define pthread_sigmask GC_pthread_sigmask
104 # endif
105 # ifndef GC_NO_DLOPEN
106 # undef dlopen
107 # define dlopen GC_dlopen
108 # endif
109 # ifndef GC_NO_PTHREAD_CANCEL
110 # undef pthread_cancel
111 # define pthread_cancel GC_pthread_cancel
112 # endif
113 # ifdef GC_HAVE_PTHREAD_EXIT
114 # undef pthread_exit
115 # define pthread_exit GC_pthread_exit
116 # endif
117 #endif /* !GC_NO_THREAD_REDIRECTS */
118
119 #endif /* GC_PTHREADS */