Skip to content
Snippets Groups Projects
Commit a610d96c authored by Raymond Toy's avatar Raymond Toy
Browse files

Merge branch 'rtoy-issue-14' into 'master'

WITH-FLOAT-TRAPS-ENABLED was incorrectly setting accrued exceptions.

Fix issue #14.

WITH-FLOAT-TRAPS-ENABLED was leaving the accrued (and current)
exceptions unchanged, but it should have cleared out any values there
that matched the exceptions to be enabled.  Without this, the next x87
operation would signal an exception if an accrued exception matched
an enabled exception.  This was the cause of issue #14.  (Note that
for x87, the accrued exception is the same as current exception.)

See merge request !5
parents a65cf4a4 edb5af9b
No related branches found
No related tags found
No related merge requests found
...@@ -417,11 +417,14 @@ ...@@ -417,11 +417,14 @@
code))))))) code)))))))
(macrolet (macrolet
((with-float-traps (name logical-op docstring) ((with-float-traps (name merge-traps docstring)
;; Define macros to enable or disable floating-point ;; Define macros to enable or disable floating-point
;; exceptions. Masked exceptions and enabled exceptions only ;; exceptions. Masked exceptions and enabled exceptions only
;; differ whether we AND in the bits or OR them, respectively. ;; differ whether we AND in the bits or OR them, respectively.
;; Logical-op is the operation to use. ;; MERGE-TRAPS is the logical operation to merge the traps with
;; the current floating-point mode. Thus, use and MERGE-EXCEPTIONS is the
;; logical operation to merge the exceptions (sticky bits) with
;; the current mode.
(let ((macro-name (symbolicate "WITH-FLOAT-TRAPS-" name))) (let ((macro-name (symbolicate "WITH-FLOAT-TRAPS-" name)))
`(progn `(progn
(defmacro ,macro-name (traps &body body) (defmacro ,macro-name (traps &body body)
...@@ -450,7 +453,8 @@ ...@@ -450,7 +453,8 @@
(progn (progn
(setf (floating-point-modes) (setf (floating-point-modes)
(ldb (byte 32 0) (ldb (byte 32 0)
(,',logical-op ,orig-modes ,(logand trap-mask exception-mask)))) (logand (,',merge-traps ,orig-modes ,trap-mask)
,exception-mask)))
,@body) ,@body)
;; Restore the original traps and exceptions. ;; Restore the original traps and exceptions.
(setf (floating-point-modes) (setf (floating-point-modes)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment