]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sun, 7 Dec 2003 21:22:46 +0000 (21:22 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 7 Dec 2003 21:22:46 +0000 (21:22 +0000)
2003-12-07  Ulrich Drepper  <drepper@redhat.com>

* sysdeps/i386/fpu/s_nexttowardf.c: Construct overflow value correctly.
* sysdeps/i386/fpu/s_nexttoward.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_nexttoward.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_nexttoward.c: Likewise.
* math/Makefile (tests): Add bug-nexttoward.
* math/bug-nexttowward.c: New file.

* sysdeps/generic/s_nextafter.c: Make sure overflow exception is set.
* sysdeps/ieee754/flt-32/s_nextafterf.c: Likewise.
* math/bug-nextafter.c (main): Add tests for overflow and negative
values.

ChangeLog
math/Makefile
math/bug-nextafter.c
math/bug-nexttoward.c [new file with mode: 0644]
sysdeps/generic/s_nextafter.c
sysdeps/i386/fpu/s_nexttoward.c
sysdeps/i386/fpu/s_nexttowardf.c
sysdeps/ieee754/flt-32/s_nextafterf.c
sysdeps/ieee754/ldbl-128/s_nexttoward.c
sysdeps/ieee754/ldbl-96/s_nexttoward.c

index 1bc4afdc3ef35c445b8521ab270eaacb5c6f05cd..e2d749d33266dfcc5359c61f68e1281fe76c63da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2003-12-07  Ulrich Drepper  <drepper@redhat.com>
+
+       * sysdeps/i386/fpu/s_nexttowardf.c: Construct overflow value correctly.
+       * sysdeps/i386/fpu/s_nexttoward.c: Likewise.
+       * sysdeps/ieee754/ldbl-128/s_nexttoward.c: Likewise.
+       * sysdeps/ieee754/ldbl-96/s_nexttoward.c: Likewise.
+       * math/Makefile (tests): Add bug-nexttoward.
+       * math/bug-nexttowward.c: New file.
+
+       * sysdeps/generic/s_nextafter.c: Make sure overflow exception is set.
+       * sysdeps/ieee754/flt-32/s_nextafterf.c: Likewise.
+       * math/bug-nextafter.c (main): Add tests for overflow and negative
+       values.
+
 2003-12-06  Ulrich Drepper  <drepper@redhat.com>
 
        * math/Makefile (tests): Add bug-nextafter.
index b8624053a861c4db976c489e1f2f7a1576f445a2..c78a2a6d15e9ea2ca60a70698bd68472c9f1f032 100644 (file)
@@ -88,7 +88,7 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
 # Rules for the test suite.
 tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
        test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
-       bug-nextafter
+       bug-nextafter bug-nexttoward
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.
 test-longdouble-yes = test-ldouble test-ildoubl
index 8aa849df19dcef3026d34edd9c788376b374d5bf..015c32dd93406e5d52922b0a6c227d5491d49bb3 100644 (file)
@@ -1,3 +1,4 @@
+#include <fenv.h>
 #include <math.h>
 #include <float.h>
 #include <stdlib.h>
@@ -10,19 +11,53 @@ main (void)
 
   float i = INFINITY;
   float m = FLT_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
   if (nextafterf (m, i) != i)
     {
-      puts ("nextafterf failed");
+      puts ("nextafterf+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafterf+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafterf (-m, -i) != -i)
+    {
+      puts ("nextafterf- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafterf- did not overflow");
       ++result;
     }
 
   double di = INFINITY;
   double dm = DBL_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
   if (nextafter (dm, di) != di)
+    {
+      puts ("nextafter+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafter+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nextafter (-dm, -di) != -di)
     {
       puts ("nextafter failed");
       ++result;
     }
+  if (fetestexcept (FE_OVERFLOW) != 0)
+    {
+      puts ("nextafter- did not overflow");
+      ++result;
+    }
 
   return result;
 }
diff --git a/math/bug-nexttoward.c b/math/bug-nexttoward.c
new file mode 100644 (file)
index 0000000..e306a12
--- /dev/null
@@ -0,0 +1,65 @@
+#include <fenv.h>
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int result = 0;
+
+  long double tl = (long double) FLT_MAX + 0x1.0p128L;
+  float fi = INFINITY;
+  float m = FLT_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttowardf (m, tl) != fi)
+    {
+      puts ("nexttowardf+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttowardf+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttowardf (-m, -tl) != -fi)
+    {
+      puts ("nexttowardf- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttowardf- did not overflow");
+      ++result;
+    }
+
+  tl = (long double) DBL_MAX + 1.0e305L;
+  double di = INFINITY;
+  double dm = DBL_MAX;
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttoward (dm, tl) != di)
+    {
+      puts ("nexttoward+ failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttoward+ did not overflow");
+      ++result;
+    }
+  feclearexcept (FE_ALL_EXCEPT);
+  if (nexttoward (-dm, -tl) != -di)
+    {
+      puts ("nexttoward- failed");
+      ++result;
+    }
+  if (fetestexcept (FE_OVERFLOW) == 0)
+    {
+      puts ("nexttoward- did not overflow");
+      ++result;
+    }
+
+  return result;
+}
index 9290fc6568674d429ccb544f0729dbc4d2418227..c2d799d5df3f0c128bf10235b9bd96c945b8a760 100644 (file)
@@ -72,12 +72,10 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
        }
        hy = hx&0x7ff00000;
        if(hy>=0x7ff00000) {
-#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
-         return x+x;   /* overflow  */
-#else
-         /* Note that y is either +Inf or -Inf.  */
-         return x+y;
-#endif
+         x = x+x;      /* overflow  */
+         if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
+           asm ("" : "=m"(x) : "m"(x));
+         return x;     /* overflow  */
        }
        if(hy<0x00100000) {             /* underflow */
            y = x*x;
index 6b18df1532f88c7cea1a8bf750e5628fd56398d8..2bd768e4487739c8ea078188fe42ecd6749a7c06 100644 (file)
@@ -83,7 +83,12 @@ static char rcsid[] = "$NetBSD: $";
            }
        }
        hy = hx&0x7ff00000;
-       if(hy>=0x7ff00000) return x+x;  /* overflow  */
+       if(hy>=0x7ff00000) {
+         x = x+x;      /* overflow  */
+         /* Force conversion to double.  */
+         asm ("" : "=m"(x) : "m"(x));
+         return x;
+       }
        if(hy<0x00100000) {             /* underflow */
            double x2 = x*x;
            if(x2!=x) {         /* raise underflow flag */
index 150641f335f4b68c10bcd3585830b8e589528aac..3fbe53c3382dcd335f71113b6d1322dcd069ee55 100644 (file)
@@ -67,7 +67,12 @@ static char rcsid[] = "$NetBSD: $";
            }
        }
        hy = hx&0x7f800000;
-       if(hy>=0x7f800000) return x+x;  /* overflow  */
+       if(hy>=0x7f800000) {
+         x = x+x;      /* overflow  */
+         /* Force conversion to float.  */
+         asm ("" : "=m"(x) : "m"(x));
+         return x;
+       }
        if(hy<0x00800000) {             /* underflow */
            float x2 = x*x;
            if(x2!=x) {         /* raise underflow flag */
index e144e56acd3b5562705861b4622edd8b722ad9ad..e1568e24c93c24de8911f7a23a117096d2198b51 100644 (file)
@@ -59,12 +59,10 @@ static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp
        }
        hy = hx&0x7f800000;
        if(hy>=0x7f800000) {
-#if FLT_EVAL_METHOD == 0
-         return x+x;   /* overflow  */
-#else
-         /* Note that y is either +Inf or -Inf.  */
-         return x+y;
-#endif
+         x = x+x;      /* overflow  */
+         if (FLT_EVAL_METHOD != 0)
+           asm ("" : "=m"(x) : "m"(x));
+         return x;     /* overflow  */
        }
        if(hy<0x00800000) {             /* underflow */
            y = x*x;
index 2c654fb97335bfe07f7eb0b47457493263ed3579..553e4019732db89dfc2394031b1f5a29b51e2b7c 100644 (file)
@@ -27,6 +27,7 @@ static char rcsid[] = "$NetBSD: $";
 
 #include "math.h"
 #include "math_private.h"
+#include <float.h>
 
 #ifdef __STDC__
        double __nexttoward(double x, long double y)
@@ -83,7 +84,13 @@ static char rcsid[] = "$NetBSD: $";
            }
        }
        hy = hx&0x7ff00000;
-       if(hy>=0x7ff00000) return x+x;  /* overflow  */
+       if(hy>=0x7ff00000) {
+         x = x+x;      /* overflow  */
+         if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
+           /* Force conversion to float.  */
+           asm ("" : "=m"(x) : "m"(x));
+         return x;
+       }
        if(hy<0x00100000) {             /* underflow */
            double x2 = x*x;
            if(x2!=x) {         /* raise underflow flag */
index c29bcd146dc0a8b1a71aee1d45dd529e5ef99717..8b273af929f083703c06ba6f818e8894d6b5f97b 100644 (file)
@@ -27,6 +27,7 @@ static char rcsid[] = "$NetBSD: $";
 
 #include "math.h"
 #include "math_private.h"
+#include <float.h>
 
 #ifdef __STDC__
        double __nexttoward(double x, long double y)
@@ -80,7 +81,13 @@ static char rcsid[] = "$NetBSD: $";
            }
        }
        hy = hx&0x7ff00000;
-       if(hy>=0x7ff00000) return x+x;  /* overflow  */
+       if(hy>=0x7ff00000) {
+         x = x+x;      /* overflow  */
+         if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
+           /* Force conversion to float.  */
+           asm ("" : "=m"(x) : "m"(x));
+         return x;
+       }
        if(hy<0x00100000) {             /* underflow */
            double x2 = x*x;
            if(x2!=x) {         /* raise underflow flag */