#endif
#include <mono/utils/mono-compiler.h>
-#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-threads-coop.h>
+#include <mono/utils/mono-threads-api.h>
#ifdef TARGET_OSX
#include <mono/utils/mach-support.h>
static void *
return_stack_ptr ()
{
- int i;
+ gpointer i;
return &i;
}
state = &info->thread_saved_state [SELF_SUSPEND_STATE_INDEX];
stackdata_size = (char*)stackdata_begin - (char*)stackdata_end;
+
+ if (((gsize) stackdata_begin & (SIZEOF_VOID_P - 1)) != 0)
+ g_error ("stackdata_begin (%p) must be %d-byte aligned", stackdata_begin, SIZEOF_VOID_P);
+ if (((gsize) stackdata_end & (SIZEOF_VOID_P - 1)) != 0)
+ g_error ("stackdata_end (%p) must be %d-byte aligned", stackdata_end, SIZEOF_VOID_P);
+
if (stackdata_size <= 0)
g_error ("stackdata_size = %d, but must be > 0, stackdata_begin = %p, stackdata_end = %p", stackdata_size, stackdata_begin, stackdata_end);
if (!mono_threads_is_coop_enabled ())
return;
- info = cookie;
+ info = (MonoThreadInfo *)cookie;
if (!info)
return;
if (!mono_threads_is_coop_enabled ())
return;
- info = cookie;
+ info = (MonoThreadInfo *)cookie;
if (!info)
return;
mono_threads_prepare_blocking (stackdata);
}
-void*
-mono_threads_try_prepare_blocking (void* stackdata)
-{
- MonoThreadInfo *info;
-
- if (!mono_threads_is_coop_enabled ())
- return NULL;
-
- ++coop_try_blocking_count;
-
- info = mono_thread_info_current_unchecked ();
- /* If the thread is not attached, it doesn't make sense prepare for suspend. */
- if (!info || !mono_thread_info_is_live (info) || mono_thread_info_current_state (info) == STATE_BLOCKING) {
- THREADS_SUSPEND_DEBUG ("PREPARE-TRY-BLOCKING failed %p\n", mono_thread_info_get_tid (info));
- return NULL;
- }
-
- copy_stack_data (info, stackdata);
-
-retry:
- ++coop_save_count;
- mono_threads_get_runtime_callbacks ()->thread_state_init (&info->thread_saved_state [SELF_SUSPEND_STATE_INDEX]);
-
- switch (mono_threads_transition_do_blocking (info)) {
- case DoBlockingContinue:
- break;
- case DoBlockingPollAndRetry:
- mono_threads_state_poll ();
- goto retry;
- }
-
- return info;
-}
-
-void
-mono_threads_finish_try_blocking (void* cookie, void* stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return;
-
- mono_threads_finish_blocking (cookie, stackdata);
-}
-
void
mono_threads_init_coop (void)
{
mono_polling_required = 0;
}
-void*
-mono_threads_enter_gc_unsafe_region (void* stackdata)
+gpointer
+mono_threads_enter_gc_unsafe_region (gpointer* stackdata)
{
if (!mono_threads_is_coop_enabled ())
return NULL;
}
void
-mono_threads_exit_gc_unsafe_region (void *regions_cookie, void* stackdata)
+mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata)
{
if (!mono_threads_is_coop_enabled ())
return;
- mono_threads_reset_blocking_end (regions_cookie, stackdata);
+ mono_threads_reset_blocking_end (cookie, stackdata);
+}
+
+void
+mono_threads_assert_gc_unsafe_region (void)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+}
+
+gpointer
+mono_threads_enter_gc_safe_region (gpointer *stackdata)
+{
+ if (!mono_threads_is_coop_enabled ())
+ return NULL;
+
+ return mono_threads_prepare_blocking (stackdata);
+}
+
+void
+mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata)
+{
+ if (!mono_threads_is_coop_enabled ())
+ return;
+
+ mono_threads_finish_blocking (cookie, stackdata);
+}
+
+void
+mono_threads_assert_gc_safe_region (void)
+{
+ MONO_REQ_GC_SAFE_MODE;
}