ensure-directories-exist: Signal an error when trying to create a
[sbcl.git] / src / runtime / x86-64-darwin-os.c
index 180db11..1050ade 100644 (file)
@@ -49,6 +49,9 @@ typedef struct __darwin_mcontext64 darwin_mcontext;
 #define es __es
 #define fs __fs
 
+#define fpu_fcw __fpu_fcw
+#define fpu_mxcsr __fpu_mxcsr
+
 #else
 
 typedef struct ucontext darwin_ucontext;
@@ -246,8 +249,8 @@ void signal_emulation_wrapper(x86_thread_state64_t *thread_state,
     os_invalidate((os_vm_address_t)regs, sizeof(darwin_mcontext));
 
     /* Trap to restore the signal context. */
-    asm volatile ("mov %0, %%rax; mov %1, %%rbx; .quad 0xffffffffffff0b0f"
-                  : : "r" (thread_state), "r" (float_state));
+    asm volatile (".quad 0xffffffffffff0b0f"
+                  : : "a" (thread_state), "b" (float_state));
 }
 
 #if defined DUMP_CONTEXT
@@ -587,4 +590,19 @@ catch_exception_raise(mach_port_t exception_port,
     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 SSE2 FPU */
+    unsigned int temp = (context->uc_mcontext->fs.fpu_mxcsr) & ~0x3F;
+    asm ("ldmxcsr %0" : : "m" (temp));
+    /* same for x87 FPU. */
+    asm ("fldcw %0" : : "m" (fpu_control_word));
+}
+
 #endif