[mcs] Accept and ignore command line args supported by csc that we don't
[mono.git] / mono / utils / mono-threads-mach-abort-syscall.c
1 /*
2  * mono-threads-mach-abort-syscall.c: Low-level syscall aborting
3  *
4  * Author:
5  *      Ludovic Henry (ludovic@xamarin.com)
6  *
7  * (C) 2015 Xamarin, Inc
8  */
9
10 #include "config.h"
11 #include <glib.h>
12
13 #if defined (__MACH__)
14 #define _DARWIN_C_SOURCE 1
15 #endif
16
17 #include <mono/utils/mono-threads.h>
18
19 #if defined(USE_MACH_BACKEND)
20
21 #if defined(HOST_WATCHOS) || defined(HOST_TVOS)
22
23 void
24 mono_threads_init_abort_syscall (void)
25 {
26 }
27
28 void
29 mono_threads_core_abort_syscall (MonoThreadInfo *info)
30 {
31
32 }
33
34 gboolean
35 mono_threads_core_needs_abort_syscall (void)
36 {
37         return FALSE;
38 }
39
40 #else
41
42 void
43 mono_threads_init_abort_syscall (void)
44 {
45 }
46
47 void
48 mono_threads_core_abort_syscall (MonoThreadInfo *info)
49 {
50         kern_return_t ret;
51
52         ret = thread_suspend (info->native_handle);
53         if (ret != KERN_SUCCESS)
54                 return;
55
56         ret = thread_abort_safely (info->native_handle);
57
58         /*
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.
65          */
66         if (ret == KERN_SUCCESS)
67                 ret = thread_abort (info->native_handle);
68
69         g_assert (thread_resume (info->native_handle) == KERN_SUCCESS);
70 }
71
72 gboolean
73 mono_threads_core_needs_abort_syscall (void)
74 {
75         return TRUE;
76 }
77
78 #endif
79
80 #endif