2004-11-30 Zoltan Varga <vargaz@freemail.hu>
[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
6 #ifdef HAVE_BOEHM_GC
7
8         /* libgc specifies this on the command line,
9          * so we must define it ourselfs
10          */
11 #       define GC_GCJ_SUPPORT
12         /*
13          * Local allocation is only beneficial if we have __thread
14          * We had to fix a bug with include order in libgc, so only do
15          * it if it is the included one.
16          */
17         
18 #       if defined(HAVE_KW_THREAD) && defined(USE_INCLUDED_LIBGC)  
19 #               define GC_REDIRECT_TO_LOCAL
20 #       endif
21
22 #       ifdef HAVE_GC_GC_H
23 #               include <gc/gc.h>
24 #               include <gc/gc_typed.h>
25 #               include <gc/gc_mark.h>
26 #               include <gc/gc_gcj.h>
27 #       elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC)
28 #               include <gc.h>
29 #               include <gc_typed.h>
30 #               include <gc_mark.h>
31 #               include <gc_gcj.h>
32 #       else
33 #               error have boehm GC without headers, you probably need to install them by hand
34 #       endif
35         /* for some strange resion, they want one extra byte on the end */
36 #       define MONO_GC_REGISTER_ROOT(x) \
37                 GC_add_roots ((char*)&(x), (char*)&(x) + sizeof (x) + 1)
38         /* this needs to be called before ANY gc allocations. We can't use
39          * mono_gc_init here because we need to make allocations before that
40          * function is called 
41          */
42 #       define MONO_GC_PRE_INIT() GC_init ()
43
44 #else
45 #       define MONO_GC_REGISTER_ROOT(x) /* nop */
46 #       define MONO_GC_PRE_INIT()
47 #endif
48
49 #endif