From: Taylor R Campbell Date: Mon, 26 Aug 2019 03:14:22 +0000 (+0000) Subject: If enabling fp traps for first time, clear sticky exceptions. X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~58 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5e3de39d43d7b9736a5583073112e237a5da00a9;p=mit-scheme.git If enabling fp traps for first time, clear sticky exceptions. 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. --- diff --git a/src/runtime/floenv.scm b/src/runtime/floenv.scm index fc6254859..149e815da 100644 --- a/src/runtime/floenv.scm +++ b/src/runtime/floenv.scm @@ -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!)