If enabling fp traps for first time, clear sticky exceptions.
authorTaylor R Campbell <campbell@mumble.net>
Mon, 26 Aug 2019 03:14:22 +0000 (03:14 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Mon, 26 Aug 2019 03:22:44 +0000 (03:22 +0000)
Otherwise, the indeterminate state of the sticky exceptions --
possibly from another thread -- may cause the machine to trap merely
by enabling traps.

Also, don't bother marking the floating-point environment in use when
disabling traps.

src/runtime/floenv.scm

index fc6254859a43c455eccc5fcd72dd69aad5ce0de1..149e815da9d847a7639d2010fa70cf02eb4305c7 100644 (file)
@@ -245,15 +245,20 @@ USA.
   ((ucode-primitive restore-float-exception-flags 2) fexcept exceptions))
 
 (define (flo:set-trapped-exceptions! exceptions)
-  (use-floating-point-environment!)
+  (if (not (using-floating-point-environment?))
+      (begin
+       ((ucode-primitive clear-float-exceptions 1) exceptions)
+       (use-floating-point-environment!)))
   ((ucode-primitive set-trapped-float-exceptions 1) exceptions))
 
 (define (flo:trap-exceptions! exceptions)
-  (use-floating-point-environment!)
+  (if (not (using-floating-point-environment?))
+      (begin
+       ((ucode-primitive clear-float-exceptions 1) exceptions)
+       (use-floating-point-environment!)))
   ((ucode-primitive trap-float-exceptions 1) exceptions))
 
 (define (flo:untrap-exceptions! exceptions)
-  (use-floating-point-environment!)
   ((ucode-primitive untrap-float-exceptions 1) exceptions))
 
 (define (flo:defer-exception-traps!)