2 * mach-support-x86.c: mach support for x86
5 * Geoff Norton (gnorton@novell.com)
7 * (C) 2010 Ximian, Inc.
16 #include "utils/mono-sigcontext.h"
17 #include "mach-support.h"
20 mono_mach_arch_get_ip (thread_state_t state)
22 x86_thread_state64_t *arch_state = (x86_thread_state64_t *) state;
24 return (void *) arch_state->__rip;
28 mono_mach_arch_get_sp (thread_state_t state)
30 x86_thread_state64_t *arch_state = (x86_thread_state64_t *) state;
32 return (void *) arch_state->__rsp;
36 mono_mach_arch_get_mcontext_size ()
38 return sizeof (struct __darwin_mcontext64);
42 mono_mach_arch_thread_state_to_mcontext (thread_state_t state, mcontext_t context)
44 x86_thread_state64_t *arch_state = (x86_thread_state64_t *) state;
45 struct __darwin_mcontext64 *ctx = (struct __darwin_mcontex64 *) context;
47 ctx->__ss = *arch_state;
51 mono_mach_arch_get_thread_state_size ()
53 return sizeof (x86_thread_state64_t);
57 mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count)
59 x86_thread_state64_t *arch_state = (x86_thread_state64_t *) state;
62 *count = x86_THREAD_STATE64_COUNT;
64 ret = thread_get_state (thread, x86_THREAD_STATE64, (thread_state_t) arch_state, count);
70 mono_mach_arch_get_tls_value_from_thread (thread_port_t thread, guint32 key)
72 /* OSX stores TLS values in a hidden array inside the pthread_t structure
73 * They are keyed off a giant array offset 0x60 into the pointer. This value
74 * is baked into their pthread_getspecific implementation
76 intptr_t *p = (intptr_t *) pthread_from_mach_thread_np (thread);
77 intptr_t **tsd = (intptr_t **) (p + 0x60);
79 return (void *) tsd [key];