From 463e347fa399f3e3635dc17350727fe228727c28 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 30 Nov 2018 07:59:04 +0000 Subject: [PATCH] Don't futz with floenv if not in use. Makes flo:raise-exceptions! kosher to use anywhere without incurring cost in threads that don't care. --- src/runtime/floenv.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/runtime/floenv.scm b/src/runtime/floenv.scm index d4d478ee3..37f8bab08 100644 --- a/src/runtime/floenv.scm +++ b/src/runtime/floenv.scm @@ -102,7 +102,10 @@ USA. ((ucode-primitive float-environment 0)) fp-env)))) -(define (use-floating-point-environment!) +(define-integrable (using-floating-point-environment?) + (and (thread-float-environment (current-thread)) #t)) + +(define-integrable (use-floating-point-environment!) (set-thread-float-environment! (current-thread) #t)) (define (flo:environment) @@ -243,12 +246,12 @@ USA. (flo:trappable-exceptions trappable-float-exceptions 0)) (define (flo:clear-exceptions! exceptions) - (use-floating-point-environment!) - ((ucode-primitive clear-float-exceptions 1) exceptions)) + (if (using-floating-point-environment?) + ((ucode-primitive clear-float-exceptions 1) exceptions))) (define (flo:raise-exceptions! exceptions) - (use-floating-point-environment!) - ((ucode-primitive raise-float-exceptions 1) exceptions)) + (if (using-floating-point-environment?) + ((ucode-primitive raise-float-exceptions 1) exceptions))) (define (flo:restore-exception-flags! fexcept exceptions) (use-floating-point-environment!) -- 2.25.1