Revert "Revert "Merge branch 'master' of https://github.com/mono/mono""
[mono.git] / mono / utils / mach-support.h
1 #ifndef __MONO_MACH_SUPPORT_H__
2 #define __MONO_MACH_SUPPORT_H__
3
4 #include "config.h"
5 #if defined(__MACH__)
6 #include <glib.h>
7 #include <pthread.h>
8 #include "mono/utils/mono-compiler.h"
9 #include <mach/task.h>
10 #include <mach/mach_port.h>
11 #include <mach/mach_init.h>
12 #include <mach/thread_act.h>
13 #include <mach/thread_status.h>
14
15 #define MONO_MACH_ARCH_SUPPORTED 1
16 #if defined(__arm__)
17 typedef _STRUCT_MCONTEXT *mcontext_t;
18 #elif defined(__aarch64__)
19 typedef _STRUCT_MCONTEXT64 *mcontext_t;
20 #endif
21
22 // We need to define this here since we need _XOPEN_SOURCE for mono
23 // and the pthread header guards against this
24 extern pthread_t pthread_from_mach_thread_np(mach_port_t);
25
26 void *mono_mach_arch_get_ip (thread_state_t state) MONO_INTERNAL;
27 void *mono_mach_arch_get_sp (thread_state_t state) MONO_INTERNAL;
28 void mono_mach_init (pthread_key_t key) MONO_INTERNAL;
29
30 int mono_mach_arch_get_mcontext_size (void) MONO_INTERNAL;
31 void mono_mach_arch_thread_state_to_mcontext (thread_state_t state, void *context) MONO_INTERNAL;
32 void mono_mach_arch_mcontext_to_thread_state (void *context, thread_state_t state) MONO_INTERNAL;
33
34 int mono_mach_arch_get_thread_state_size (void) MONO_INTERNAL;
35 kern_return_t mono_mach_get_threads (thread_act_array_t *threads, guint32 *count) MONO_INTERNAL;
36 kern_return_t mono_mach_free_threads (thread_act_array_t threads, guint32 count) MONO_INTERNAL;
37 kern_return_t mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count) MONO_INTERNAL;
38 kern_return_t mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count) MONO_INTERNAL;
39 void *mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key) MONO_INTERNAL;
40 void *mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key) MONO_INTERNAL;
41
42 #endif
43 #endif /* __MONO_MACH_SUPPORT_H__ */