newlib/libm/common: Fix modf/modff returning snan
Recent GCC appears to elide multiplication by 1, which causes snan parameters to be returned unchanged through *iptr. Use the existing conversion of snan to qnan to also set the correct result in *iptr instead. Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
5e24839658
commit
61cd34c1bf
@ -63,12 +63,6 @@ QUICKREF
|
|||||||
|
|
||||||
#ifndef _DOUBLE_IS_32BITS
|
#ifndef _DOUBLE_IS_32BITS
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
static const double one = 1.0;
|
|
||||||
#else
|
|
||||||
static double one = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
double modf(double x, double *iptr)
|
double modf(double x, double *iptr)
|
||||||
#else
|
#else
|
||||||
@ -99,8 +93,8 @@ static double one = 1.0;
|
|||||||
}
|
}
|
||||||
} else if (j0>51) { /* no fraction part */
|
} else if (j0>51) { /* no fraction part */
|
||||||
__uint32_t high;
|
__uint32_t high;
|
||||||
*iptr = x*one;
|
*iptr = x;
|
||||||
if (__fpclassifyd(x) == FP_NAN) return x+x; /* x is NaN, return NaN */
|
if (__fpclassifyd(x) == FP_NAN) return *iptr = x+x; /* x is NaN, return NaN */
|
||||||
GET_HIGH_WORD(high,x);
|
GET_HIGH_WORD(high,x);
|
||||||
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
|
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
|
||||||
return x;
|
return x;
|
||||||
|
@ -15,12 +15,6 @@
|
|||||||
|
|
||||||
#include "fdlibm.h"
|
#include "fdlibm.h"
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
static const float one = 1.0;
|
|
||||||
#else
|
|
||||||
static float one = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
float modff(float x, float *iptr)
|
float modff(float x, float *iptr)
|
||||||
#else
|
#else
|
||||||
@ -51,8 +45,8 @@ static float one = 1.0;
|
|||||||
}
|
}
|
||||||
} else { /* no fraction part */
|
} else { /* no fraction part */
|
||||||
__uint32_t ix;
|
__uint32_t ix;
|
||||||
*iptr = x*one;
|
*iptr = x;
|
||||||
if (__fpclassifyf(x) == FP_NAN) return x+x; /* x is NaN, return NaN */
|
if (__fpclassifyf(x) == FP_NAN) return *iptr = x+x; /* x is NaN, return NaN */
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
|
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
|
||||||
return x;
|
return x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user