OpenLIBM: remaining local modifications
authorJohn Marino <draco@marino.st>
Sun, 12 Jul 2015 20:16:29 +0000 (22:16 +0200)
committerJohn Marino <draco@marino.st>
Sun, 12 Jul 2015 20:16:29 +0000 (22:16 +0200)
The following section is an excerpt of DRAGONFLY.README for this vendor
branch.  Many of these patched issued exist in the current libm as well,
but they are masked with WARNS?=1.  Other fixes adjust for differences
between DragonFly and OpenBSD.  The WARNS level has been raised to 3, and
it could be raised to 4 by fixing "set-but-unused" errors.

The following files have been patched
=====================================
arch/amd64/*.S             (elf note added to all assembly files)
arch/amd64/fenv.c          (#include diff from OpenBSD)
arch/amd64/fenv.h          (#include <sys/cdefs.h> for CDECL)
include/global/math.h      (#include diff, double/float typedefs)
src/e_j0.c                 (full coverage)
src/e_j0f.c                (full coverage, fix sign comparison mismatch)
src/e_j1.c                 (full coverage)
src/e_j1f.c                (full coverage, fix sign comparison mismatch)
src/e_jnf.c                (sign comparison mismatch)
src/e_pow.c                (sign comparison mismatch)
src/e_powf.c               (sign comparison mismatch)
src/e_rem_pio2f.c          (sign comparison mismatch)
src/ld80/e_fmodl.c         (sign comparison mismatch)
src/ld80/s_ceill.c         (sign comparison mismatch)
src/ld80/s_floorl.c        (sign comparison mismatch)
src/ld80/s_nextafterl.c    (strong alias, explicit eval order, always true)
src/ld80/s_remquol.c       (sign comparison mismatch)
src/s_lround.c             (sign comparison mismatch)
src/s_lroundf.c            (sign comparison mismatch)
src/s_nan.c                (#include diff from OpenBSD)
src/w_drem.c               (ansify prototype)

20 files changed:
contrib/openbsd_libm/arch/amd64/fenv.c
contrib/openbsd_libm/include/amd64/fenv.h
contrib/openbsd_libm/include/global/math.h
contrib/openbsd_libm/src/e_j0.c
contrib/openbsd_libm/src/e_j0f.c
contrib/openbsd_libm/src/e_j1.c
contrib/openbsd_libm/src/e_j1f.c
contrib/openbsd_libm/src/e_jnf.c
contrib/openbsd_libm/src/e_pow.c
contrib/openbsd_libm/src/e_powf.c
contrib/openbsd_libm/src/e_rem_pio2f.c
contrib/openbsd_libm/src/ld80/e_fmodl.c
contrib/openbsd_libm/src/ld80/s_ceill.c
contrib/openbsd_libm/src/ld80/s_floorl.c
contrib/openbsd_libm/src/ld80/s_nextafterl.c
contrib/openbsd_libm/src/ld80/s_remquol.c
contrib/openbsd_libm/src/s_lround.c
contrib/openbsd_libm/src/s_lroundf.c
contrib/openbsd_libm/src/s_nan.c
contrib/openbsd_libm/src/w_drem.c

index 708259d..6169212 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 #include <fenv.h>
-#include <machine/fpu.h>
+#include <machine/npx.h>
 
 /*
  * The following constant represents the default floating-point environment
index 8dc2343..483dbc1 100644 (file)
@@ -30,6 +30,8 @@
 #ifndef        _AMD64_FENV_H_
 #define        _AMD64_FENV_H_
 
+#include <sys/cdefs.h>
+
 /*
  * Each symbol representing a floating point exception expands to an integer
  * constant expression with values, such that bitwise-inclusive ORs of _all
index 02e1417..ad5e715 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef _MATH_H_
 #define _MATH_H_
 
-#include <sys/_types.h>
+#include <sys/types.h>
 #include <sys/limits.h>
 
 __BEGIN_DECLS
@@ -35,8 +35,8 @@ extern char __infinity[];
  * C99
  */
 #if __ISO_C_VISIBLE >= 1999
-typedef        __double_t      double_t;
-typedef        __float_t       float_t;
+typedef        double  double_t;
+typedef        float   float_t;
 
 #if __GNUC_PREREQ__(3, 3) && !defined(__vax__)
 #define        HUGE_VALF       __builtin_huge_valf()
@@ -71,7 +71,7 @@ extern char __nan[];
        ((sizeof (x) == sizeof (float)) ? \
                __fpclassifyf(x) \
        : (sizeof (x) == sizeof (double)) ? \
-               __fpclassify(x) \
+               __fpclassifyd(x) \
        :       __fpclassifyl(x))
 #define isfinite(x) \
        ((sizeof (x) == sizeof (float)) ? \
index 138d90c..a1b3722 100644 (file)
@@ -275,7 +275,7 @@ pzero(double x)
        if(ix>=0x40200000)     {p = pR8; q= pS8;}
        else if(ix>=0x40122E8B){p = pR5; q= pS5;}
        else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
-       else if(ix>=0x40000000){p = pR2; q= pS2;}
+       else /*if(ix>=0x40000000)*/ {p = pR2; q= pS2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -371,7 +371,7 @@ qzero(double x)
        if(ix>=0x40200000)     {p = qR8; q= qS8;}
        else if(ix>=0x40122E8B){p = qR5; q= qS5;}
        else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
-       else if(ix>=0x40000000){p = qR2; q= qS2;}
+       else /*if(ix>=0x40000000)*/ {p = qR2; q= qS2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
index e485e55..8e323ba 100644 (file)
@@ -59,7 +59,7 @@ j0f(float x)
         * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
         * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
         */
-               if(ix>0x80000000U) z = (invsqrtpi*cc)/sqrtf(x);
+               if((u_int32_t)ix>0x80000000U) z = (invsqrtpi*cc)/sqrtf(x);
                else {
                    u = pzerof(x); v = qzerof(x);
                    z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
@@ -133,7 +133,7 @@ y0f(float x)
                     if ((s*c)<zero) cc = z/ss;
                     else            ss = z/cc;
                 }
-                if(ix>0x80000000U) z = (invsqrtpi*ss)/sqrtf(x);
+                if((u_int32_t)ix>0x80000000U) z = (invsqrtpi*ss)/sqrtf(x);
                 else {
                     u = pzerof(x); v = qzerof(x);
                     z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
@@ -232,7 +232,7 @@ pzerof(float x)
        if(ix>=0x41000000)     {p = pR8; q= pS8;}
        else if(ix>=0x40f71c58){p = pR5; q= pS5;}
        else if(ix>=0x4036db68){p = pR3; q= pS3;}
-       else if(ix>=0x40000000){p = pR2; q= pS2;}
+       else /*if(ix>=0x40000000)*/ {p = pR2; q= pS2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -328,7 +328,7 @@ qzerof(float x)
        if(ix>=0x41000000)     {p = qR8; q= qS8;}
        else if(ix>=0x40f71c58){p = qR5; q= qS5;}
        else if(ix>=0x4036db68){p = qR3; q= qS3;}
-       else if(ix>=0x40000000){p = qR2; q= qS2;}
+       else /*if(ix>=0x40000000)*/ {p = qR2; q= qS2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
index 2c475a5..aba397d 100644 (file)
@@ -269,7 +269,7 @@ pone(double x)
         if(ix>=0x40200000)     {p = pr8; q= ps8;}
         else if(ix>=0x40122E8B){p = pr5; q= ps5;}
         else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
-        else if(ix>=0x40000000){p = pr2; q= ps2;}
+        else /*if(ix>=0x40000000)*/ {p = pr2; q= ps2;}
         z = one/(x*x);
         r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
         s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -366,7 +366,7 @@ qone(double x)
        if(ix>=0x40200000)     {p = qr8; q= qs8;}
        else if(ix>=0x40122E8B){p = qr5; q= qs5;}
        else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
-       else if(ix>=0x40000000){p = qr2; q= qs2;}
+       else /*if(ix>=0x40000000)*/ {p = qr2; q= qs2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
index b65abc0..4266127 100644 (file)
@@ -60,7 +60,7 @@ j1f(float x)
         * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
         * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
         */
-               if(ix>0x80000000U) z = (invsqrtpi*cc)/sqrtf(y);
+               if((u_int64_t)ix>0x80000000U) z = (invsqrtpi*cc)/sqrtf(y);
                else {
                    u = ponef(y); v = qonef(y);
                    z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
@@ -227,7 +227,7 @@ ponef(float x)
         if(ix>=0x41000000)     {p = pr8; q= ps8;}
         else if(ix>=0x40f71c58){p = pr5; q= ps5;}
         else if(ix>=0x4036db68){p = pr3; q= ps3;}
-        else if(ix>=0x40000000){p = pr2; q= ps2;}
+        else /*if(ix>=0x40000000)*/ {p = pr2; q= ps2;}
         z = one/(x*x);
         r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
         s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -324,7 +324,7 @@ qonef(float x)
        if(ix>=0x40200000)     {p = qr8; q= qs8;}
        else if(ix>=0x40f71c58){p = qr5; q= qs5;}
        else if(ix>=0x4036db68){p = qr3; q= qs3;}
-       else if(ix>=0x40000000){p = qr2; q= qs2;}
+       else /*if(ix>=0x40000000)*/ {p = qr2; q= qs2;}
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
index daaf1ae..ecec51b 100644 (file)
@@ -181,7 +181,7 @@ ynf(int n, float x)
        b = y1f(x);
        /* quit if b is -inf */
        GET_FLOAT_WORD(ib,b);
-       for(i=1;i<n&&ib!=0xff800000;i++){ 
+       for(i=1;i<n&&(u_int32_t)ib!=0xff800000;i++){
            temp = b;
            b = ((float)(i+i)/x)*b - a;
            GET_FLOAT_WORD(ib,b);
index 2af0e92..0f2cb0c 100644 (file)
@@ -129,7 +129,7 @@ pow(double x, double y)
                k = (iy>>20)-0x3ff;        /* exponent */
                if(k>20) {
                    j = ly>>(52-k);
-                   if((j<<(52-k))==ly) yisint = 2-(j&1);
+                   if((u_int32_t)(j<<(52-k))==ly) yisint = 2-(j&1);
                } else if(ly==0) {
                    j = iy>>(20-k);
                    if((j<<(20-k))==iy) yisint = 2-(j&1);
index 3c4269d..3931008 100644 (file)
@@ -208,7 +208,7 @@ powf(float x, float y)
        }
        else if ((j&0x7fffffff)>0x43160000)             /* z <= -150 */
            return s*tiny*tiny;                         /* underflow */
-       else if (j==0xc3160000){                        /* z == -150 */
+       else if ((u_int32_t)j==0xc3160000){             /* z == -150 */
            if(p_l<=z-p_h) return s*tiny*tiny;          /* underflow */
        }
     /*
index f2af8c4..1e86ddf 100644 (file)
@@ -125,7 +125,7 @@ __ieee754_rem_pio2f(float x, float *y)
            fn = (float)n;
            r  = t-fn*pio2_1;
            w  = fn*pio2_1t;    /* 1st round good to 40 bit */
-           if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) {  
+           if(n<32&&(ix&0xffffff00)!=(u_int32_t)npio2_hw[n-1]) {
                y[0] = r-w;     /* quick check no cancellation */
            } else {
                u_int32_t high;
index a7cf347..a0e9c03 100644 (file)
@@ -125,7 +125,7 @@ fmodl(long double x, long double y)
     /* convert back to floating value and restore the sign */
        if((hx|lx)==0)                  /* return sign(x)*0 */
            return Zero[sx];
-       while(hx<(1ULL<<HFRAC_BITS)) {  /* normalize x */
+       while(hx<(int64_t)(1ULL<<HFRAC_BITS)) { /* normalize x */
            hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;
            iy -= 1;
        }
index bff5277..50de1d5 100644 (file)
@@ -66,7 +66,7 @@ ceill(long double x)
                    if(jj0==31) i0+=1;
                    else {
                        j = i1 + (1<<(63-jj0));
-                       if(j<i1) i0+=1; /* got a carry */
+                       if(j<(u_int32_t)i1) i0+=1;      /* got a carry */
                        i1 = j;
                    }
                }
index a5b7877..16b90ac 100644 (file)
@@ -68,7 +68,7 @@ floorl(long double x)
                    if(jj0==31) i0+=1;
                    else {
                        j = i1+(1<<(63-jj0));
-                       if(j<i1) i0 +=1 ;       /* got a carry */
+                       if(j<(u_int32_t)i1) i0 +=1 ;    /* got a carry */
                        i1=j;
                    }
                }
index 0c28b02..39095c2 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <math.h>
+#include <sys/cdefs.h>
 
 #include "math_private.h"
 
@@ -32,8 +33,8 @@ nextafterl(long double x, long double y)
        ix = esx&0x7fff;                /* |x| */
        iy = esy&0x7fff;                /* |y| */
 
-       if (((ix==0x7fff)&&((hx&0x7fffffff|lx)!=0)) ||   /* x is nan */
-           ((iy==0x7fff)&&((hy&0x7fffffff|ly)!=0)))     /* y is nan */
+       if (((ix==0x7fff)&&(((hx&0x7fffffff)|lx)!=0)) ||   /* x is nan */
+           ((iy==0x7fff)&&(((hy&0x7fffffff)|ly)!=0)))     /* y is nan */
           return x+y;
        if(x==y) return y;              /* x=y, return y */
        if((ix|hx|lx)==0) {                     /* x == 0 */
@@ -59,7 +60,7 @@ nextafterl(long double x, long double y)
                }
            }
        } else {                                /* x < 0 */
-           if(esy>=0||(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
+           if(/*esy>=0||*/(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
              /* x < y, x -= ulp */
                if(lx==0) {
                    if ((hx&0x7fffffff)==0) esx -= 1;
@@ -87,4 +88,4 @@ nextafterl(long double x, long double y)
        return x;
 }
 
-__strong_alias(nexttowardl, nextafterl);
+__strong_reference(nextafterl, nexttowardl);
index 244c105..a361e34 100644 (file)
@@ -131,7 +131,7 @@ remquol(long double x, long double y, int *quo)
            *quo = (sxy ? -q : q);
            return Zero[sx!=0];
        }
-       while(hx<(1ULL<<HFRAC_BITS)) {  /* normalize x */
+       while(hx<(int64_t)(1ULL<<HFRAC_BITS)) { /* normalize x */
            hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;
            iy -= 1;
        }
index 15ac8e9..4e02eba 100644 (file)
@@ -42,7 +42,7 @@
 #define RESTYPE_MAX LONG_MAX
 #endif
 
-#define RESTYPE_BITS (sizeof(RESTYPE) * 8)
+#define RESTYPE_BITS (int)(sizeof(RESTYPE) * 8)
 
 RESTYPE
 LROUNDNAME(double x)
@@ -60,7 +60,7 @@ LROUNDNAME(double x)
        if (e < -1)
                return (0);
        /* 1.0 x 2^31 (or 2^63) is already too large */
-       if (e >= (int)RESTYPE_BITS - 1)
+       if (e >= RESTYPE_BITS - 1)
                return (s ? RESTYPE_MIN : RESTYPE_MAX); /* ??? unspecified */
 
        /* >= 2^52 is already an exact integer */
index 7858008..2b9f8ba 100644 (file)
@@ -41,7 +41,7 @@
 #define RESTYPE_MAX LONG_MAX
 #endif
 
-#define RESTYPE_BITS (sizeof(RESTYPE) * 8)
+#define RESTYPE_BITS (int)(sizeof(RESTYPE) * 8)
 
 RESTYPE
 LROUNDNAME(float x)
@@ -59,7 +59,7 @@ LROUNDNAME(float x)
        if (e < -1)
                return (0);
        /* 1.0 x 2^31 (or 2^63) is already too large */
-       if (e >= (int)RESTYPE_BITS - 1)
+       if (e >= RESTYPE_BITS - 1)
                return (s ? RESTYPE_MIN : RESTYPE_MAX); /* ??? unspecified */
 
        /* >= 2^23 is already an exact integer */
index 33628c8..d7d8a69 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <sys/types.h>
 #include <ctype.h>
-#include <endian.h>
+#include <sys/endian.h>
 #include <float.h>
 #include <math.h>
 #include <stdint.h>
index 7f50493..5038f5c 100644 (file)
@@ -8,8 +8,7 @@
 #include <math.h>
 
 double
-drem(x, y)
-       double x, y;
+drem(double x, double y)
 {
        return remainder(x, y);
 }