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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/truncl.c
          +++ new/usr/src/lib/libm/common/m9x/truncl.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 __truncl = truncl
  31   32  
  32   33  #include "libm.h"
  33   34  
  34   35  #if defined(__sparc)
  35   36  long double
  36      -truncl(long double x) {
       37 +truncl(long double x)
       38 +{
  37   39          union {
  38   40                  unsigned i[4];
  39   41                  long double q;
  40   42          } xx;
       43 +
  41   44          unsigned hx, sx;
  42   45          int j;
  43   46  
  44   47          xx.q = x;
  45   48          sx = xx.i[0] & 0x80000000;
  46   49          hx = xx.i[0] & ~0x80000000;
  47   50  
  48   51          /* handle trivial cases */
  49      -        if (hx >= 0x406f0000) /* |x| >= 2^112 + ... or x is nan */
       52 +        if (hx >= 0x406f0000)           /* |x| >= 2^112 + ... or x is nan */
  50   53                  return (hx >= 0x7fff0000 ? x + x : x);
  51   54  
  52   55          /* handle |x| < 1 */
  53   56          if (hx < 0x3fff0000)
  54   57                  return (sx ? -0.0L : 0.0L);
  55   58  
  56      -        j = 0x406f - (hx >> 16);                /* 1 <= j <= 112 */
       59 +        j = 0x406f - (hx >> 16);        /* 1 <= j <= 112 */
  57   60          xx.i[0] = hx;
  58      -        if (j >= 96) {                          /* 96 <= j <= 112 */
       61 +
       62 +        if (j >= 96) {                  /* 96 <= j <= 112 */
  59   63                  xx.i[0] &= ~((1 << (j - 96)) - 1);
  60   64                  xx.i[1] = xx.i[2] = xx.i[3] = 0;
  61      -        } else if (j >= 64) {                   /* 64 <= j <= 95 */
       65 +        } else if (j >= 64) {           /* 64 <= j <= 95 */
  62   66                  xx.i[1] &= ~((1 << (j - 64)) - 1);
  63   67                  xx.i[2] = xx.i[3] = 0;
  64      -        } else if (j >= 32) {                   /* 32 <= j <= 63 */
       68 +        } else if (j >= 32) {           /* 32 <= j <= 63 */
  65   69                  xx.i[2] &= ~((1 << (j - 32)) - 1);
  66   70                  xx.i[3] = 0;
  67      -        } else                                  /* 1 <= j <= 31 */
       71 +        } else {                        /* 1 <= j <= 31 */
  68   72                  xx.i[3] &= ~((1 << j) - 1);
       73 +        }
  69   74  
  70   75          /* negate result if need be */
  71   76          if (sx)
  72   77                  xx.i[0] |= 0x80000000;
       78 +
  73   79          return (xx.q);
  74   80  }
  75   81  #elif defined(__x86)
  76   82  long double
  77      -truncl(long double x) {
       83 +truncl(long double x)
       84 +{
  78   85          union {
  79   86                  unsigned i[3];
  80   87                  long double e;
  81   88          } xx;
       89 +
  82   90          int ex, sx, i;
  83   91  
  84   92          xx.e = x;
  85   93          ex = xx.i[2] & 0x7fff;
  86   94          sx = xx.i[2] & 0x8000;
  87      -        if (ex < 0x403e) {      /* |x| < 2^63 */
       95 +
       96 +        if (ex < 0x403e) {              /* |x| < 2^63 */
  88   97                  if (ex < 0x3fff)        /* |x| < 1 */
  89   98                          return (sx ? -0.0L : 0.0L);
  90   99  
  91  100                  /* chop x at the integer bit */
  92  101                  if (ex < 0x401e) {
  93  102                          i = 1 << (0x401d - ex);
  94  103                          xx.i[1] &= ~(i | (i - 1));
  95  104                          xx.i[0] = 0;
  96  105                  } else {
  97  106                          i = 1 << (0x403d - ex);
  98  107                          xx.i[0] &= ~(i | (i - 1));
  99  108                  }
      109 +
 100  110                  return (xx.e);
 101      -        } else if (ex < 0x7fff) /* x is integral */
      111 +        } else if (ex < 0x7fff) {       /* x is integral */
 102  112                  return (x);
 103      -        else                    /* inf or nan */
      113 +        } else {                        /* inf or nan */
 104  114                  return (x + x);
      115 +        }
 105  116  }
 106  117  #else
 107  118  #error Unknown architecture
 108      -#endif  /* defined(__sparc) || defined(__x86) */
      119 +#endif /* defined(__sparc) || defined(__x86) */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX