[jit] Assert that the trampoline code is called in gc unsafe mode, throw exceptions...
[mono.git] / mono / utils / mono-threads-state-machine.c
index 38e869cd040e9ffb3504349cbd9bb7c25aa0babb..1518438babbb9a99d2f1844bf65b3a35888d8bd0 100644 (file)
@@ -633,3 +633,21 @@ mono_thread_state_name (int state)
 {
        return state_name (state);
 }
+
+gboolean
+mono_thread_is_gc_unsafe_mode (void)
+{
+       MonoThreadInfo *cur = mono_thread_info_current ();
+
+       if (!cur)
+               return FALSE;
+
+       switch (mono_thread_info_current_state (cur)) {
+       case STATE_RUNNING:
+       case STATE_ASYNC_SUSPEND_REQUESTED:
+       case STATE_SELF_SUSPEND_REQUESTED:
+               return TRUE;
+       default:
+               return FALSE;
+       }
+}