X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmach-support-x86.c;h=d1e0a73492f58934903f4e8e7a220199541d0b41;hb=30cddad5fb4c3d290906a6e6c33ecd8b07d8b48c;hp=5650e8b92c916b7a584ccfe073d9e915a30ff489;hpb=468225a247b8897b2a4fa1e6bd7ffa32aa8c243b;p=mono.git diff --git a/mono/utils/mach-support-x86.c b/mono/utils/mach-support-x86.c index 5650e8b92c9..d1e0a73492f 100644 --- a/mono/utils/mach-support-x86.c +++ b/mono/utils/mach-support-x86.c @@ -1,5 +1,6 @@ -/* - * mach-support-x86.c: mach support for x86 +/** + * \file + * mach support for x86 * * Authors: * Geoff Norton (gnorton@novell.com) @@ -16,6 +17,9 @@ #include "utils/mono-sigcontext.h" #include "mach-support.h" +// For reg numbers +#include + /* Known offsets used for TLS storage*/ /* All OSX versions up to 10.8 */ @@ -55,21 +59,47 @@ mono_mach_arch_get_mcontext_size () } void -mono_mach_arch_thread_state_to_mcontext (thread_state_t state, void *context) +mono_mach_arch_thread_states_to_mcontext (thread_state_t state, thread_state_t fpstate, void *context) { x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state; + x86_float_state32_t *arch_fpstate = (x86_float_state32_t *) fpstate; struct __darwin_mcontext32 *ctx = (struct __darwin_mcontext32 *) context; - ctx->__ss = *arch_state; + ctx->__fs = *arch_fpstate; } void -mono_mach_arch_mcontext_to_thread_state (void *context, thread_state_t state) +mono_mach_arch_mcontext_to_thread_states (void *context, thread_state_t state, thread_state_t fpstate) { x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state; + x86_float_state32_t *arch_fpstate = (x86_float_state32_t *) fpstate; struct __darwin_mcontext32 *ctx = (struct __darwin_mcontext32 *) context; - *arch_state = ctx->__ss; + *arch_fpstate = ctx->__fs; +} + +void +mono_mach_arch_thread_states_to_mono_context (thread_state_t state, thread_state_t fpstate, MonoContext *context) +{ + x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state; + x86_float_state32_t *arch_fpstate = (x86_float_state32_t *) state; + context->eax = arch_state->__eax; + context->ebx = arch_state->__ebx; + context->ecx = arch_state->__ecx; + context->edx = arch_state->__edx; + context->ebp = arch_state->__ebp; + context->esp = arch_state->__esp; + context->esi = arch_state->__edi; + context->edi = arch_state->__esi; + context->eip = arch_state->__eip; + context->fregs [X86_XMM0] = arch_fpstate->__fpu_xmm0; + context->fregs [X86_XMM1] = arch_fpstate->__fpu_xmm1; + context->fregs [X86_XMM2] = arch_fpstate->__fpu_xmm2; + context->fregs [X86_XMM3] = arch_fpstate->__fpu_xmm3; + context->fregs [X86_XMM4] = arch_fpstate->__fpu_xmm4; + context->fregs [X86_XMM5] = arch_fpstate->__fpu_xmm5; + context->fregs [X86_XMM6] = arch_fpstate->__fpu_xmm6; + context->fregs [X86_XMM7] = arch_fpstate->__fpu_xmm7; } int @@ -78,29 +108,46 @@ mono_mach_arch_get_thread_state_size () return sizeof (x86_thread_state32_t); } +int +mono_mach_arch_get_thread_fpstate_size () +{ + return sizeof (x86_float_state32_t); +} + kern_return_t -mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count) +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) { #if defined(HOST_WATCHOS) g_error ("thread_get_state() is not supported by this platform"); #else x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state; + x86_float_state32_t *arch_fpstate = (x86_float_state32_t *) fpstate; kern_return_t ret; *count = x86_THREAD_STATE32_COUNT; - ret = thread_get_state (thread, x86_THREAD_STATE32, (thread_state_t) arch_state, count); + *fpcount = x86_FLOAT_STATE32_COUNT; + ret = thread_get_state (thread, x86_THREAD_STATE32, (thread_state_t)arch_state, count); + if (ret != KERN_SUCCESS) + return ret; + + ret = thread_get_state (thread, x86_FLOAT_STATE32, (thread_state_t)arch_fpstate, fpcount); return ret; #endif } kern_return_t -mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count) +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) { #if defined(HOST_WATCHOS) g_error ("thread_set_state() is not supported by this platform"); #else - return thread_set_state (thread, x86_THREAD_STATE32, state, count); + kern_return_t ret; + ret = thread_set_state (thread, x86_THREAD_STATE32, state, count); + if (ret != KERN_SUCCESS) + return ret; + ret = thread_set_state (thread, x86_FLOAT_STATE32, fpstate, fpcount); + return ret; #endif }