<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-15-handle-fpu-exceptions
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/1fab9bf37ce138dba85e5fb85a10f8b1ad37c390">1fab9bf3</a></strong>
<div>
<span>by Raymond Toy</span>
<i>at 2016-01-13T21:34:39Z</i>
</div>
<pre class='commit-message'>Clean up sigfpe-handler; add comments.</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
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/1fab9bf37ce138dba85e5fb85a10f8b1ad37c390#diff-0'>
<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">@@ -312,7 +312,6 @@
</span> ;;;
;;; Signal the appropriate condition when we get a floating-point error.
;;;
<span style="color: #000000;background-color: #ffdddd">-(defvar *debug-sigfpe-handler* nil)
</span> (defun sigfpe-handler (signal code scp)
(declare (ignore signal)
(type system-area-pointer scp))
<span style="color: #aaaaaa">@@ -385,54 +384,53 @@
</span> (error _"SIGFPE with no exceptions currently enabled? (si-code = ~D)"
code))))
;; Cleanup
<span style="color: #000000;background-color: #ffdddd">- #+(and darwin ppc)
</span> (let* ((new-modes modes)
(new-exceptions (logandc2 (ldb float-exceptions-byte new-modes)
traps)))
<span style="color: #000000;background-color: #ffdddd">- ;; (format t "sigfpe: modes = #B~32,'0b~%" modes)
- ;; (format t "sigfpe: new-exc = #B~32,'0b~%" new-exceptions)
- (setf (ldb float-exceptions-byte new-modes) new-exceptions)
- ;; Clear out all exceptions and save them to the context.
- ;;
- ;; XXX: Should we just clear out the bits for the traps that are
- ;; enabled? If we did that then the accrued exceptions would be
- ;; correct.
- (setf (ldb float-sticky-bits new-modes) 0)
- ;; Clear out the various sticky invalid operation bits too.
- ;;
- ;; XXX: Should we only do that if the invalid trap is enabled?
- (setf (ldb float-invalid-op-1-byte new-modes) 0)
- (setf (ldb float-invalid-op-2-byte new-modes) 0)
- ;; Clear the FP exception summary bit too.
- (setf (ldb float-exceptions-summary-byte new-modes) 0)
- ;; (format t "sigfpe: new modes = #B~32,'0b~%" new-modes)
- (setf (floating-point-modes) new-modes)
- #+nil
- (setf (sigcontext-floating-point-modes
- (alien:sap-alien scp (* unix:sigcontext)))
- new-modes))
-
- #+sse2
- (let* ((new-modes modes)
- (new-exceptions (logandc2 (ldb float-exceptions-byte new-modes)
- traps)))
- ;; Clear out the status for any enabled traps. With SSE2, if
- ;; the current exception is enabled, the next FP instruction
- ;; will cause the exception to be signaled again. Hence, we
- ;; need to clear out the exceptions that we are handling here.
- (setf (ldb float-exceptions-byte new-modes) new-exceptions)
- ;; XXX: This seems not right. Shouldn't we be setting the modes
- ;; in the sigcontext instead? This however seems to do what we
- ;; want.
-
- (when *debug-sigfpe-handler*
- (format *debug-io* "sigcontext modes: #x~4x (~A)~%"
- modes (decode-floating-point-modes modes))
- (format *debug-io* "current modes: #x~4x (~A)~%"
- (vm:floating-point-modes) (get-floating-point-modes))
- (format *debug-io* "new modes: #x~x (~A)~%"
- new-modes (decode-floating-point-modes new-modes)))
- (setf (vm:floating-point-modes) new-modes))))))
</span><span style="color: #000000;background-color: #ddffdd">+ #+(and darwin ppc)
+ (progn
+ ;; (format t "sigfpe: modes = #B~32,'0b~%" modes)
+ ;; (format t "sigfpe: new-exc = #B~32,'0b~%" new-exceptions)
+ (setf (ldb float-exceptions-byte new-modes) new-exceptions)
+ ;; Clear out all exceptions.
+ ;;
+ ;; XXX: Should we just clear out the bits for the traps that are
+ ;; enabled? If we did that then the accrued exceptions would be
+ ;; correct.
+ (setf (ldb float-sticky-bits new-modes) 0)
+ ;; Clear out the various sticky invalid operation bits too.
+ ;;
+ ;; XXX: Should we only do that if the invalid trap is enabled?
+ (setf (ldb float-invalid-op-1-byte new-modes) 0)
+ (setf (ldb float-invalid-op-2-byte new-modes) 0)
+ ;; Clear the FP exception summary bit too.
+ (setf (ldb float-exceptions-summary-byte new-modes) 0)
+ ;; (format t "sigfpe: new modes = #B~32,'0b~%" new-modes)
+ (setf (floating-point-modes) new-modes))
+
+ #+sse2
+ (progn
+ ;; Clear out the status for any enabled traps. With SSE2, if
+ ;; the current exception is enabled, the next FP instruction
+ ;; will cause the exception to be signaled again. Hence, we
+ ;; need to clear out the exceptions that we are handling here.
+ (setf (ldb float-exceptions-byte new-modes) new-exceptions)
+ #+nil
+ (progn
+ (format *debug-io* "sigcontext modes: #x~4x (~A)~%"
+ modes (decode-floating-point-modes modes))
+ (format *debug-io* "current modes: #x~4x (~A)~%"
+ (vm:floating-point-modes) (get-floating-point-modes))
+ (format *debug-io* "new modes: #x~x (~A)~%"
+ new-modes (decode-floating-point-modes new-modes)))
+ (setf (vm:floating-point-modes) new-modes))
+
+ #-(or sse2 (and darwin ppc))
+ (progn
+ ;; Apparently nothing needed for sparc it seems The FPU
+ ;; state in the signal handler is unchanged and it seems we
+ ;; don't need to reset it any way when we throw out.
+ ))))))
</span>
(macrolet
((with-float-traps (name merge-traps docstring)
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/1fab9bf37ce138dba85e5fb85a10f8b1ad37c390">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/1fab9bf37ce138dba85e5fb85a10f8b1ad37c390"}}</script>
</p>
</div>
</body>
</html>