2 * Copyright 2004-2011 Novell, Inc (http://www.novell.com)
3 * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
5 #ifndef __MONO_OS_GC_WRAPPER_H__
6 #define __MONO_OS_GC_WRAPPER_H__
14 # include <winsock2.h>
16 /* libgc specifies this on the command line,
17 * so we must define it ourselfs
19 # define GC_GCJ_SUPPORT
23 * Local allocation is only beneficial if we have __thread
24 * We had to fix a bug with include order in libgc, so only do
25 * it if it is the included one.
28 # if defined(HAVE_KW_THREAD) && defined(USE_INCLUDED_LIBGC) && !defined(__powerpc__)
29 /* The local alloc stuff is in pthread_support.c, but solaris uses solaris_threads.c */
30 /* It is also disabled on solaris/x86 by libgc/configure.ac */
32 * ARM has no definition for some atomic functions in gc_locks.h and
33 * support is also disabled in libgc/configure.ac.
35 # if !defined(__sparc__) && !defined(__sun) && !defined(__arm__) && !defined(__mips__)
36 # define GC_REDIRECT_TO_LOCAL
42 # include <gc/gc_typed.h>
43 # include <gc/gc_mark.h>
44 # include <gc/gc_gcj.h>
45 # elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC)
47 # include <gc_typed.h>
51 # error have boehm GC without headers, you probably need to install them by hand
54 #if defined(HOST_WIN32)
55 #define CreateThread GC_CreateThread
58 #elif defined(HAVE_SGEN_GC)
60 #else /* not Boehm and not sgen GC */
63 #if !defined(HOST_WIN32)
66 * Both Boehm and SGEN needs to intercept some thread operations. So instead of the
67 * pthread_... calls, runtime code should call these wrappers.
70 /* pthread function wrappers */
74 int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
75 int mono_gc_pthread_join (pthread_t thread, void **retval);
76 int mono_gc_pthread_detach (pthread_t thread);
77 void mono_gc_pthread_exit (void *retval) G_GNUC_NORETURN;