1.0.42.8: fix build on OpenBSD/i386 -current and upcoming 4.8 release
authorNikodemus Siivola <nikodemus@random-state.net>
Tue, 31 Aug 2010 13:04:54 +0000 (13:04 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Tue, 31 Aug 2010 13:04:54 +0000 (13:04 +0000)
 * Patch by Josh Elsasser, lp#615489.

 * On OpenBSD/i386, the structure that stores the FPU state during
   signals was recently moved.

   Add a script to tools-for-build/ which is run from make-config.sh
   to detect where the FPU state is located, and create a
   src/runtime/openbsd-sigcontext.h header containing a #define which
   src/runtime/x86-bsd-os.c can use.

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

 * Missing NEWS entry for last commit.

NEWS
make-config.sh
src/runtime/x86-bsd-os.c
tools-for-build/openbsd-sigcontext.sh [new file with mode: 0644]
version.lisp-expr

diff --git a/NEWS b/NEWS
index 64ca237..ed85faa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ changes relative to sbcl-1.0.42
     correctly. (lp#598374, thanks to Stas Boukarev)
   * bug fix: better availability of names of foreign functions in backtraces
     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)
 
 changes in sbcl-1.0.42 relative to sbcl-1.0.41
   * build changes
index c05acab..fcdd9f9 100644 (file)
@@ -310,6 +310,10 @@ if [ "$sbcl_arch" = "x86" ]; then
         # roughly-equivalent magic nevertheless.
         printf ' :os-provides-dlopen' >> $ltf
     fi
+    if [ "$sbcl_os" = "openbsd" ]; then
+        rm -f src/runtime/openbsd-sigcontext.h
+        sh tools-for-build/openbsd-sigcontext.sh > src/runtime/openbsd-sigcontext.h
+    fi
 elif [ "$sbcl_arch" = "x86-64" ]; then
     printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
     printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
index d071666..1054659 100644 (file)
 #endif
 
 #if defined(LISP_FEATURE_OPENBSD)
-#include <machine/frame.h>
 #include <machine/npx.h>
 #include <stddef.h>
+#include "openbsd-sigcontext.h"
+#ifdef OS_OPENBSD_FPSTATE_IN_SIGFRAME
+# include <machine/frame.h>
+#endif
 #endif
 
 /* KLUDGE: There is strong family resemblance in the signal context
@@ -248,11 +251,14 @@ os_restore_fp_control(os_context_t *context)
 void
 os_restore_fp_control(os_context_t *context)
 {
-    struct sigframe *frame;
-    union savefpu *fpu;
+#ifdef OS_OPENBSD_FPSTATE_IN_SIGFRAME
+    struct sigframe *frame = (struct sigframe *)((char*)context -
+        offsetof(struct sigframe, sf_sc));
+    union savefpu *fpu = frame->sf_fpstate;
+#elif defined(OS_OPENBSD_FPSTATE_IN_SIGCONTEXT)
+    union savefpu *fpu = context->sc_fpstate;
+#endif
 
-    frame = (struct sigframe *)((char*)context - offsetof(struct sigframe, sf_sc));
-    fpu = frame->sf_fpstate;
     if (openbsd_use_fxsave)
         __asm__ __volatile__ ("fldcw %0" : : "m" (fpu->sv_xmm.sv_env.en_cw));
     else
diff --git a/tools-for-build/openbsd-sigcontext.sh b/tools-for-build/openbsd-sigcontext.sh
new file mode 100644 (file)
index 0000000..4281bef
--- /dev/null
@@ -0,0 +1,41 @@
+cd ./tools-for-build
+
+base=openbsd-sigcontext
+
+# check for sf_fpstate in struct sigframe (ie: pre July 2010)
+rm -f "${base}.c"
+cat > "${base}.c" <<EOF
+#include <stddef.h>
+#include <stdio.h>
+#include <machine/frame.h>
+int
+main()
+{
+    printf("it works: %d\n", offsetof(struct sigframe, sf_fpstate));
+    return (0);
+}
+EOF
+if $GNUMAKE "${base}" > /dev/null 2>&1 && "./${base}" > /dev/null 2>&1
+then
+    echo '#define OS_OPENBSD_FPSTATE_IN_SIGFRAME'
+fi
+
+# check for sc_fpstate in struct sigcontext (ie: July 2010 and later)
+rm -f "${base}.c"
+cat > "${base}.c" <<EOF
+#include <stddef.h>
+#include <stdio.h>
+#include <signal.h>
+int
+main()
+{
+    printf("it works: %d\n", offsetof(struct sigcontext, sc_fpstate));
+    return (0);
+}
+EOF
+if $GNUMAKE "${base}" > /dev/null 2>&1 && "./${base}" > /dev/null 2>&1
+then
+    echo '#define OS_OPENBSD_FPSTATE_IN_SIGCONTEXT'
+fi
+
+rm -f "${base}.c" "${base}"
index 922b464..b9a66dd 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.42.7"
+"1.0.42.8"