1 /** 2 * \file 3 */ 4 5 #ifndef __MONO_MACH_SUPPORT_H__ 6 #define __MONO_MACH_SUPPORT_H__ 7 8 #include "config.h" 9 #if defined(__MACH__) 10 #include <glib.h> 11 #include <pthread.h> 12 #include "mono/utils/mono-compiler.h" 13 #include "mono/utils/mono-context.h" 14 #include <mach/task.h> 15 #include <mach/mach_port.h> 16 #include <mach/mach_init.h> 17 #include <mach/thread_act.h> 18 #include <mach/thread_status.h> 19 20 #define MONO_MACH_ARCH_SUPPORTED 1 21 #if defined(__arm__) 22 typedef _STRUCT_MCONTEXT *mcontext_t; 23 #elif defined(__aarch64__) 24 typedef _STRUCT_MCONTEXT64 *mcontext_t; 25 #endif 26 27 // We need to define this here since we need _XOPEN_SOURCE for mono 28 // and the pthread header guards against this 29 extern pthread_t pthread_from_mach_thread_np(mach_port_t); 30 31 void *mono_mach_arch_get_ip (thread_state_t state); 32 void *mono_mach_arch_get_sp (thread_state_t state); 33 void mono_mach_init (pthread_key_t key); 34 35 int mono_mach_arch_get_mcontext_size (void); 36 void mono_mach_arch_thread_states_to_mcontext (thread_state_t state, thread_state_t fpstate, void *context); 37 void mono_mach_arch_mcontext_to_thread_states (void *context, thread_state_t state, thread_state_t fpstate); 38 void mono_mach_arch_thread_states_to_mono_context (thread_state_t state, thread_state_t fpstate, MonoContext *context); 39 40 /* FIXME: Should return size_t, not int. */ 41 int mono_mach_arch_get_thread_state_size (void); 42 int mono_mach_arch_get_thread_fpstate_size (void); 43 kern_return_t mono_mach_get_threads (thread_act_array_t *threads, guint32 *count); 44 kern_return_t mono_mach_free_threads (thread_act_array_t threads, guint32 count); 45 kern_return_t mono_mach_arch_get_thread_states (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count, thread_state_t fpstate, mach_msg_type_number_t *fpcount); 46 kern_return_t mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count, thread_state_t fpstate, mach_msg_type_number_t fpcount); 47 void *mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key); 48 void *mono_mach_get_tls_address_from_thread (pthread_t thread, pthread_key_t key); 49 50 #endif 51 #endif /* __MONO_MACH_SUPPORT_H__ */ 52