mono_mach_arch_thread_states_to_mcontext (thread_state_t state, thread_state_t fpstate, void *context)
{
arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state;
+ arm_neon_state64_t *arch_fpstate = (arm_neon_state64_t*) fpstate;
struct __darwin_mcontext64 *ctx = (struct __darwin_mcontext64 *) context;
ctx->__ss = arch_state->ts_64;
+ ctx->__ns = *arch_fpstate;
}
void
mono_mach_arch_mcontext_to_thread_states (void *context, thread_state_t state, thread_state_t fpstate)
{
arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state;
+ arm_neon_state64_t *arch_fpstate = (arm_neon_state64_t*) fpstate;
struct __darwin_mcontext64 *ctx = (struct __darwin_mcontext64 *) context;
arch_state->ts_64 = ctx->__ss;
+ *arch_fpstate = ctx->__ns;
}
void
{
int i;
arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state;
+ arm_neon_state64_t *arch_fpstate = (arm_neon_state64_t*) fpstate;
+
for (i = 0; i < 29; ++i)
context->regs [i] = arch_state->ts_64.__x [i];
context->regs [ARMREG_R30] = arch_state->ts_64.__lr;
context->regs [ARMREG_SP] = arch_state->ts_64.__sp;
context->pc = arch_state->ts_64.__pc;
+
+ for (i = 0; i < 32; ++i)
+ context->fregs [i] = arch_fpstate->__v [i];
}
int
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)
{
arm_unified_thread_state_t *arch_state = (arm_unified_thread_state_t *) state;
+ arm_neon_state64_t *arch_fpstate = (arm_neon_state64_t *) fpstate;
kern_return_t ret;
*count = ARM_UNIFIED_THREAD_STATE_COUNT;
-
ret = thread_get_state (thread, ARM_UNIFIED_THREAD_STATE, (thread_state_t) arch_state, count);
+ if (ret != KERN_SUCCESS)
+ return ret;
+
+ *fpcount = ARM_NEON_STATE64_COUNT;
+ ret = thread_get_state (thread, ARM_NEON_STATE64, (thread_state_t) arch_fpstate, fpcount);
return ret;
}
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)
{
- return thread_set_state (thread, ARM_UNIFIED_THREAD_STATE, state, count);
+ kern_return_t ret;
+ ret = thread_set_state (thread, ARM_UNIFIED_THREAD_STATE, state, count);
+ if (ret != KERN_SUCCESS)
+ return ret;
+ ret = thread_set_state (thread, ARM_NEON_STATE64, fpstate, fpcount);
+ return ret;
}
void *
#define MONO_CONTEXT_GET_CURRENT(ctx) do { \
arm_unified_thread_state_t thread_state; \
+ arm_neon_state64_t thread_fpstate; \
int state_flavor = ARM_UNIFIED_THREAD_STATE; \
+ int fpstate_flavor = ARM_NEON_STATE64; \
unsigned state_count = ARM_UNIFIED_THREAD_STATE_COUNT; \
+ unsigned fpstate_count = ARM_NEON_STATE64_COUNT; \
thread_port_t self = mach_thread_self (); \
kern_return_t ret = thread_get_state (self, state_flavor, (thread_state_t) &thread_state, &state_count); \
g_assert (ret == 0); \
- mono_mach_arch_thread_states_to_mono_context ((thread_state_t)&thread_state, (thread_state_t)NULL, &ctx); \
+ ret = thread_get_state (self, fpstate_flavor, (thread_state_t) &thread_fpstate, &fpstate_count); \
+ g_assert (ret == 0); \
+ mono_mach_arch_thread_states_to_mono_context ((thread_state_t) &thread_state, (thread_state_t) &thread_fpstate, &ctx); \
mach_port_deallocate (current_task (), self); \
} while (0);