From: Nikodemus Siivola Date: Wed, 1 Sep 2010 16:05:17 +0000 (+0000) Subject: 1.0.42.17: better host lisp fasl-type logic X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=e8e0f5803f2940799fa5969715f9eb3238939be5;p=sbcl.git 1.0.42.17: better host lisp fasl-type logic * 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. --- diff --git a/NEWS b/NEWS index 0cbd098..4aabc59 100644 --- 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. diff --git a/src/runtime/x86-64-bsd-os.c b/src/runtime/x86-64-bsd-os.c index 93dec52..8c54503 100644 --- a/src/runtime/x86-64-bsd-os.c +++ b/src/runtime/x86-64-bsd-os.c @@ -8,6 +8,10 @@ #include #endif +#if defined(LISP_FEATURE_OPENBSD) +#include +#endif + #ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER #include @@ -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 diff --git a/src/runtime/x86-64-bsd-os.h b/src/runtime/x86-64-bsd-os.h index aefdd30..9db3ae7 100644 --- a/src/runtime/x86-64-bsd-os.h +++ b/src/runtime/x86-64-bsd-os.h @@ -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 */