1.0.38.11: Enable floating-point exception delivery on PPC/Linux.
authorAlastair Bridgewater <lisphacker@users.sourceforge.net>
Sun, 23 May 2010 22:49:58 +0000 (22:49 +0000)
committerAlastair Bridgewater <lisphacker@users.sourceforge.net>
Sun, 23 May 2010 22:49:58 +0000 (22:49 +0000)
  * For some reason, Linux disables floating-point exception delivery
by default.  Use the PR_SET_FPEXC prctl (new in 2.4.21 and 2.5.32) to
enable it in "precise" mode (possibly overkill).

  * This is necessary but not sufficient to fix one of the failing
tests in float.pure.lisp.

  * Given that this is only necessary for one test case, the test
suite has woefully incomplete coverage of floating-point exceptions.

src/runtime/ppc-linux-os.c
version.lisp-expr

index 07124f1..fe22e41 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <sys/prctl.h>
 
 #include "validate.h"
 #include "ppc-linux-mcontext.h"
 size_t os_vm_page_size;
 
 int arch_os_thread_init(struct thread *thread) {
+    /* For some reason, PPC Linux appears to default to not generating
+     * floating point exceptions.  PR_SET_FPEXC is a PPC-specific
+     * option new in kernel 2.4.21 and 2.5.32 that allows us to
+     * configure this.  Should we need to run on an older kenel, the
+     * equivalent trick is to get into a signal-handling context and
+     * modify the saved machine state register.
+     *
+     * PR_FP_EXC_PRECISE may be more accurate than we need,
+     * particularly if we move to the x86oid trick of inserting
+     * explicit synchronization for floating-point exception
+     * delivery.  If we wish to move to such a model, the other two
+     * exception delivery modes that we could use are PR_FP_EXC_ASYNC
+     * and PR_FP_EXC_NONRECOV, and exception delivery can be forced
+     * by any access to the FPSCR.  -- AB, 2010-May-23 */
+    prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE, 0, 0);
+
     return 1;                   /* success */
 }
 int arch_os_thread_cleanup(struct thread *thread) {
index 1b7b1eb..9d3ff57 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.38.10"
+"1.0.38.11"