3 * Low level access to thread state.
6 * Rodrigo Kumpera (kumpera@gmail.com)
11 #ifndef __MONO_THREADS_API_H__
12 #define __MONO_THREADS_API_H__
15 #include <mono/utils/mono-publib.h>
20 >>>> WARNING WARNING WARNING <<<<
22 This API is experimental. It will eventually be required to properly use the rest of the raw-omp embedding API.
26 mono_threads_enter_gc_unsafe_region (gpointer* stackdata);
29 mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata);
32 mono_threads_enter_gc_unsafe_region_unbalanced (gpointer* stackdata);
35 mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer* stackdata);
38 mono_threads_assert_gc_unsafe_region (void);
43 mono_threads_enter_gc_safe_region (gpointer *stackdata);
46 mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata);
49 mono_threads_enter_gc_safe_region_unbalanced (gpointer *stackdata);
52 mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdata);
55 mono_threads_assert_gc_safe_region (void);
58 Use those macros to limit regions of code that interact with managed memory or use the embedding API.
59 This will put the current thread in GC Unsafe mode.
61 For further explanation of what can and can't be done in GC unsafe mode:
62 http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode
64 #define MONO_ENTER_GC_UNSAFE \
66 gpointer __gc_unsafe_dummy; \
67 gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__gc_unsafe_dummy)
69 #define MONO_EXIT_GC_UNSAFE \
70 mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__gc_unsafe_dummy); \
73 #define MONO_ENTER_GC_UNSAFE_UNBALANCED \
75 gpointer __gc_unsafe_unbalanced_dummy; \
76 gpointer __gc_unsafe_unbalanced_cookie = mono_threads_enter_gc_unsafe_region_unbalanced (&__gc_unsafe_unbalanced_dummy)
78 #define MONO_EXIT_GC_UNSAFE_UNBALANCED \
79 mono_threads_exit_gc_unsafe_region_unbalanced (__gc_unsafe_unbalanced_cookie, &__gc_unsafe_unbalanced_dummy); \
82 #define MONO_ENTER_GC_SAFE \
84 gpointer __gc_safe_dummy; \
85 gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__gc_safe_dummy)
87 #define MONO_EXIT_GC_SAFE \
88 mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__gc_safe_dummy); \
91 #define MONO_ENTER_GC_SAFE_UNBALANCED \
93 gpointer __gc_safe_unbalanced_dummy; \
94 gpointer __gc_safe_unbalanced_cookie = mono_threads_enter_gc_safe_region_unbalanced (&__gc_safe_unbalanced_dummy)
96 #define MONO_EXIT_GC_SAFE_UNBALANCED \
97 mono_threads_exit_gc_safe_region_unbalanced (__gc_safe_unbalanced_cookie, &__gc_safe_unbalanced_dummy); \
102 #endif /* __MONO_LOGGER_H__ */