2008-08-24 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / os / 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 #       if !defined(__sparc__) && !defined(__sun)
28 #                   define GC_REDIRECT_TO_LOCAL
29 #       endif
30 #       endif
31
32 #       ifdef HAVE_GC_GC_H
33 #               include <gc/gc.h>
34 #               include <gc/gc_typed.h>
35 #               include <gc/gc_mark.h>
36 #               include <gc/gc_gcj.h>
37 #       elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC)
38 #               include <gc.h>
39 #               include <gc_typed.h>
40 #               include <gc_mark.h>
41 #               include <gc_gcj.h>
42 #       else
43 #               error have boehm GC without headers, you probably need to install them by hand
44 #       endif
45
46 #if defined(PLATFORM_WIN32)
47 #define CreateThread GC_CreateThread
48 #endif
49
50 #elif defined(HAVE_SGEN_GC)
51
52 #if defined(PLATFORM_WIN32)
53 #define CreateThread mono_gc_CreateThread
54 #else
55 /* pthread function wrappers */
56 #include <pthread.h>
57 #include <signal.h>
58
59 int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
60 int mono_gc_pthread_join (pthread_t thread, void **retval);
61 int mono_gc_pthread_detach (pthread_t thread);
62
63 #define pthread_create mono_gc_pthread_create
64 #define pthread_join mono_gc_pthread_join
65 #define pthread_detach mono_gc_pthread_detach
66
67 #endif
68
69 #else /* not Boehm and not sgen GC */
70 #endif
71
72 #endif