Fixed.
[mono.git] / mono / utils / gc_wrapper.h
1 #ifndef __MONO_OS_GC_WRAPPER_H__
2 #define __MONO_OS_GC_WRAPPER_H__
3
4 #include <config.h>
5 #include <stdlib.h>
6
7 #ifdef HAVE_BOEHM_GC
8
9 #       ifdef _MSC_VER
10 #               include <winsock2.h>
11 #       else
12                 /* libgc specifies this on the command line,
13                  * so we must define it ourselfs
14                 */
15 #               define GC_GCJ_SUPPORT
16 #       endif
17
18         /*
19          * Local allocation is only beneficial if we have __thread
20          * We had to fix a bug with include order in libgc, so only do
21          * it if it is the included one.
22          */
23         
24 #       if defined(HAVE_KW_THREAD) && defined(USE_INCLUDED_LIBGC) && !defined(__powerpc__)
25         /* The local alloc stuff is in pthread_support.c, but solaris uses solaris_threads.c */
26         /* It is also disabled on solaris/x86 by libgc/configure.in */
27         /* 
28                  * ARM has no definition for some atomic functions in gc_locks.h and
29                  * support is also disabled in libgc/configure.in.
30                  */
31 #       if !defined(__sparc__) && !defined(__sun) && !defined(__arm__) && !defined(__mips__)
32 #                   define GC_REDIRECT_TO_LOCAL
33 #       endif
34 #       endif
35
36 #       ifdef HAVE_GC_GC_H
37 #               include <gc/gc.h>
38 #               include <gc/gc_typed.h>
39 #               include <gc/gc_mark.h>
40 #               include <gc/gc_gcj.h>
41 #       elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC)
42 #               include <gc.h>
43 #               include <gc_typed.h>
44 #               include <gc_mark.h>
45 #               include <gc_gcj.h>
46 #       else
47 #               error have boehm GC without headers, you probably need to install them by hand
48 #       endif
49
50 #if defined(HOST_WIN32)
51 #define CreateThread GC_CreateThread
52 #endif
53
54 #elif defined(HAVE_SGEN_GC)
55
56 #if defined(HOST_WIN32)
57 #define CreateThread mono_gc_CreateThread
58
59 #endif
60
61 #else /* not Boehm and not sgen GC */
62 #endif
63
64 #if !defined(HOST_WIN32)
65
66 /*
67  * Both Boehm and SGEN needs to intercept some thread operations. So instead of the
68  * pthread_... calls, runtime code should call these wrappers.
69  */
70
71 /* pthread function wrappers */
72 #include <pthread.h>
73 #include <signal.h>
74
75 int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
76 int mono_gc_pthread_join (pthread_t thread, void **retval);
77 int mono_gc_pthread_detach (pthread_t thread);
78
79 #endif
80
81 #endif