X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fos%2Fgc_wrapper.h;h=466057c42ae75a8c57144533449e05a8670a1a96;hb=fc4b07f20f9e79fe99d4b520bb5ff8b5e80b10f6;hp=9a4322e282738d9312054c6d06c51a136a8e5005;hpb=cc63aff65e9d9de2a38d7c48771ce08006488e15;p=mono.git diff --git a/mono/os/gc_wrapper.h b/mono/os/gc_wrapper.h index 9a4322e2827..466057c42ae 100644 --- a/mono/os/gc_wrapper.h +++ b/mono/os/gc_wrapper.h @@ -1,23 +1,88 @@ +#ifndef __MONO_OS_GC_WRAPPER_H__ +#define __MONO_OS_GC_WRAPPER_H__ + #include #ifdef HAVE_BOEHM_GC -#ifdef HAVE_GC_GC_H -#include -#include -#include -#include -#else +# ifdef _MSC_VER +# include +# else + /* libgc specifies this on the command line, + * so we must define it ourselfs + */ +# define GC_GCJ_SUPPORT +# endif + + /* + * Local allocation is only beneficial if we have __thread + * We had to fix a bug with include order in libgc, so only do + * it if it is the included one. + */ + +# if defined(HAVE_KW_THREAD) && defined(USE_INCLUDED_LIBGC) && !defined(__powerpc__) + /* The local alloc stuff is in pthread_support.c, but solaris uses solaris_threads.c */ + /* It is also disabled on solaris/x86 by libgc/configure.in */ +# if !defined(__sparc__) && !defined(__sun) +# define GC_REDIRECT_TO_LOCAL +# endif +# endif + +# ifdef HAVE_GC_GC_H +# include +# include +# include +# include +# elif defined(HAVE_GC_H) || defined(USE_INCLUDED_LIBGC) +# include +# include +# include +# include +# else +# error have boehm GC without headers, you probably need to install them by hand +# endif + /* for some strange resion, they want one extra byte on the end */ +# define MONO_GC_REGISTER_ROOT(x) \ + GC_add_roots ((char*)&(x), (char*)&(x) + sizeof (x) + 1) + /* this needs to be called before ANY gc allocations. We can't use + * mono_gc_init here because we need to make allocations before that + * function is called + */ +# define MONO_GC_PRE_INIT() GC_init () + +#if defined(PLATFORM_WIN32) +#define CreateThread GC_CreateThread +#endif -#ifdef HAVE_GC_H -#include -#include -#include -#include +#elif defined(HAVE_SGEN_GC) + +#if defined(PLATFORM_WIN32) +#define CreateThread mono_gc_CreateThread #else -#error have boehm GC without headers, you probably need to install them by hand +/* pthread function wrappers */ +#include +#include + +int mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); +int mono_gc_pthread_join (pthread_t thread, void **retval); +int mono_gc_pthread_detach (pthread_t thread); + +#define pthread_create mono_gc_pthread_create +#define pthread_join mono_gc_pthread_join +#define pthread_detach mono_gc_pthread_detach + #endif +extern int +mono_gc_register_root (char *start, size_t size, void *descr); +extern void mono_gc_base_init (void); + +# define MONO_GC_REGISTER_ROOT(x) mono_gc_register_root (&(x), sizeof(x), NULL) +# define MONO_GC_PRE_INIT() mono_gc_base_init () + +#else /* not Boehm and not sgen GC */ +# define MONO_GC_REGISTER_ROOT(x) /* nop */ +# define MONO_GC_PRE_INIT() #endif #endif