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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/scalbln.c
          +++ new/usr/src/lib/libm/common/m9x/scalbln.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 __scalbln = scalbln
  31   32  
  32   33  #include "libm.h"
  33      -#include <float.h>              /* DBL_MAX, DBL_MIN */
       34 +#include <float.h>                      /* DBL_MAX, DBL_MIN */
  34   35  
  35   36  static const double twom54 = 5.5511151231257827021181583404541015625e-17;
       37 +
  36   38  #if defined(__x86)
  37   39  static const double two52 = 4503599627370496.0;
  38   40  #else
  39   41  /*
  40   42   * Normalize non-zero subnormal x and return biased exponent of x in [-51,0]
  41   43   */
  42   44  static int
  43      -ilogb_biased(unsigned *px) {
       45 +ilogb_biased(unsigned *px)
       46 +{
  44   47          int s = 52;
  45   48          unsigned v = px[HIWORD] & ~0x80000000, w = px[LOWORD], t = v;
  46   49  
  47   50          if (t)
  48   51                  s -= 32;
  49   52          else
  50   53                  t = w;
       54 +
  51   55          if (t & 0xffff0000)
  52   56                  s -= 16, t >>= 16;
       57 +
  53   58          if (t & 0xff00)
  54   59                  s -= 8, t >>= 8;
       60 +
  55   61          if (t & 0xf0)
  56   62                  s -= 4, t >>= 4;
       63 +
  57   64          t <<= 1;
  58   65          s -= (0xffffaa50 >> t) & 0x3;
       66 +
  59   67          if (s < 32) {
  60   68                  v = (v << s) | w >> (32 - s);
  61   69                  w <<= s;
  62   70          } else {
  63   71                  v = w << (s - 32);
  64   72                  w = 0;
  65   73          }
       74 +
  66   75          px[HIWORD] = (px[HIWORD] & 0x80000000) | v;
  67   76          px[LOWORD] = w;
  68   77          return (1 - s);
  69   78  }
  70      -#endif  /* defined(__x86) */
       79 +#endif /* defined(__x86) */
  71   80  
  72   81  double
  73      -scalbln(double x, long n) {
  74      -        int *px = (int *) &x, ix, k;
       82 +scalbln(double x, long n)
       83 +{
       84 +        int *px = (int *)&x, ix, k;
  75   85  
  76   86          ix = px[HIWORD] & ~0x80000000;
  77   87          k = ix >> 20;
       88 +
  78   89          if (k == 0x7ff)
  79   90  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  80   91                  return ((px[HIWORD] & 0x80000) != 0 ? x : x + x);
  81      -                /* assumes sparc-like QNaN */
       92 +
       93 +        /* assumes sparc-like QNaN */
  82   94  #else
  83   95                  return (x + x);
  84   96  #endif
       97 +
  85   98          if ((px[LOWORD] | ix) == 0 || n == 0)
  86   99                  return (x);
      100 +
  87  101          if (k == 0) {
  88  102  #if defined(__x86)
  89  103                  x *= two52;
  90  104                  k = ((px[HIWORD] & ~0x80000000) >> 20) - 52;
  91  105  #else
  92      -                k = ilogb_biased((unsigned *) px);
      106 +                k = ilogb_biased((unsigned *)px);
  93  107  #endif
  94  108          }
  95      -        k += (int) n;
      109 +
      110 +        k += (int)n;
      111 +
  96  112          if (n > 5000 || k > 0x7fe)
  97  113                  return (DBL_MAX * copysign(DBL_MAX, x));
      114 +
  98  115          if (n < -5000 || k <= -54)
  99  116                  return (DBL_MIN * copysign(DBL_MIN, x));
      117 +
 100  118          if (k > 0) {
 101  119                  px[HIWORD] = (px[HIWORD] & ~0x7ff00000) | (k << 20);
 102  120                  return (x);
 103  121          }
      122 +
 104  123          k += 54;
 105  124          px[HIWORD] = (px[HIWORD] & ~0x7ff00000) | (k << 20);
 106  125          return (x * twom54);
 107  126  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX