Print this page
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local

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 ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  /*
  26   26   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   27   * Use is subject to license terms.
  28   28   */
  29   29  
  30      -#if defined(ELFOBJ)
  31   30  #pragma weak scalbln = __scalbln
  32      -#endif
  33   31  
  34   32  #include "libm.h"
  35   33  #include <float.h>              /* DBL_MAX, DBL_MIN */
  36   34  
  37   35  static const double twom54 = 5.5511151231257827021181583404541015625e-17;
  38      -#if defined(USE_FPSCALE) || defined(__x86)
       36 +#if defined(__x86)
  39   37  static const double two52 = 4503599627370496.0;
  40   38  #else
  41   39  /*
  42   40   * Normalize non-zero subnormal x and return biased exponent of x in [-51,0]
  43   41   */
  44   42  static int
  45   43  ilogb_biased(unsigned *px) {
  46   44          int s = 52;
  47   45          unsigned v = px[HIWORD] & ~0x80000000, w = px[LOWORD], t = v;
  48   46  
↓ open down ↓ 13 lines elided ↑ open up ↑
  62   60                  v = (v << s) | w >> (32 - s);
  63   61                  w <<= s;
  64   62          } else {
  65   63                  v = w << (s - 32);
  66   64                  w = 0;
  67   65          }
  68   66          px[HIWORD] = (px[HIWORD] & 0x80000000) | v;
  69   67          px[LOWORD] = w;
  70   68          return (1 - s);
  71   69  }
  72      -#endif  /* defined(USE_FPSCALE) */
       70 +#endif  /* defined(__x86) */
  73   71  
  74   72  double
  75   73  scalbln(double x, long n) {
  76   74          int *px = (int *) &x, ix, k;
  77   75  
  78   76          ix = px[HIWORD] & ~0x80000000;
  79   77          k = ix >> 20;
  80   78          if (k == 0x7ff)
  81   79  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  82   80                  return ((px[HIWORD] & 0x80000) != 0 ? x : x + x);
  83   81                  /* assumes sparc-like QNaN */
  84   82  #else
  85   83                  return (x + x);
  86   84  #endif
  87   85          if ((px[LOWORD] | ix) == 0 || n == 0)
  88   86                  return (x);
  89   87          if (k == 0) {
  90      -#if defined(USE_FPSCALE) || defined(__x86)
       88 +#if defined(__x86)
  91   89                  x *= two52;
  92   90                  k = ((px[HIWORD] & ~0x80000000) >> 20) - 52;
  93   91  #else
  94   92                  k = ilogb_biased((unsigned *) px);
  95   93  #endif
  96   94          }
  97   95          k += (int) n;
  98   96          if (n > 5000 || k > 0x7fe)
  99   97                  return (DBL_MAX * copysign(DBL_MAX, x));
 100   98          if (n < -5000 || k <= -54)
 101   99                  return (DBL_MIN * copysign(DBL_MIN, x));
 102  100          if (k > 0) {
 103  101                  px[HIWORD] = (px[HIWORD] & ~0x7ff00000) | (k << 20);
 104  102                  return (x);
 105  103          }
 106  104          k += 54;
 107  105          px[HIWORD] = (px[HIWORD] & ~0x7ff00000) | (k << 20);
 108  106          return (x * twom54);
 109  107  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX