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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/round.c
          +++ new/usr/src/lib/libm/common/m9x/round.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
       25 +
  25   26  /*
  26   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  #pragma weak __round = round
  31   32  
  32   33  #include "libm.h"
  33   34  
  34   35  double
  35      -round(double x) {
       36 +round(double x)
       37 +{
  36   38          union {
  37   39                  unsigned i[2];
  38   40                  double d;
  39   41          } xx;
       42 +
  40   43          unsigned hx, sx, i;
  41   44  
  42   45          xx.d = x;
  43   46          hx = xx.i[HIWORD] & ~0x80000000;
  44   47          sx = xx.i[HIWORD] & 0x80000000;
  45      -        if (hx < 0x43300000) {  /* |x| < 2^52 */
       48 +
       49 +        if (hx < 0x43300000) {          /* |x| < 2^52 */
  46   50                  if (hx < 0x3ff00000) {  /* |x| < 1 */
  47   51                          if (hx >= 0x3fe00000)
  48   52                                  return (sx ? -1.0 : 1.0);
       53 +
  49   54                          return (sx ? -0.0 : 0.0);
  50   55                  }
  51   56  
  52   57                  /* round x at the integer bit */
  53   58                  if (hx < 0x41300000) {
  54   59                          i = 1 << (0x412 - (hx >> 20));
  55   60                          xx.i[HIWORD] = (xx.i[HIWORD] + i) & ~(i | (i - 1));
  56   61                          xx.i[LOWORD] = 0;
  57   62                  } else {
  58   63                          i = 1 << (0x432 - (hx >> 20));
  59   64                          xx.i[LOWORD] += i;
       65 +
  60   66                          if (xx.i[LOWORD] < i)
  61   67                                  xx.i[HIWORD]++;
       68 +
  62   69                          xx.i[LOWORD] &= ~(i | (i - 1));
  63   70                  }
       71 +
  64   72                  return (xx.d);
  65      -        } else if (hx < 0x7ff00000)
       73 +        } else if (hx < 0x7ff00000) {
  66   74                  return (x);
  67      -        else
       75 +        } else {
  68   76  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  69   77                  return (hx >= 0x7ff80000 ? x : x + x);
  70      -                /* assumes sparc-like QNaN */
       78 +
       79 +        /* assumes sparc-like QNaN */
  71   80  #else
  72   81                  return (x + x);
  73   82  #endif
       83 +        }
  74   84  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX