1.0.42.17: better host lisp fasl-type logic
authorNikodemus Siivola <nikodemus@random-state.net>
Wed, 1 Sep 2010 16:05:17 +0000 (16:05 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Wed, 1 Sep 2010 16:05:17 +0000 (16:05 +0000)
 * Patch by Josh Elsasser, lp#615492.

   In his words:

   OpenBSD/amd64 recently began running signal handlers with a clean
   FPU state, making it necessary to load the floating point control
   word. The attached patch does exactly this, and works equally well
   on OpenBSD systems from both before and after the signal handler
   change was made.

   This patch is necessary to build SBCL x86-64 on recent -current
   snapshots of OpenBSD, and for the upcoming 4.8 release.

 * Committing untested, as I don't have OpenBSD handy.

NEWS
src/runtime/x86-64-bsd-os.c
src/runtime/x86-64-bsd-os.h

diff --git a/NEWS b/NEWS
index 0cbd098..4aabc59 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,8 +17,8 @@ changes relative to sbcl-1.0.42
     on Linux. (lp#626962, thanks to Stas Boukarev)
   * bug fix: scripting fixes for Solaris and FreeBSD. (lp#615497, thanks to
     Josh Elsasser)
-  * bug fix: build fixes for OpenBSD -current and 4.8 (lp#615489, thanks to
-    Josh Elsasser)
+  * bug fix: build fixes for OpenBSD -current and 4.8 (lp#615489, lp#615492,
+    thanks to Josh Elsasser)
   * bug fix: using aliases for builtin classes as defmethod specializers
     without adding DEFTYPEs for them works. (lp#618387)
   * bug fix: timetravel by getrusage() no longer causes type-errors during GC.
index 93dec52..8c54503 100644 (file)
@@ -8,6 +8,10 @@
 #include <machine/fpu.h>
 #endif
 
+#if defined(LISP_FEATURE_OPENBSD)
+#include <machine/fpu.h>
+#endif
+
 #ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
 #include <mach/mach.h>
 
@@ -182,3 +186,16 @@ os_restore_fp_control(os_context_t *context)
     asm ("fldcw %0" : : "m" (ex->en_cw));
 }
 #endif
+
+#if defined(LISP_FEATURE_OPENBSD)
+void
+os_restore_fp_control(os_context_t *context)
+{
+    if (context->sc_fpstate != NULL) {
+        u_int32_t mxcsr = context->sc_fpstate->fx_mxcsr & ~0x3F;
+        u_int16_t cw = context->sc_fpstate->fx_fcw;
+        asm ("ldmxcsr %0" : : "m" (mxcsr));
+        asm ("fldcw %0" : : "m" (cw));
+    }
+}
+#endif
index aefdd30..9db3ae7 100644 (file)
@@ -41,4 +41,9 @@ arch_os_context_mxcsr_addr(os_context_t *context)
 }
 #endif
 
+#if defined LISP_FEATURE_OPENBSD
+#define RESTORE_FP_CONTROL_FROM_CONTEXT
+void os_restore_fp_control(os_context_t *context);
+#endif
+
 #endif /* _X86_64_BSD_OS_H */