Merge pull request #3040 from xmcclure/debugger-step-recursive
[mono.git] / mono / utils / mono-threads-api.h
index f94fd66e35b8f7832a6d9386117caf56b072420a..f36ec0beb813bf39430d83be8cc1889529bab591 100644 (file)
@@ -10,7 +10,9 @@
 #ifndef __MONO_THREADS_API_H__
 #define __MONO_THREADS_API_H__
 
+#include <glib.h>
 #include <mono/utils/mono-publib.h>
+
 MONO_BEGIN_DECLS
 
 /*
@@ -19,9 +21,37 @@ 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 void* mono_threads_enter_gc_unsafe_region (void);
-MONO_API void mono_threads_exit_gc_unsafe_region (void *region_cookie);
+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);
 
 /*
 Use those macros to limit regions of code that interact with managed memory or use the embedding API.
@@ -29,11 +59,42 @@ 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_EFRAME { void *__region_cookie = mono_threads_enter_gc_unsafe_region ();
-#define MONO_END_EFRAME mono_threads_exit_gc_unsafe_region (__region_cookie); }
+#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 __gc_safe_dummy;       \
+               gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__gc_safe_dummy)
+
+#define MONO_EXIT_GC_SAFE      \
+               mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__gc_safe_dummy);  \
+       } while (0)
+
+#define MONO_ENTER_GC_SAFE_UNBALANCED  \
+       do {    \
+               gpointer __gc_safe_unbalanced_dummy;    \
+               gpointer __gc_safe_unbalanced_cookie = mono_threads_enter_gc_safe_region_unbalanced (&__gc_safe_unbalanced_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