]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/s_nextafter.c
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483,...
[thirdparty/glibc.git] / math / s_nextafter.c
index d2af52dda38d280d0bf7c617b5542278e1581fbe..9c678b79c57c0efb9cf3e8fd412deb284daf94c9 100644 (file)
@@ -26,7 +26,7 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
 #define nexttoward __internal_nexttoward
 
 #include <math.h>
-#include <math_private.h>
+#include "math_private.h"
 #include <float.h>
 
 #ifdef __STDC__
@@ -49,12 +49,9 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
           return x+y;
        if(x==y) return y;              /* x=y, return y */
        if((ix|lx)==0) {                        /* x == 0 */
-           double u;
            INSERT_WORDS(x,hy&0x80000000,1);    /* return +-minsubnormal */
-           u = math_opt_barrier (x);
-           u = u*u;
-           math_force_eval (u);                /* raise underflow flag */
-           return x;
+           y = x*x;
+           if(y==x) return y; else return x;   /* raise underflow flag */
        }
        if(hx>=0) {                             /* x > 0 */
            if(hx>hy||((hx==hy)&&(lx>ly))) {    /* x > y, x -= ulp */
@@ -77,12 +74,15 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
        if(hy>=0x7ff00000) {
          x = x+x;      /* overflow  */
          if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
-           asm ("" : "+m"(x));
+           asm ("" : "=m"(x) : "m"(x));
          return x;     /* overflow  */
        }
-       if(hy<0x00100000) {
-           double u = x*x;                     /* underflow */
-           math_force_eval (u);                /* raise underflow flag */
+       if(hy<0x00100000) {             /* underflow */
+           y = x*x;
+           if(y!=x) {          /* raise underflow flag */
+               INSERT_WORDS(y,hx,lx);
+               return y;
+           }
        }
        INSERT_WORDS(x,hx,lx);
        return x;