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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/trunc.c
          +++ new/usr/src/lib/libm/common/m9x/trunc.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 __trunc = trunc
  31   32  
  32   33  #include "libm.h"
  33   34  
  34   35  double
  35      -trunc(double x) {
       36 +trunc(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                          return (sx ? -0.0 : 0.0);
  48   52  
  49   53                  /* chop x at the integer bit */
  50   54                  if (hx < 0x41300000) {
  51   55                          i = 1 << (0x412 - (hx >> 20));
  52   56                          xx.i[HIWORD] &= ~(i | (i - 1));
  53   57                          xx.i[LOWORD] = 0;
  54   58                  } else {
  55   59                          i = 1 << (0x432 - (hx >> 20));
  56   60                          xx.i[LOWORD] &= ~(i | (i - 1));
  57   61                  }
       62 +
  58   63                  return (xx.d);
  59      -        } else if (hx < 0x7ff00000)
       64 +        } else if (hx < 0x7ff00000) {
  60   65                  return (x);
  61      -        else
       66 +        } else {
  62   67  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  63   68                  return (hx >= 0x7ff80000 ? x : x + x);
  64      -                /* assumes sparc-like QNaN */
       69 +
       70 +        /* assumes sparc-like QNaN */
  65   71  #else
  66   72                  return (x + x);
  67   73  #endif
       74 +        }
  68   75  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX