1 #ifndef __MONO_OS_GC_WRAPPER_H__
2 #define __MONO_OS_GC_WRAPPER_H__
11 /* libgc specifies this on the command line,
12 * so we must define it ourselfs
14 # define GC_GCJ_SUPPORT
18 * Local allocation is only beneficial if we have __thread
19 * We had to fix a bug with include order in libgc, so only do
20 * it if it is the included one.
23 # if defined(HAVE_KW_THREAD) && defined(USE_INCLUDED_LIBGC) && !defined(__powerpc__)
24 /* The local alloc stuff is in pthread_support.c, but solaris uses solaris_threads.c */
25 /* It is also disabled on solaris/x86 by libgc/configure.in */
26 # if !defined(__sparc__) && !defined(__sun)
27 # define GC_REDIRECT_TO_LOCAL
33 # include <gc/gc_typed.h>
34 # include <gc/gc_mark.h>
35 # include <gc/gc_gcj.h>
36 # elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC)
38 # include <gc_typed.h>
42 # error have boehm GC without headers, you probably need to install them by hand
44 /* for some strange resion, they want one extra byte on the end */
45 # define MONO_GC_REGISTER_ROOT(x) \
46 GC_add_roots ((char*)&(x), (char*)&(x) + sizeof (x) + 1)
47 /* this needs to be called before ANY gc allocations. We can't use
48 * mono_gc_init here because we need to make allocations before that
51 # define MONO_GC_PRE_INIT() GC_init ()
53 #if defined(PLATFORM_WIN32)
54 #define CreateThread GC_CreateThread
57 #elif defined(HAVE_SGEN_GC)
59 #if defined(PLATFORM_WIN32)
60 #define CreateThread mono_gc_CreateThread
62 /* pthread function wrappers */
66 int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
67 int mono_gc_pthread_join (pthread_t thread, void **retval);
68 int mono_gc_pthread_detach (pthread_t thread);
70 #define pthread_create mono_gc_pthread_create
71 #define pthread_join mono_gc_pthread_join
72 #define pthread_detach mono_gc_pthread_detach
77 mono_gc_register_root (char *start, size_t size, void *descr);
78 extern void mono_gc_base_init (void);
80 # define MONO_GC_REGISTER_ROOT(x) mono_gc_register_root (&(x), sizeof(x), NULL)
81 # define MONO_GC_PRE_INIT() mono_gc_base_init ()
83 #else /* not Boehm and not sgen GC */
84 # define MONO_GC_REGISTER_ROOT(x) /* nop */
85 # define MONO_GC_PRE_INIT()