* math/w_fmod.c: Also handle x=±Inf as error.
authorUlrich Drepper <drepper@redhat.com>
Sun, 26 Apr 2009 03:43:02 +0000 (03:43 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 26 Apr 2009 03:43:02 +0000 (03:43 +0000)
* 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.

ChangeLog
math/libm-test.inc
math/w_fmod.c
math/w_fmodf.c
math/w_fmodl.c

index 2355ff3..bdeac75 100644 (file)
--- 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.
index 5f4dbe7..bed59e8 100644 (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);
 
index 43a1d8e..ca01cf2 100644 (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
index 2bd133f..e2e869a 100644 (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;
index 7b9a297..c39b285 100644 (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