<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Raymond Toy pushed to branch rtoy-setexception-inexact at <a href="https://gitlab.common-lisp.net/cmucl/cmucl">cmucl / cmucl</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/97bd0eaa99f355568b4d588863964b2cbaa61578">97bd0eaa</a></strong>
<div>
<span>by Raymond Toy</span>
<i>at 2015-12-24T10:37:57Z</i>
</div>
<pre class='commit-message'>Add WITH-FLOAT-TRAPS-ENABLED to enable specific traps.

This works like WITH-FLOAT-TRAPS-MASKED, except that the specified
traps are enabled.

Use this in fdlibm to enable the inexact trap.</pre>
</li>
</ul>
<h4>2 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/code/exports.lisp
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/code/float-trap.lisp
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/97bd0eaa99f355568b4d588863964b2cbaa61578#diff-0'>
<strong>
src/code/exports.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/exports.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/exports.lisp
</span><span style="color: #aaaaaa">@@ -1583,7 +1583,8 @@
</span>      "FLOAT-DENORMALIZED-P" "FLOAT-INFINITY-P"
           "FLOAT-NAN-P" "FLOAT-TRAPPING-NAN-P"
           "FLOAT-SIGNALING-NAN-P"
<span style="color: #000000;background-color: #ffdddd">-           "WITH-FLOAT-TRAPS-MASKED")
</span><span style="color: #000000;background-color: #ddffdd">+      "WITH-FLOAT-TRAPS-MASKED"
+          "WITH-FLOAT-TRAPS-ENABLED")
</span>   ;; More float extensions
   #+double-double
   (:export "LEAST-POSITIVE-NORMALIZED-DOUBLE-DOUBLE-FLOAT"
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/97bd0eaa99f355568b4d588863964b2cbaa61578#diff-1'>
<strong>
src/code/float-trap.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/float-trap.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/float-trap.lisp
</span><span style="color: #aaaaaa">@@ -23,7 +23,8 @@
</span> )
 (in-package "EXTENSIONS")
 (export '(set-floating-point-modes get-floating-point-modes
<span style="color: #000000;background-color: #ffdddd">-          with-float-traps-masked))
</span><span style="color: #000000;background-color: #ddffdd">+     with-float-traps-masked
+         with-float-traps-enabled))
</span> (in-package "VM")
 
 (eval-when (compile load eval)
<span style="color: #aaaaaa">@@ -406,3 +407,44 @@
</span>                         #+ppc
                              ,invalid-mask
                              #+mips ,(dpb 0 float-exceptions-byte #xffffffff))))))))
<span style="color: #000000;background-color: #ddffdd">+
+(defmacro with-float-traps-enabled (traps &body body)
+  "Execute BODY with the floating point exceptions listed in TRAPS
+  enabled.  TRAPS should be a list of possible exceptions which
+  includes :UNDERFLOW, :OVERFLOW, :INEXACT, :INVALID and
+  :DIVIDE-BY-ZERO and on the X86 :DENORMALIZED-OPERAND. The respective
+  accrued exceptions are cleared at the start of the body to support
+  their testing within, and restored on exit."
+  (let ((traps (dpb (float-trap-mask traps) float-traps-byte 0))
+       (exceptions (dpb (float-trap-mask traps) float-sticky-bits 0))
+       (trap-mask (dpb (lognot (float-trap-mask traps))
+                       float-traps-byte #xffffffff))
+       (exception-mask (dpb (lognot (vm::float-trap-mask traps))
+                            float-sticky-bits #xffffffff))
+       ;; On ppc if we are masking the invalid trap, we need to make
+       ;; sure we wipe out the various individual sticky bits
+       ;; representing the invalid operation.  Otherwise, if we
+       ;; enable the invalid trap later, these sticky bits will cause
+       ;; an exception.
+       #+ppc
+       (invalid-mask (if (member :invalid traps)
+                         (dpb 0
+                              (byte 1 31)
+                              (dpb 0 vm::float-invalid-op-2-byte
+                                   (dpb 0 vm:float-invalid-op-1-byte #xffffffff)))
+                         #xffffffff))
+       (orig-modes (gensym)))
+    `(let ((,orig-modes (floating-point-modes)))
+      (unwind-protect
+          (progn
+            (setf (floating-point-modes)
+                  (logorc2 ,orig-modes ,(logand trap-mask exception-mask)))
+            ,@body)
+       ;; Restore the original traps and exceptions.
+       (setf (floating-point-modes)
+             (logior (logand ,orig-modes ,(logior traps exceptions))
+                     (logand (floating-point-modes)
+                             ,(logand trap-mask exception-mask)
+                             #+ppc
+                             ,invalid-mask
+                             #+mips ,(dpb 0 float-exceptions-byte #xffffffff))))))))
</span></code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/97bd0eaa99f355568b4d588863964b2cbaa61578">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.common-lisp.net.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.common-lisp.net/cmucl/cmucl/commit/97bd0eaa99f355568b4d588863964b2cbaa61578"}}</script>
</p>
</div>
</body>
</html>