Re: [PATCH] libm: switch sf_log1p from double error routines to float

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Nov 29 11:23, Keith Packard wrote:
> sf_log1p was using __math_divzero and __math_invalid, which
> drag in a pile of double-precision code. Switch to using the
> single-precision variants. This also required making those
> available in __OBSOLETE_MATH mode.
> 
> Signed-off-by: Keith Packard <[email protected]>
> ---
>  newlib/libm/common/math_errf.c | 2 --
>  newlib/libm/common/sf_log1p.c  | 4 ++--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/newlib/libm/common/math_errf.c b/newlib/libm/common/math_errf.c
> index 762fc2799..53c68b1cf 100644
> --- a/newlib/libm/common/math_errf.c
> +++ b/newlib/libm/common/math_errf.c
> @@ -75,7 +75,6 @@ __math_oflowf (uint32_t sign)
>    return xflowf (sign, 0x1p97f);
>  }
>  
> -#if !__OBSOLETE_MATH
>  HIDDEN float
>  __math_divzerof (uint32_t sign)
>  {
> @@ -89,4 +88,3 @@ __math_invalidf (float x)
>    float y = (x - x) / (x - x);
>    return isnan (x) ? y : with_errnof (y, EDOM);
>  }
> -#endif /* !__OBSOLETE_MATH */
> diff --git a/newlib/libm/common/sf_log1p.c b/newlib/libm/common/sf_log1p.c
> index d86768082..d326e00ba 100644
> --- a/newlib/libm/common/sf_log1p.c
> +++ b/newlib/libm/common/sf_log1p.c
> @@ -56,9 +56,9 @@ static float zero = 0.0;
>  	if (hx < 0x3ed413d7) {			/* x < 0.41422  */
>  	    if(ax>=0x3f800000) {		/* x <= -1.0 */
>  		if(x==(float)-1.0)
> -		    return __math_divzero (1); /* log1p(-1)=-inf */
> +		    return __math_divzerof (1); /* log1p(-1)=-inf */
>  		else
> -		    return __math_invalid (x);	/* log1p(x<-1)=NaN */
> +		    return __math_invalidf (x);	/* log1p(x<-1)=NaN */
>  	    }
>  	    if(ax<0x31000000) {			/* |x| < 2**-29 */
>  		if(two25+x>zero			/* raise inexact */
> -- 
> 2.24.0

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl3k09UACgkQ9TYGna5E
T6AmDA/+PPQUn/477ojEnAWDZ55zR8YdKxKcxJrGrtZNzDdnkKX2kZmmZA8aHcY9
4dDHGlLCSEk0UpBz85ALir+4ZO3O2InOLsj9Wp6SNL6oqaNTSFx+EJdCqvl8FIAt
dcL6lNxC0cvY1Q7ZxlnqhxYXBn7tC8RrbrmEZ9iCIxiJmwU3JIK915Hc9P0FjKgq
K1E3dxseVmCrIgB0kECfRgRMzMSW8v+I/BCa46p25afMrdyY48BUDJ6RFtylLcNG
Kw/5EhUe9EI5gFYFLdZT+DFwaV4aZ2KDftp4FMsz21WpBFH+7mCZk3uHOGtrXGYm
llZqvx8XROzPNYWLnMOeShpbBNGbTuy16AztjLyGqpVKThaBUmliqFMJw9Z+S6YP
+FImSHYiZv/qFxUA42nS7VJNfs5B6vKAPHwKnCAuh12I8GtYqVwlnhn3sbUxA7VT
ahpHKciO5wfE55iTR4tM2AOrkF7sTCx5t8CV37MUAw2j21y3eB4wEftUkTljAHbK
X+Nz77I6PEzaL2ePkBGyANpBpeEZ3XtdDgN3Sw1xIWFgZsYyLzY8Psv0rleR2VXd
PHocK5NRzi6Ak9c39divCFmUWeHOofE0rk8/78VgENeiqyimwIWbjthX5PiezejR
bafpKX+6GQULzdgck+p2Po4aGDlUTS0Je3sOyRauDv8dQCX53xI=
=ATjB
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.