X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-threads-api.h;h=2d8b37e58a58d459525d7b07ffd92730b7a39193;hb=b9e7bcabe48cd0d9f282a2eebe6ab9a8a010d9b0;hp=42e096efee787b951b4a84fe707de0a9e4fef787;hpb=635a4cec6f5236d6bd602465cfcb6036ffa2e249;p=mono.git diff --git a/mono/utils/mono-threads-api.h b/mono/utils/mono-threads-api.h index 42e096efee7..2d8b37e58a5 100644 --- a/mono/utils/mono-threads-api.h +++ b/mono/utils/mono-threads-api.h @@ -1,5 +1,6 @@ -/* - * mono-threads-api.h: Low level access to thread state. +/** + * \file + * Low level access to thread state. * * Author: * Rodrigo Kumpera (kumpera@gmail.com) @@ -10,7 +11,9 @@ #ifndef __MONO_THREADS_API_H__ #define __MONO_THREADS_API_H__ +#include #include + MONO_BEGIN_DECLS /* @@ -19,22 +22,35 @@ MONO_BEGIN_DECLS This API is experimental. It will eventually be required to properly use the rest of the raw-omp embedding API. */ -/* Don't use those directly, use the MONO_(BEGIN|END)_EFRAME */ MONO_API gpointer mono_threads_enter_gc_unsafe_region (gpointer* stackdata); MONO_API void mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata); +MONO_API gpointer +mono_threads_enter_gc_unsafe_region_unbalanced (gpointer* stackdata); + +MONO_API void +mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer* stackdata); + MONO_API void mono_threads_assert_gc_unsafe_region (void); + + MONO_API gpointer mono_threads_enter_gc_safe_region (gpointer *stackdata); MONO_API void mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata); +MONO_API gpointer +mono_threads_enter_gc_safe_region_unbalanced (gpointer *stackdata); + +MONO_API void +mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdata); + MONO_API void mono_threads_assert_gc_safe_region (void); @@ -44,24 +60,41 @@ This will put the current thread in GC Unsafe mode. For further explanation of what can and can't be done in GC unsafe mode: http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode - */ -#define MONO_BEGIN_GC_UNSAFE \ +#define MONO_ENTER_GC_UNSAFE \ + do { \ + gpointer __gc_unsafe_dummy; \ + gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__gc_unsafe_dummy) + +#define MONO_EXIT_GC_UNSAFE \ + mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__gc_unsafe_dummy); \ + } while (0) + +#define MONO_ENTER_GC_UNSAFE_UNBALANCED \ + do { \ + gpointer __gc_unsafe_unbalanced_dummy; \ + gpointer __gc_unsafe_unbalanced_cookie = mono_threads_enter_gc_unsafe_region_unbalanced (&__gc_unsafe_unbalanced_dummy) + +#define MONO_EXIT_GC_UNSAFE_UNBALANCED \ + mono_threads_exit_gc_unsafe_region_unbalanced (__gc_unsafe_unbalanced_cookie, &__gc_unsafe_unbalanced_dummy); \ + } while (0) + +#define MONO_ENTER_GC_SAFE \ do { \ - gpointer __dummy; \ - gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__dummy) \ + gpointer __gc_safe_dummy; \ + gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__gc_safe_dummy) -#define MONO_END_GC_UNSAFE \ - mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__dummy); \ +#define MONO_EXIT_GC_SAFE \ + mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__gc_safe_dummy); \ } while (0) -#define MONO_BEGIN_GC_SAFE \ +#define MONO_ENTER_GC_SAFE_UNBALANCED \ do { \ - gpointer __dummy; \ - gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__dummy) \ + gpointer __gc_safe_unbalanced_dummy; \ + gpointer __gc_safe_unbalanced_cookie = mono_threads_enter_gc_safe_region_unbalanced (&__gc_safe_unbalanced_dummy) -#define MONO_END_GC_SAFE \ - mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__dummy); \ +#define MONO_EXIT_GC_SAFE_UNBALANCED \ + mono_threads_exit_gc_safe_region_unbalanced (__gc_safe_unbalanced_cookie, &__gc_safe_unbalanced_dummy); \ } while (0) MONO_END_DECLS