Print this page
11210 libm should be cstyle(1ONBLD) clean

@@ -20,25 +20,26 @@
  */
 
 /*
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
+
 /*
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 #ifdef __LITTLE_ENDIAN
-#define H0(x)   *(3 + (int *) &x)
-#define H1(x)   *(2 + (int *) &x)
-#define H2(x)   *(1 + (int *) &x)
-#define H3(x)   *(int *) &x
+#define H0(x)           *(3 + (int *)&x)
+#define H1(x)           *(2 + (int *)&x)
+#define H2(x)           *(1 + (int *)&x)
+#define H3(x)           *(int *)&x
 #else
-#define H0(x)   *(int *) &x
-#define H1(x)   *(1 + (int *) &x)
-#define H2(x)   *(2 + (int *) &x)
-#define H3(x)   *(3 + (int *) &x)
+#define H0(x)           *(int *)&x
+#define H1(x)           *(1 + (int *)&x)
+#define H2(x)           *(2 + (int *)&x)
+#define H3(x)           *(3 + (int *)&x)
 #endif
 
 /*
  * log1pl(x)
  * Table look-up algorithm by modifying logl.c

@@ -112,88 +113,95 @@
 #pragma weak __log1pl = log1pl
 
 #include "libm.h"
 
 extern const long double _TBL_logl_hi[], _TBL_logl_lo[];
-
-static const long double
-zero    =   0.0L,
-one     =   1.0L,
-two     =   2.0L,
-ln2hi   =   6.931471805599453094172319547495844850203e-0001L,
-ln2lo   =   1.667085920830552208890449330400379754169e-0025L,
-A1      =   2.000000000000000000000000000000000000024e+0000L,
-A2      =   6.666666666666666666666666666666091393804e-0001L,
-A3      =   4.000000000000000000000000407167070220671e-0001L,
-A4      =   2.857142857142857142730077490612903681164e-0001L,
-A5      =   2.222222222222242577702836920812882605099e-0001L,
-A6      =   1.818181816435493395985912667105885828356e-0001L,
-A7      =   1.538537835211839751112067512805496931725e-0001L,
-B1      =   6.666666666666666666666666666666961498329e-0001L,
-B2      =   3.999999999999999999999999990037655042358e-0001L,
-B3      =   2.857142857142857142857273426428347457918e-0001L,
-B4      =   2.222222222222222221353229049747910109566e-0001L,
-B5      =   1.818181818181821503532559306309070138046e-0001L,
-B6      =   1.538461538453809210486356084587356788556e-0001L,
-B7      =   1.333333344463358756121456892645178795480e-0001L,
-B8      =   1.176460904783899064854645174603360383792e-0001L,
-B9      =   1.057293869956598995326368602518056990746e-0001L;
+static const long double zero = 0.0L,
+        one = 1.0L,
+        two = 2.0L,
+        ln2hi = 6.931471805599453094172319547495844850203e-0001L,
+        ln2lo = 1.667085920830552208890449330400379754169e-0025L,
+        A1 = 2.000000000000000000000000000000000000024e+0000L,
+        A2 = 6.666666666666666666666666666666091393804e-0001L,
+        A3 = 4.000000000000000000000000407167070220671e-0001L,
+        A4 = 2.857142857142857142730077490612903681164e-0001L,
+        A5 = 2.222222222222242577702836920812882605099e-0001L,
+        A6 = 1.818181816435493395985912667105885828356e-0001L,
+        A7 = 1.538537835211839751112067512805496931725e-0001L,
+        B1 = 6.666666666666666666666666666666961498329e-0001L,
+        B2 = 3.999999999999999999999999990037655042358e-0001L,
+        B3 = 2.857142857142857142857273426428347457918e-0001L,
+        B4 = 2.222222222222222221353229049747910109566e-0001L,
+        B5 = 1.818181818181821503532559306309070138046e-0001L,
+        B6 = 1.538461538453809210486356084587356788556e-0001L,
+        B7 = 1.333333344463358756121456892645178795480e-0001L,
+        B8 = 1.176460904783899064854645174603360383792e-0001L,
+        B9 = 1.057293869956598995326368602518056990746e-0001L;
 
 long double
-log1pl(long double x) {
+log1pl(long double x)
+{
         long double f, s, z, qn, h, t, y, g;
         int i, j, ix, iy, n, hx, m;
 
         hx = H0(x);
         ix = hx & 0x7fffffff;
+
         if (ix < 0x3ffaf07c) {  /* |x|<2/33 */
                 if (ix <= 0x3f8d0000) { /* x <= 2**-114, return x */
-                        if ((int) x == 0)
+                        if ((int)x == 0)
                                 return (x);
                 }
+
                 s = x / (two + x);      /* |s|<2**-8 */
                 z = s * s;
-                return (x - s * (x - z * (B1 + z * (B2 + z * (B3 + z * (B4 +
-                    z * (B5 + z * (B6 + z * (B7 + z * (B8 + z * B9))))))))));
+                return (x - s * (x - z * (B1 + z * (B2 + z * (B3 + z * (B4 + z *
+                    (B5 + z * (B6 + z * (B7 + z * (B8 + z * B9))))))))));
         }
-        if (ix >= 0x7fff0000) { /* x is +inf or NaN */
+
+        if (ix >= 0x7fff0000)           /* x is +inf or NaN */
                 return (x + fabsl(x));
-        }
+
         if (hx < 0 && ix >= 0x3fff0000) {
                 if (ix > 0x3fff0000 || (H1(x) | H2(x) | H3(x)) != 0)
                         x = zero;
+
                 return (x / zero);      /* log1p(x) is NaN  if x<-1 */
                 /* log1p(-1) is -inf */
         }
+
         if (ix >= 0x7ffeffff)
                 y = x;          /* avoid spurious overflow */
         else
                 y = one + x;
+
         iy = H0(y);
         n = ((iy + 0x200) >> 16) - 0x3fff;
         iy = (iy & 0x0000ffff) | 0x3fff0000;    /* scale 1+x to [1,2] */
         H0(y) = iy;
         z = zero;
         m = (ix >> 16) - 0x3fff;
+
         /* HI(1+x) = (((hx&0xffff)|0x10000)>>(-m))|0x3fff0000 */
         if (n == 0) {           /* x in [2/33,1) */
                 g = zero;
                 H0(g) = ((hx + (0x200 << (-m))) >> (10 - m)) << (10 - m);
                 t = x - g;
                 i = (((((hx & 0xffff) | 0x10000) >> (-m)) | 0x3fff0000) +
                         0x200) >> 10;
                 H0(z) = i << 10;
-
         } else if ((1 + n) == 0 && (ix < 0x3ffe0000)) { /* x in (-0.5,-2/33] */
                 g = zero;
                 H0(g) = ((ix + (0x200 << (-m - 1))) >> (9 - m)) << (9 - m);
                 t = g + x;
                 t = t + t;
+
                 /*
                  * HI(2*(1+x)) =
                  * ((0x10000-(((hx&0xffff)|0x10000)>>(-m)))<<1)|0x3fff0000
                  */
+
                 /*
                  * i =
                  * ((((0x10000-(((hx&0xffff)|0x10000)>>(-m)))<<1)|0x3fff0000)+
                  * 0x200)>>10; H0(z)=i<<10;
                  */

@@ -206,12 +214,12 @@
         }
 
         s = t / (y + z);
         j = i & 0x3f;
         z = s * s;
-        qn = (long double) n;
+        qn = (long double)n;
         t = qn * ln2lo + _TBL_logl_lo[j];
         h = qn * ln2hi + _TBL_logl_hi[j];
-        f = t + s * (A1 + z * (A2 + z * (A3 + z * (A4 + z * (A5 + z * (A6 +
-                z * A7))))));
+        f = t + s * (A1 + z * (A2 + z * (A3 + z * (A4 + z * (A5 + z * (A6 + z *
+            A7))))));
         return (h + f);
 }