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_abort_syscall_init (void)
29 mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
35 mono_threads_suspend_needs_abort_syscall (void)
43 mono_threads_abort_syscall_init (void)
48 mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
53 ret = thread_suspend (info->native_handle);
54 } while (ret == KERN_ABORTED);
56 if (ret != KERN_SUCCESS)
60 ret = thread_abort_safely (info->native_handle);
61 } while (ret == KERN_ABORTED);
64 * We are doing thread_abort when thread_abort_safely returns KERN_SUCCESS because
65 * for some reason accept is not interrupted by thread_abort_safely.
66 * The risk of aborting non-atomic operations while calling thread_abort should not
67 * exist because by the time thread_abort_safely returns KERN_SUCCESS the target
68 * thread should have return from the kernel and should be waiting for thread_resume
69 * to resume the user code.
71 if (ret == KERN_SUCCESS)
72 ret = thread_abort (info->native_handle);
75 ret = thread_resume (info->native_handle);
76 } while (ret == KERN_ABORTED);
78 g_assert (ret == KERN_SUCCESS);
82 mono_threads_suspend_needs_abort_syscall (void)