public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Set errno in expm1{,f} / log1p{,f}
@ 2019-07-09 17:08 Jeff Johnston
  0 siblings, 0 replies; only message in thread
From: Jeff Johnston @ 2019-07-09 17:08 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0d24a86822a5ee73d6a6aa69e2a0118aa1e35204

commit 0d24a86822a5ee73d6a6aa69e2a0118aa1e35204
Author: Jeff Johnston <jjohnstn@redhat.com>
Date:   Tue Jul 9 13:06:59 2019 -0400

    Set errno in expm1{,f} / log1p{,f}
    
    2019-07-09  Joern Rennecke  <joern.rennecke@riscy-ip.com>
    
    	* libm/common/s_expm1.c ("math_config.h"): Include.
    	(expm1): Use __math_oflow to set errno.
    	* libm/common/s_log1p.c ("math_config.h"): Include.
    	(log1p): Use __math_divzero and __math_invalid to set errno.
    	* libm/common/sf_expm1.c ("math_config.h"): Include.
    	(expm1f): Use __math_oflow to set errno.
    	* libm/common/sf_log1p.c ("math_config.h"): Include.
    	(log1pf): Use __math_divzero and __math_invalid to set errno.

Diff:
---
 newlib/libm/common/s_expm1.c  | 3 ++-
 newlib/libm/common/s_log1p.c  | 7 +++++--
 newlib/libm/common/sf_expm1.c | 3 ++-
 newlib/libm/common/sf_log1p.c | 7 +++++--
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/newlib/libm/common/s_expm1.c b/newlib/libm/common/s_expm1.c
index a4c3912..10b0c8e 100644
--- a/newlib/libm/common/s_expm1.c
+++ b/newlib/libm/common/s_expm1.c
@@ -142,6 +142,7 @@ PORTABILITY
  */
 
 #include "fdlibm.h"
+#include "math_config.h"
 
 #ifndef _DOUBLE_IS_32BITS
 
@@ -190,7 +191,7 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
 		         return x+x; 	 /* NaN */
 		    else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
 	        }
-	        if(x > o_threshold) return huge*huge; /* overflow */
+	        if(x > o_threshold) return __math_oflow (0); /* overflow */
 	    }
 	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
 		if(x+tiny<0.0)		/* raise inexact */
diff --git a/newlib/libm/common/s_log1p.c b/newlib/libm/common/s_log1p.c
index 359c257..c44461e 100644
--- a/newlib/libm/common/s_log1p.c
+++ b/newlib/libm/common/s_log1p.c
@@ -113,6 +113,7 @@ Interface Definition (Issue 2).
  */
 
 #include "fdlibm.h"
+#include "math_config.h"
 
 #ifndef _DOUBLE_IS_32BITS
 
@@ -154,8 +155,10 @@ static double zero = 0.0;
 	k = 1;
 	if (hx < 0x3FDA827A) {			/* x < 0.41422  */
 	    if(ax>=0x3ff00000) {		/* x <= -1.0 */
-		if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
-		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
+		if(x==-1.0)
+		    return __math_divzero (1);	/* log1p(-1)=-inf */
+		else
+		    return __math_invalid (x);	/* log1p(x<-1)=NaN */
 	    }
 	    if(ax<0x3e200000) {			/* |x| < 2**-29 */
 		if(two54+x>zero			/* raise inexact */
diff --git a/newlib/libm/common/sf_expm1.c b/newlib/libm/common/sf_expm1.c
index 4ba3b81..ed98650 100644
--- a/newlib/libm/common/sf_expm1.c
+++ b/newlib/libm/common/sf_expm1.c
@@ -14,6 +14,7 @@
  */
 
 #include "fdlibm.h"
+#include "math_config.h"
 
 #ifdef __v810__
 #define const
@@ -60,7 +61,7 @@ Q5  =  -2.0109921195e-07; /* 0xb457edbb */
 	    if(FLT_UWORD_IS_INFINITE(hx))
 		return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
 	    if(xsb == 0 && hx > FLT_UWORD_LOG_MAX) /* if x>=o_threshold */
-		return huge*huge; /* overflow */
+		return __math_oflowf (0); /* overflow */
 	    if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */
 		if(x+tiny<(float)0.0)	/* raise inexact */
 		return tiny-one;	/* return -1 */
diff --git a/newlib/libm/common/sf_log1p.c b/newlib/libm/common/sf_log1p.c
index e09170f..d867680 100644
--- a/newlib/libm/common/sf_log1p.c
+++ b/newlib/libm/common/sf_log1p.c
@@ -14,6 +14,7 @@
  */
 
 #include "fdlibm.h"
+#include "math_config.h"
 
 #ifdef __STDC__
 static const float
@@ -54,8 +55,10 @@ static float zero = 0.0;
 	if (!FLT_UWORD_IS_FINITE(hx)) return x+x;
 	if (hx < 0x3ed413d7) {			/* x < 0.41422  */
 	    if(ax>=0x3f800000) {		/* x <= -1.0 */
-		if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */
-		else return (x-x)/(x-x);	/* log1p(x<-1)=NaN */
+		if(x==(float)-1.0)
+		    return __math_divzero (1); /* log1p(-1)=-inf */
+		else
+		    return __math_invalid (x);	/* log1p(x<-1)=NaN */
 	    }
 	    if(ax<0x31000000) {			/* |x| < 2**-29 */
 		if(two25+x>zero			/* raise inexact */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-09 17:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-09 17:08 [newlib-cygwin] Set errno in expm1{,f} / log1p{,f} Jeff Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).