void
mono_threads_core_abort_syscall (MonoThreadInfo *info)
{
+ kern_return_t ret;
+
+ ret = thread_suspend (info->native_handle);
+ if (ret != KERN_SUCCESS)
+ return;
+
+ ret = thread_abort_safely (info->native_handle);
+
+ /*
+ * We are doing thread_abort when thread_abort_safely returns KERN_SUCCESS because
+ * for some reason accept is not interrupted by thread_abort_safely.
+ * The risk of aborting non-atomic operations while calling thread_abort should not
+ * exist because by the time thread_abort_safely returns KERN_SUCCESS the target
+ * thread should have return from the kernel and should be waiting for thread_resume
+ * to resume the user code.
+ */
+ if (ret == KERN_SUCCESS)
+ ret = thread_abort (info->native_handle);
+
+ g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
}
gboolean
mono_threads_core_needs_abort_syscall (void)
{
- return FALSE;
+ return TRUE;
}
gboolean
return TRUE;
}
res = mono_threads_get_runtime_callbacks ()->
- thread_state_init_from_handle (&info->suspend_state, info);
+ thread_state_init_from_handle (&info->thread_saved_state [ASYNC_SUSPEND_STATE_INDEX], info);
THREADS_SUSPEND_DEBUG ("thread state %p -> %d\n", (void*)info->native_handle, res);
if (res) {
if (interrupt_kernel)
kern_return_t ret;
if (info->async_target) {
- MonoContext tmp = info->suspend_state.ctx;
+ MonoContext tmp = info->thread_saved_state [ASYNC_SUSPEND_STATE_INDEX].ctx;
mach_msg_type_number_t num_state;
thread_state_t state;
ucontext_t uctx;
mcontext_t mctx;
mono_threads_get_runtime_callbacks ()->setup_async_callback (&tmp, info->async_target, info->user_data);
- info->async_target = info->user_data = NULL;
+ info->user_data = NULL;
+ info->async_target = (void (*)(void *)) info->user_data;
state = (thread_state_t) alloca (mono_mach_arch_get_thread_state_size ());
mctx = (mcontext_t) alloca (mono_mach_arch_get_mcontext_size ());
mach_port_deallocate (current_task (), info->native_handle);
}
-MonoNativeThreadId
-mono_native_thread_id_get (void)
-{
- return pthread_self ();
-}
-
-gboolean
-mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
-{
- return pthread_equal (id1, id2);
-}
-
-/*
- * mono_native_thread_create:
- *
- * Low level thread creation function without any GC wrappers.
- */
-gboolean
-mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg)
+void
+mono_threads_core_begin_global_suspend (void)
{
- return pthread_create (tid, NULL, func, arg) == 0;
}
void
-mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
+mono_threads_core_end_global_suspend (void)
{
- /* pthread_setnmae_np() on Mac is not documented and doesn't receive thread id. */
}
+
#endif /* USE_MACH_BACKEND */
#ifdef __MACH__