2 * mono-threads-mach-abort-syscall.c: Low-level syscall aborting
5 * Ludovic Henry (ludovic@xamarin.com)
7 * (C) 2015 Xamarin, Inc
13 #if defined (__MACH__)
14 #define _DARWIN_C_SOURCE 1
17 #include <mono/utils/mono-threads.h>
19 #if defined(USE_MACH_BACKEND)
21 #if defined(HOST_WATCHOS) || defined(HOST_TVOS)
24 mono_threads_init_abort_syscall (void)
29 mono_threads_core_abort_syscall (MonoThreadInfo *info)
35 mono_threads_core_needs_abort_syscall (void)
43 mono_threads_init_abort_syscall (void)
48 mono_threads_core_abort_syscall (MonoThreadInfo *info)
52 ret = thread_suspend (info->native_handle);
53 if (ret != KERN_SUCCESS)
56 ret = thread_abort_safely (info->native_handle);
59 * We are doing thread_abort when thread_abort_safely returns KERN_SUCCESS because
60 * for some reason accept is not interrupted by thread_abort_safely.
61 * The risk of aborting non-atomic operations while calling thread_abort should not
62 * exist because by the time thread_abort_safely returns KERN_SUCCESS the target
63 * thread should have return from the kernel and should be waiting for thread_resume
64 * to resume the user code.
66 if (ret == KERN_SUCCESS)
67 ret = thread_abort (info->native_handle);
69 g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
73 mono_threads_core_needs_abort_syscall (void)