about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-04-26 03:43:02 +0000
committerUlrich Drepper <drepper@redhat.com>2009-04-26 03:43:02 +0000
commit7095366d1efc6e58639f7c76d0b515212d61247d (patch)
tree57288207af8eee5b1a67fa7eeb3dbdc8cf9fcec5
parent0c59a1963e948c546e0d3e34de974c7e71de1134 (diff)
downloadglibc-7095366d1efc6e58639f7c76d0b515212d61247d.tar.gz
glibc-7095366d1efc6e58639f7c76d0b515212d61247d.tar.xz
glibc-7095366d1efc6e58639f7c76d0b515212d61247d.zip
* 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.
-rw-r--r--ChangeLog6
-rw-r--r--math/libm-test.inc6
-rw-r--r--math/w_fmod.c5
-rw-r--r--math/w_fmodf.c8
-rw-r--r--math/w_fmodl.c5
5 files changed, 22 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 2355ff383e..bdeac75fb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 5f4dbe7fa1..bed59e8b72 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -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);
 
diff --git a/math/w_fmod.c b/math/w_fmod.c
index 43a1d8ef5c..ca01cf2ac5 100644
--- a/math/w_fmod.c
+++ b/math/w_fmod.c
@@ -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
diff --git a/math/w_fmodf.c b/math/w_fmodf.c
index 2bd133f2d7..e2e869a3cc 100644
--- a/math/w_fmodf.c
+++ b/math/w_fmodf.c
@@ -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;
diff --git a/math/w_fmodl.c b/math/w_fmodl.c
index 7b9a297cfd..c39b2852f6 100644
--- a/math/w_fmodl.c
+++ b/math/w_fmodl.c
@@ -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