Make flo:clear-exceptions! register interest in fp env.
authorTaylor R Campbell <campbell@mumble.net>
Sat, 1 Dec 2018 22:39:12 +0000 (22:39 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sat, 1 Dec 2018 22:39:12 +0000 (22:39 +0000)
Not sure why I made it conditional before.  Makes sense for
flo:raise-exceptions! for functions whose callers might or might not
want them, but usually you do flo:clear-exceptions! only if you are
actually going to use them afterward.

src/runtime/floenv.scm
tests/runtime/test-floenv.scm

index 37f8bab08ee7db6011df7eefd74f021a3f97db40..6c7bb0febe500da26bd51ca30ccd3b3f68684f11 100644 (file)
@@ -246,8 +246,8 @@ USA.
   (flo:trappable-exceptions trappable-float-exceptions 0))
 
 (define (flo:clear-exceptions! exceptions)
-  (if (using-floating-point-environment?)
-      ((ucode-primitive clear-float-exceptions 1) exceptions)))
+  (use-floating-point-environment!)
+  ((ucode-primitive clear-float-exceptions 1) exceptions))
 
 (define (flo:raise-exceptions! exceptions)
   (if (using-floating-point-environment?)
index c754e0e3705636040c744618a10e1043940d43eb..9fc9cc0f8b7420003601f2421d6c4bef5f2cc340 100644 (file)
@@ -536,25 +536,23 @@ USA.
     ;; block thread-switching so nobody else can get in -- and then
     ;; confirm that within flo:preserving-environment,
     ;; flo:clear-exceptions! actually clears the exceptions.
-    (expect-failure
-     (lambda ()
-       (assert-eqv
-        (without-interruption
+    (assert-eqv
+     (without-interruption
+      (lambda ()
+        ;; Trigger as many floating-point exceptions as we can.  If
+        ;; they trap, ignore it.  Don't enable floating-point traps
+        ;; since we're testing what happens if we haven't done any
+        ;; operations that touch the floating-point environment.
+        (ignore-errors
+         (lambda ()
+           (flo:sqrt -1.)
+           (flo:/ flo:smallest-positive-normal 2.)
+           (flo:sqrt 2.)
+           (flo:exp (flo:* 2. flo:greatest-normal-exponent-base-e))))
+        (flo:preserving-environment
          (lambda ()
-           ;; Trigger as many floating-point exceptions as we can.  If
-           ;; they trap, ignore it.  Don't enable floating-point traps
-           ;; since we're testing what happens if we haven't done any
-           ;; operations that touch the floating-point environment.
-           (ignore-errors
-            (lambda ()
-              (flo:sqrt -1.)
-              (flo:/ flo:smallest-positive-normal 2.)
-              (flo:sqrt 2.)
-              (flo:exp (flo:* 2. flo:greatest-normal-exponent-base-e))))
-           (flo:preserving-environment
-            (lambda ()
-              ;; Clear the exceptions.
-              (flo:clear-exceptions! (flo:supported-exceptions))
-              ;; Test the exceptions.  They should actually be cleared.
-              (flo:test-exceptions (flo:supported-exceptions))))))
-        0)))))
+           ;; Clear the exceptions.
+           (flo:clear-exceptions! (flo:supported-exceptions))
+           ;; Test the exceptions.  They should actually be cleared.
+           (flo:test-exceptions (flo:supported-exceptions))))))
+     0)))