[cmucl-commit] [git] CMU Common Lisp branch master updated. snapshot-2014-08-25-g2aa8444

Raymond Toy rtoy at common-lisp.net
Sat Aug 23 03:33:26 UTC 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".

The branch, master has been updated
       via  2aa84447c6a2f5cee471d150a354226d0842fb69 (commit)
      from  6ae74240bfa83dafcc6251b8a014a080d757df33 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2aa84447c6a2f5cee471d150a354226d0842fb69
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Fri Aug 22 20:33:20 2014 -0700

    Make log signal errors using fdlibm_setexception.
    
     * src/lisp/e_log.c
       * Use fdlibm_setexception
     * tests/trig.lisp:
       * Add tests for log

diff --git a/src/lisp/e_log.c b/src/lisp/e_log.c
index 032f794..01022ee 100644
--- a/src/lisp/e_log.c
+++ b/src/lisp/e_log.c
@@ -100,9 +100,16 @@ static double zero   =  0.0;
 
 	k=0;
 	if (hx < 0x00100000) {			/* x < 2**-1022  */
-	    if (((hx&0x7fffffff)|lx)==0) 
-		return -two54/zero;		/* log(+-0)=-inf */
-	    if (hx<0) return (x-x)/zero;	/* log(-#) = NaN */
+	    if (((hx&0x7fffffff)|lx)==0) {
+                /* log(+-0)=-inf */
+		return fdlibm_setexception(-1.0, FDLIBM_DIVIDE_BY_ZERO);
+            }
+            
+            if (hx<0) {
+                /* log(-#) = NaN */
+                return fdlibm_setexception(x, FDLIBM_INVALID);
+            }
+            
 	    k -= 54; x *= two54; /* subnormal number, scale up x */
 	    ux.d = x;
 	    hx = ux.i[HIWORD];		/* high word of x */
diff --git a/tests/trig.lisp b/tests/trig.lisp
index 5001375..b4163b7 100644
--- a/tests/trig.lisp
+++ b/tests/trig.lisp
@@ -911,4 +911,24 @@
 		(kernel:%exp ext:double-float-positive-infinity))
   (kernel::with-float-traps-masked (:overflow)
     (assert-equal ext:double-float-positive-infinity
-		  (kernel:%exp 710d0))))
\ No newline at end of file
+		  (kernel:%exp 710d0))))
+
+(define-test log.exception
+  (:tag :fdlibm)
+  (assert-error 'division-by-zero
+		(kernel:%log 0d0))
+  (assert-error 'division-by-zero
+		(kernel:%log -0d0))
+  (assert-error 'floating-point-invalid-operation
+		(kernel:%log -1d0))
+  (assert-error 'floating-point-invalid-operation
+		(kernel:%log *snan*))
+  (assert-true (ext:float-nan-p (kernel:%log *qnan*)))
+  (kernel::with-float-traps-masked (:divide-by-zero)
+    (assert-equal ext:double-float-negative-infinity
+		  (kernel:%log 0d0))
+    (assert-equal ext:double-float-negative-infinity
+		  (kernel:%log -0d0)))
+  (kernel::with-float-traps-masked (:invalid)
+    (assert-true (ext:float-nan-p (kernel:%log -1d0)))
+    (assert-true (ext:float-nan-p (kernel:%log *snan*)))))

-----------------------------------------------------------------------

Summary of changes:
 src/lisp/e_log.c |   13 ++++++++++---
 tests/trig.lisp  |   22 +++++++++++++++++++++-
 2 files changed, 31 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
CMU Common Lisp


More information about the cmucl-commit mailing list