]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/s_nextafter.c
powerpc: Fix build of wcscpy with --disable-multi-arch
[thirdparty/glibc.git] / math / s_nextafter.c
index 9c678b79c57c0efb9cf3e8fd412deb284daf94c9..792c9d1d78436339ee97581b1b3d7c0ae6576d3e 100644 (file)
@@ -25,19 +25,17 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
 #define __nexttoward __internal___nexttoward
 #define nexttoward __internal_nexttoward
 
+#include <errno.h>
 #include <math.h>
-#include "math_private.h"
+#include <math-barriers.h>
+#include <math_private.h>
 #include <float.h>
+#include <libm-alias-double.h>
 
-#ifdef __STDC__
-       double __nextafter(double x, double y)
-#else
-       double __nextafter(x,y)
-       double x,y;
-#endif
+double __nextafter(double x, double y)
 {
        int32_t hx,hy,ix,iy;
-       u_int32_t lx,ly;
+       uint32_t lx,ly;
 
        EXTRACT_WORDS(hx,lx,x);
        EXTRACT_WORDS(hy,ly,y);
@@ -49,9 +47,12 @@ 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 */
-           y = x*x;
-           if(y==x) return y; else return x;   /* raise underflow flag */
+           u = math_opt_barrier (x);
+           u = u*u;
+           math_force_eval (u);                /* raise underflow flag */
+           return x;
        }
        if(hx>=0) {                             /* x > 0 */
            if(hx>hy||((hx==hy)&&(lx>ly))) {    /* x > y, x -= ulp */
@@ -72,25 +73,20 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
        }
        hy = hx&0x7ff00000;
        if(hy>=0x7ff00000) {
-         x = x+x;      /* overflow  */
-         if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
-           asm ("" : "=m"(x) : "m"(x));
-         return x;     /* overflow  */
+         double u = x+x;       /* overflow  */
+         math_force_eval (u);
+         __set_errno (ERANGE);
        }
-       if(hy<0x00100000) {             /* underflow */
-           y = x*x;
-           if(y!=x) {          /* raise underflow flag */
-               INSERT_WORDS(y,hx,lx);
-               return y;
-           }
+       if(hy<0x00100000) {
+           double u = x*x;                     /* underflow */
+           math_force_eval (u);                /* raise underflow flag */
+         __set_errno (ERANGE);
        }
        INSERT_WORDS(x,hx,lx);
        return x;
 }
-weak_alias (__nextafter, nextafter)
+libm_alias_double (__nextafter, nextafter)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__nextafter, __nextafterl)
-weak_alias (__nextafter, nextafterl)
 strong_alias (__nextafter, __nexttowardl)
 weak_alias (__nexttowardl, nexttowardl)
 #undef __nexttoward