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.
  */
 

@@ -31,15 +32,17 @@
 
 #include "libm.h"
 
 #if defined(__sparc)
 long double
-roundl(long double x) {
+roundl(long double x)
+{
         union {
                 unsigned i[4];
                 long double q;
         } xx;
+
         unsigned hx, sx, v;
         int j;
 
         xx.q = x;
         sx = xx.i[0] & 0x80000000;

@@ -51,91 +54,113 @@
 
         /* handle |x| < 1 */
         if (hx < 0x3fff0000) {
                 if (hx >= 0x3ffe0000)
                         return (sx ? -1.0L : 1.0L);
+
                 return (sx ? -0.0L : 0.0L);
         }
 
         xx.i[0] = hx;
         j = 0x406f - (hx >> 16);                /* 1 <= j <= 112 */
+
         if (j >= 96) {                          /* 96 <= j <= 112 */
                 v = (1U << (j - 96)) >> 1;
+
                 if (v) {
                         if (xx.i[0] & v)
                                 xx.i[0] += v;
+
                         xx.i[0] &= ~(v - 1);
-                } else if (xx.i[1] & 0x80000000)
+                } else if (xx.i[1] & 0x80000000) {
                                 ++xx.i[0];
+                }
+
                 xx.i[1] = xx.i[2] = xx.i[3] = 0;
         } else if (j >= 64) {                   /* 64 <= j <= 95 */
                 v = (1U << (j - 64)) >> 1;
+
                 if (v) {
                         if (xx.i[1] & v) {
                                 xx.i[1] += v;
+
                                 if (xx.i[1] < v)
                                         ++xx.i[0];
                         }
+
                         xx.i[1] &= ~(v - 1);
                 } else if (xx.i[2] & 0x80000000) {
                                 if (++xx.i[1] == 0)
                                         ++xx.i[0];
                 }
+
                 xx.i[2] = xx.i[3] = 0;
         } else if (j >= 32) {                   /* 32 <= j <= 63 */
                 v = (1U << (j - 32)) >> 1;
+
                 if (v) {
                         if (xx.i[2] & v) {
                                 xx.i[2] += v;
+
                                 if (xx.i[2] < v) {
                                         if (++xx.i[1] == 0)
                                                 ++xx.i[0];
                                 }
                         }
+
                         xx.i[2] &= ~(v - 1);
                 } else if (xx.i[3] & 0x80000000) {
                                 if (++xx.i[2] == 0) {
                                         if (++xx.i[1] == 0)
                                                 ++xx.i[0];
                                 }
                 }
+
                 xx.i[3] = 0;
         } else {                                /* 1 <= j <= 31 */
                 v = 1U << (j - 1);
+
                 if (xx.i[3] & v) {
                         xx.i[3] += v;
+
                         if (xx.i[3] < v) {
                                 if (++xx.i[2] == 0) {
                                         if (++xx.i[1] == 0)
                                                 ++xx.i[0];
                                 }
                         }
                 }
+
                 xx.i[3] &= ~(v - 1);
         }
 
         /* negate result if need be */
         if (sx)
                 xx.i[0] |= 0x80000000;
+
         return (xx.q);
 }
 #elif defined(__x86)
 long double
-roundl(long double x) {
+roundl(long double x)
+{
         union {
                 unsigned i[3];
                 long double e;
         } xx;
+
         int ex, sx, i;
 
         xx.e = x;
         ex = xx.i[2] & 0x7fff;
         sx = xx.i[2] & 0x8000;
+
         if (ex < 0x403e) {      /* |x| < 2^63 */
                 if (ex < 0x3fff) {      /* |x| < 1 */
                         if (ex >= 0x3ffe)
                                 return (sx ? -1.0L : 1.0L);
+
                         return (sx ? -0.0L : 0.0L);
                 }
 
                 /* round x at the integer bit */
                 if (ex < 0x401e) {

@@ -143,22 +168,27 @@
                         xx.i[1] = (xx.i[1] + i) & ~(i | (i - 1));
                         xx.i[0] = 0;
                 } else {
                         i = 1 << (0x403d - ex);
                         xx.i[0] += i;
+
                         if (xx.i[0] < i)
                                 xx.i[1]++;
+
                         xx.i[0] &= ~(i | (i - 1));
                 }
+
                 if (xx.i[1] == 0) {
                         xx.i[2] = sx | ++ex;
                         xx.i[1] = 0x80000000U;
                 }
+
                 return (xx.e);
-        } else if (ex < 0x7fff) /* x is integral */
+        } else if (ex < 0x7fff) {       /* x is integral */
                 return (x);
-        else                    /* inf or nan */
+        } else {                        /* inf or nan */
                 return (x + x);
+        }
 }
 #else
 #error Unknown architecture
 #endif  /* defined(__sparc) || defined(__x86) */