os_invalidate((os_vm_address_t)regs, sizeof(mcontext_t));
/* Trap to restore the signal context. */
- asm volatile ("movl %0, %%eax; movl %1, %%ebx; .long 0xffff0b0f"
- : : "r" (thread_state), "r" (float_state));
+ asm volatile (".long 0xffff0b0f"
+ : : "a" (thread_state), "b" (float_state));
}
/* Convenience wrapper for the above */
int signal = 0;
void (*handler)(int, siginfo_t *, void *) = NULL;
siginfo_t siginfo;
- kern_return_t ret;
+ kern_return_t ret, dealloc_ret;
/* Get state and info */
state_count = x86_THREAD_STATE32_COUNT;
call_handler_on_thread(thread, &thread_state, signal, &siginfo, handler);
}
- mach_port_deallocate (current_mach_task, exception_port);
- mach_port_deallocate (current_mach_task, thread);
- mach_port_deallocate (current_mach_task, task);
+ dealloc_ret = mach_port_deallocate (current_mach_task, thread);
+ if (dealloc_ret) {
+ lose("mach_port_deallocate (thread) failed with return_code %d\n", dealloc_ret);
+ }
+
+ dealloc_ret = mach_port_deallocate (current_mach_task, task);
+ if (dealloc_ret) {
+ lose("mach_port_deallocate (task) failed with return_code %d\n", dealloc_ret);
+ }
return ret;
}
+void
+os_restore_fp_control(os_context_t *context)
+{
+ /* KLUDGE: The x87 FPU control word is some nasty bitfield struct
+ * thing. Rather than deal with that, just grab it as a 16-bit
+ * integer. */
+ unsigned short fpu_control_word =
+ *((unsigned short *)&context->uc_mcontext->FS.FPU_FCW);
+ /* reset exception flags and restore control flags on x87 FPU */
+ asm ("fldcw %0" : : "m" (fpu_control_word));
+}
+
#endif