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

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
+
 /*
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 

@@ -32,22 +33,22 @@
 #include "libm.h"
 #include "fma.h"
 #include "fenv_inlines.h"
 
 #if defined(__sparc)
-
 static union {
         unsigned i;
         float f;
 } snan = { 0x7f800001 };
-
 long double
-__nearbyintl(long double x) {
+__nearbyintl(long double x)
+{
         union {
                 unsigned i[4];
                 long double q;
         } xx;
+
         unsigned hx, sx, i, frac;
         unsigned int fsr;
         int rm, j;
         volatile float  dummy;
 

@@ -56,19 +57,21 @@
         hx = xx.i[0] & ~0x80000000;
 
         /* handle trivial cases */
         if (hx >= 0x406f0000) { /* x is nan, inf, or already integral */
                 /* check for signaling nan */
-                if ((hx > 0x7fff0000 || (hx == 0x7fff0000 &&
-                        (xx.i[1] | xx.i[2] | xx.i[3]))) && !(hx & 0x8000)) {
+                if ((hx > 0x7fff0000 || (hx == 0x7fff0000 && (xx.i[1] |
+                    xx.i[2] | xx.i[3]))) && !(hx & 0x8000)) {
                         dummy = snan.f;
                         dummy += snan.f;
                         xx.i[0] = sx | hx | 0x8000;
                 }
+
                 return (xx.q);
-        } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0)     /* x is zero */
+        } else if ((hx | xx.i[1] | xx.i[2] | xx.i[3]) == 0) {   /* x is zero */
                 return (x);
+        }
 
         /* get the rounding mode */
         __fenv_getfsr32(&fsr);
         rm = fsr >> 30;
 

@@ -76,90 +79,108 @@
         if (sx)
                 rm ^= rm >> 1;
 
         /* handle |x| < 1 */
         if (hx < 0x3fff0000) {
-                if (rm == FSR_RP || (rm == FSR_RN && (hx >= 0x3ffe0000 &&
-                        ((hx & 0xffff) | xx.i[1] | xx.i[2] | xx.i[3]))))
+                if (rm == FSR_RP || (rm == FSR_RN && (hx >= 0x3ffe0000 && ((hx &
+                    0xffff) | xx.i[1] | xx.i[2] | xx.i[3]))))
                         xx.i[0] = sx | 0x3fff0000;
                 else
                         xx.i[0] = sx;
+
                 xx.i[1] = xx.i[2] = xx.i[3] = 0;
                 return (xx.q);
         }
 
         /* round x at the integer bit */
         j = 0x406f - (hx >> 16);
+
         if (j >= 96) {
                 i = 1 << (j - 96);
                 frac = ((xx.i[0] << 1) << (127 - j)) | (xx.i[1] >> (j - 96));
+
                 if ((xx.i[1] & (i - 1)) | xx.i[2] | xx.i[3])
                         frac |= 1;
+
                 if (!frac)
                         return (x);
+
                 xx.i[1] = xx.i[2] = xx.i[3] = 0;
                 xx.i[0] &= ~(i - 1);
+
                 if (rm == FSR_RP || (rm == FSR_RN && (frac > 0x80000000u ||
                         (frac == 0x80000000 && (xx.i[0] & i)))))
                         xx.i[0] += i;
         } else if (j >= 64) {
                 i = 1 << (j - 64);
                 frac = ((xx.i[1] << 1) << (95 - j)) | (xx.i[2] >> (j - 64));
+
                 if ((xx.i[2] & (i - 1)) | xx.i[3])
                         frac |= 1;
+
                 if (!frac)
                         return (x);
+
                 xx.i[2] = xx.i[3] = 0;
                 xx.i[1] &= ~(i - 1);
+
                 if (rm == FSR_RP || (rm == FSR_RN && (frac > 0x80000000u ||
                         (frac == 0x80000000 && (xx.i[1] & i))))) {
                         xx.i[1] += i;
+
                         if (xx.i[1] == 0)
                                 xx.i[0]++;
                 }
         } else if (j >= 32) {
                 i = 1 << (j - 32);
                 frac = ((xx.i[2] << 1) << (63 - j)) | (xx.i[3] >> (j - 32));
+
                 if (xx.i[3] & (i - 1))
                         frac |= 1;
+
                 if (!frac)
                         return (x);
+
                 xx.i[3] = 0;
                 xx.i[2] &= ~(i - 1);
+
                 if (rm == FSR_RP || (rm == FSR_RN && (frac > 0x80000000u ||
                         (frac == 0x80000000 && (xx.i[2] & i))))) {
                         xx.i[2] += i;
+
                         if (xx.i[2] == 0)
                                 if (++xx.i[1] == 0)
                                         xx.i[0]++;
                 }
         } else {
                 i = 1 << j;
                 frac = (xx.i[3] << 1) << (31 - j);
+
                 if (!frac)
                         return (x);
+
                 xx.i[3] &= ~(i - 1);
+
                 if (rm == FSR_RP || (rm == FSR_RN && (frac > 0x80000000u ||
                         (frac == 0x80000000 && (xx.i[3] & i))))) {
                         xx.i[3] += i;
+
                         if (xx.i[3] == 0)
                                 if (++xx.i[2] == 0)
                                         if (++xx.i[1] == 0)
                                                 xx.i[0]++;
                 }
         }
 
         return (xx.q);
 }
-
 #elif defined(__x86)
-
 /* inline template */
 extern long double frndint(long double);
-
 long double
-__nearbyintl(long double x) {
+__nearbyintl(long double x)
+{
         long double z;
         unsigned oldcwsw, cwsw;
 
         /* save the control and status words, mask the inexact exception */
         __fenv_getcwsw(&oldcwsw);

@@ -176,9 +197,8 @@
         oldcwsw |= (cwsw & 0x1f);
         __fenv_setcwsw(&oldcwsw);
 
         return (z);
 }
-
 #else
 #error Unknown architecture
 #endif