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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/rint.c
          +++ new/usr/src/lib/libm/common/C/rint.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
       25 +
  24   26  /*
  25   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  #pragma weak __rint = rint
  30   32  
  31   33  /*
  32   34   * rint(x) return x rounded to integral according to the rounding direction
  33   35   * rint(x) returns result with the same sign as x's,  including 0.0.
  34   36   */
  35   37  
  36   38  #include "libm.h"
  37   39  
  38   40  #if defined(__i386) && !defined(__amd64) && (!defined(__FLT_EVAL_METHOD__) || \
  39   41          __FLT_EVAL_METHOD__ != 0)
       42 +
  40   43  extern enum fp_precision_type __swapRP(enum fp_precision_type);
  41      -#define DECLRP(x)       enum fp_precision_type x;
  42      -#define SWAPRP(new, x)  x = __swapRP(new);
  43      -#define RESTRP(x)       (void) __swapRP(x);
       44 +
       45 +#define DECLRP(x)               enum fp_precision_type x;
       46 +#define SWAPRP(new, x)          x = __swapRP(new);
       47 +#define RESTRP(x)               (void) __swapRP(x);
  44   48  #else
  45   49  #define DECLRP(x)
  46   50  #define SWAPRP(new, x)
  47   51  #define RESTRP(x)
  48   52  #endif
  49   53  
  50      -static const double
  51      -        two52 = 4503599627370496.0,
  52      -        zero = 0.0,
  53      -        one = 1.0;
       54 +static const double two52 = 4503599627370496.0, zero = 0.0, one = 1.0;
  54   55  
  55   56  double
  56      -rint(double x) {
       57 +rint(double x)
       58 +{
  57   59          DECLRP(rp)
  58      -        double  t, w;
  59      -        int     ix, hx;
       60 +        double t, w;
       61 +        int ix, hx;
  60   62  
  61   63          ix = ((int *)&x)[HIWORD];
  62   64          hx = ix & ~0x80000000;
  63   65  
  64   66          if (hx >= 0x43300000)
  65   67                  return (x * one);
  66      -        t = (ix < 0)? -two52 : two52;
       68 +
       69 +        t = (ix < 0) ? -two52 : two52;
  67   70          SWAPRP(fp_double, rp)           /* set precision mode to double */
  68   71          w = x + t;                      /* x+sign(x)*2**52 rounded */
  69   72          RESTRP(rp)                      /* restore precision mode */
       73 +
  70   74          if (w == t)
  71      -                return ((ix < 0)? -zero : zero);
       75 +                return ((ix < 0) ? -zero : zero);
       76 +
  72   77          return (w - t);
  73   78  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX