2 * mono-threads-api.h: Low level access to thread state.
5 * Rodrigo Kumpera (kumpera@gmail.com)
10 #ifndef __MONO_THREADS_API_H__
11 #define __MONO_THREADS_API_H__
13 #include <mono/utils/mono-publib.h>
17 >>>> WARNING WARNING WARNING <<<<
19 This API is experimental. It will eventually be required to properly use the rest of the raw-omp embedding API.
22 /* Don't use those directly, use the MONO_(BEGIN|END)_EFRAME */
24 mono_threads_enter_gc_unsafe_region (gpointer* stackdata);
27 mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata);
30 mono_threads_assert_gc_unsafe_region (void);
33 mono_threads_enter_gc_safe_region (gpointer *stackdata);
36 mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata);
39 mono_threads_assert_gc_safe_region (void);
42 Use those macros to limit regions of code that interact with managed memory or use the embedding API.
43 This will put the current thread in GC Unsafe mode.
45 For further explanation of what can and can't be done in GC unsafe mode:
46 http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode
48 #define MONO_ENTER_GC_UNSAFE \
50 gpointer __gc_unsafe_dummy; \
51 gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__gc_unsafe_dummy) \
53 #define MONO_EXIT_GC_UNSAFE \
54 mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__gc_unsafe_dummy); \
57 #define MONO_ENTER_GC_SAFE \
59 gpointer __gc_safe_dummy; \
60 gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__gc_safe_dummy) \
62 #define MONO_EXIT_GC_SAFE \
63 mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__gc_safe_dummy); \
68 #endif /* __MONO_LOGGER_H__ */