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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/frexp.c
          +++ new/usr/src/lib/libm/common/m9x/frexp.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 frexp = __frexp
  31   32  
  32   33  /*
  33   34   * frexp(x, exp) returns the normalized significand of x and sets
  34   35   * *exp so that x = r*2^(*exp) where r is the return value.  If x
↓ open down ↓ 4 lines elided ↑ open up ↑
  39   40   * NaN, but this code sets it anyway.)
  40   41   *
  41   42   * If x is a signaling NaN, this code returns x without attempting
  42   43   * to raise the invalid operation exception.  If x is subnormal,
  43   44   * this code treats it as nonzero regardless of nonstandard mode.
  44   45   */
  45   46  
  46   47  #include "libm.h"
  47   48  
  48   49  double
  49      -__frexp(double x, int *exp) {
       50 +__frexp(double x, int *exp)
       51 +{
  50   52          union {
  51   53                  unsigned i[2];
  52   54                  double d;
  53   55          } xx, yy;
       56 +
  54   57          double t;
  55   58          unsigned hx;
  56   59          int e;
  57   60  
  58   61          xx.d = x;
  59   62          hx = xx.i[HIWORD] & ~0x80000000;
  60   63  
  61      -        if (hx >= 0x7ff00000) { /* x is infinite or NaN */
       64 +        if (hx >= 0x7ff00000) {         /* x is infinite or NaN */
  62   65                  *exp = 0;
  63   66                  return (x);
  64   67          }
  65   68  
  66   69          e = 0;
  67      -        if (hx < 0x00100000) { /* x is subnormal or zero */
       70 +
       71 +        if (hx < 0x00100000) {          /* x is subnormal or zero */
  68   72                  if ((hx | xx.i[LOWORD]) == 0) {
  69   73                          *exp = 0;
  70   74                          return (x);
  71   75                  }
  72   76  
  73   77                  /*
  74   78                   * normalize x by regarding it as an integer
  75   79                   *
  76   80                   * Here we use 32-bit integer arithmetic to avoid trapping
  77   81                   * or emulating 64-bit arithmetic.  If 64-bit arithmetic is
↓ open down ↓ 3 lines elided ↑ open up ↑
  81   85                   *  xx.d = (xx.i[HIWORD] < 0)? -lx : lx;
  82   86                   *
  83   87                   * If subnormal arithmetic doesn't trap, just multiply x by
  84   88                   * a power of two.
  85   89                   */
  86   90                  yy.i[HIWORD] = 0x43300000 | hx;
  87   91                  yy.i[LOWORD] = xx.i[LOWORD];
  88   92                  t = yy.d;
  89   93                  yy.i[HIWORD] = 0x43300000;
  90   94                  yy.i[LOWORD] = 0;
  91      -                t -= yy.d; /* t = |x| scaled */
  92      -                xx.d = ((int)xx.i[HIWORD] < 0)? -t : t;
       95 +                t -= yy.d;              /* t = |x| scaled */
       96 +                xx.d = ((int)xx.i[HIWORD] < 0) ? -t : t;
  93   97                  hx = xx.i[HIWORD] & ~0x80000000;
  94   98                  e = -1074;
  95   99          }
  96  100  
  97  101          /* now xx.d is normal */
  98  102          xx.i[HIWORD] = (xx.i[HIWORD] & ~0x7ff00000) | 0x3fe00000;
  99  103          *exp = e + (hx >> 20) - 0x3fe;
 100  104          return (xx.d);
 101  105  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX