2 * mono-threads-coop.h: Cooperative suspend thread helpers
5 * Rodrigo Kumpera (kumpera@gmail.com)
10 #ifndef __MONO_THREADS_COOP_H__
11 #define __MONO_THREADS_COOP_H__
16 #include "checked-build.h"
17 #include "mono-threads-api.h"
21 /* JIT specific interface */
22 extern volatile size_t mono_polling_required;
24 /* Runtime consumable API */
27 mono_threads_is_coop_enabled (void);
32 mono_threads_state_poll (void);
35 mono_threads_safepoint (void)
37 if (G_UNLIKELY (mono_polling_required))
38 mono_threads_state_poll ();
42 * The following are used for wrappers and trampolines as their
43 * calls might be unbalanced, due to exception unwinding.
47 mono_threads_enter_gc_safe_region_unbalanced (gpointer *stackdata);
50 mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdata);
53 mono_threads_enter_gc_unsafe_region_unbalanced (gpointer *stackdata);
56 mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer *stackdata);
58 #define MONO_ENTER_GC_UNSAFE_UNBALANCED \
61 gpointer __reset_cookie = mono_threads_enter_gc_unsafe_region_unbalanced (&__dummy)
63 #define MONO_EXIT_GC_UNSAFE_UNBALANCED \
64 mono_threads_exit_gc_unsafe_region_unbalanced (__reset_cookie, &__dummy); \