* math/w_fmod.c: Also handle x=±Inf as error.

* math/w_fmodf.c: Likewise.
	* math/w_fmodl.c: Likewise.
	* math/libm-test.inc (fmod_test): Add tests for errno after calls for
	x=±Inf or y=0.
This commit is contained in:
Ulrich Drepper 2009-04-26 03:43:02 +00:00
parent 0c59a1963e
commit 7095366d1e
5 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,11 @@
2009-04-25 Ulrich Drepper <drepper@redhat.com>
* math/w_fmod.c: Also handle x=±Inf as error.
* math/w_fmodf.c: Likewise.
* math/w_fmodl.c: Likewise.
* math/libm-test.inc (fmod_test): Add tests for errno after calls for
x=±Inf or y=0.
* sysdeps/i386/fpu/s_cos.S: Set errno for ±Inf.
* sysdeps/i386/fpu/s_cosf.S: Likewise.
* sysdeps/i386/fpu/s_cosl.S: Likewise.

View File

@ -2883,11 +2883,17 @@ fmod_test (void)
TEST_ff_f (fmod, minus_zero, 3, minus_zero);
/* fmod (+inf, y) == NaN plus invalid exception. */
errno = 0;
TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (-inf, y) == NaN plus invalid exception. */
errno = 0;
TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(-Inf,3) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, +0) == NaN plus invalid exception. */
errno = 0;
TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
check_int ("errno for fmod(3,0) unchanged", errno, EDOM, 0, 0, 0);
/* fmod (x, -0) == NaN plus invalid exception. */
TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);

View File

@ -35,8 +35,9 @@ static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $";
double z;
z = __ieee754_fmod(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnan(y)||__isnan(x)) return z;
if(y==0.0) {
return __kernel_standard(x,y,27); /* fmod(x,0) */
if(__isinf(x)||y==0.0) {
/* fmod(+-Inf,y) or fmod(x,0) */
return __kernel_standard(x,y,27);
} else
return z;
#endif

View File

@ -8,7 +8,7 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@ -17,7 +17,7 @@
static char rcsid[] = "$NetBSD: w_fmodf.c,v 1.3 1995/05/10 20:48:57 jtc Exp $";
#endif
/*
/*
* wrapper fmodf(x,y)
*/
@ -38,8 +38,8 @@ static char rcsid[] = "$NetBSD: w_fmodf.c,v 1.3 1995/05/10 20:48:57 jtc Exp $";
float z;
z = __ieee754_fmodf(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnanf(y)||__isnanf(x)) return z;
if(y==(float)0.0) {
/* fmodf(x,0) */
if(__isinff(x)||y==(float)0.0) {
/* fmodf(+-Inf,y) or fmodf(x,0) */
return (float)__kernel_standard((double)x,(double)y,127);
} else
return z;

View File

@ -39,8 +39,9 @@ static char rcsid[] = "$NetBSD: $";
long double z;
z = __ieee754_fmodl(x,y);
if(_LIB_VERSION == _IEEE_ ||__isnanl(y)||__isnanl(x)) return z;
if(y==0.0) {
return __kernel_standard(x,y,227); /* fmod(x,0) */
if(__isinfl(x)||y==0.0) {
/* fmodl(+-Inf,y) or fmodl(x,0) */
return __kernel_standard(x,y,227);
} else
return z;
#endif