]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/s_nextafter.c
Improve the accuracy of tgamma (BZ #26983)
[thirdparty/glibc.git] / math / s_nextafter.c
index 7b026f00cee976fea2da0d21f5ff1b1cfe3818a2..792c9d1d78436339ee97581b1b3d7c0ae6576d3e 100644 (file)
@@ -25,14 +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-barriers.h>
 #include <math_private.h>
 #include <float.h>
+#include <libm-alias-double.h>
 
 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);
@@ -70,22 +73,20 @@ double __nextafter(double x, double y)
        }
        hy = hx&0x7ff00000;
        if(hy>=0x7ff00000) {
-         x = x+x;      /* overflow  */
-         if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
-           asm ("" : "+m"(x));
-         return x;     /* overflow  */
+         double u = x+x;       /* overflow  */
+         math_force_eval (u);
+         __set_errno (ERANGE);
        }
        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