Mark floenv in use so exceptions stay cleared if preempted.
authorTaylor R Campbell <campbell@mumble.net>
Tue, 3 Sep 2019 13:37:25 +0000 (13:37 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Tue, 3 Sep 2019 13:37:25 +0000 (13:37 +0000)
Otherwise, we might do:

T1: clear-float-exceptions
    preempt and switch
T2: floating-point operation that raises exceptions
    preempt and switch
T1: use-floating-point-environment!

and the exceptions may remain raised from T2.

src/runtime/floenv.scm

index 149e815da9d847a7639d2010fa70cf02eb4305c7..819c9bfc642c5b86df53201568f1bd7de19b13ac 100644 (file)
@@ -247,15 +247,15 @@ USA.
 (define (flo:set-trapped-exceptions! exceptions)
   (if (not (using-floating-point-environment?))
       (begin
-       ((ucode-primitive clear-float-exceptions 1) exceptions)
-       (use-floating-point-environment!)))
+       (use-floating-point-environment!)
+       ((ucode-primitive clear-float-exceptions 1) exceptions)))
   ((ucode-primitive set-trapped-float-exceptions 1) exceptions))
 
 (define (flo:trap-exceptions! exceptions)
   (if (not (using-floating-point-environment?))
       (begin
-       ((ucode-primitive clear-float-exceptions 1) exceptions)
-       (use-floating-point-environment!)))
+       (use-floating-point-environment!)
+       ((ucode-primitive clear-float-exceptions 1) exceptions)))
   ((ucode-primitive trap-float-exceptions 1) exceptions))
 
 (define (flo:untrap-exceptions! exceptions)