Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/scalbn.c
          +++ new/usr/src/lib/libm/common/C/scalbn.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23   23   */
  24   24  /*
  25   25   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  26   26   * Use is subject to license terms.
  27   27   */
  28   28  
  29      -#pragma weak scalbn = __scalbn
       29 +#pragma weak __scalbn = scalbn
  30   30  
  31   31  #include "libm.h"
  32   32  
  33   33  static const double
  34   34          one     = 1.0,
  35   35          huge    = 1.0e300,
  36   36          tiny    = 1.0e-300,
  37   37          twom54  = 5.5511151231257827021181583404541015625e-17;
  38   38  
  39      -#if defined(USE_FPSCALE) || defined(__x86)
       39 +#if defined(__x86)
  40   40  static const double two52 = 4503599627370496.0;
  41   41  #else
  42   42  /*
  43   43   * Normalize non-zero subnormal x and return biased exponent of x in [-51,0]
  44   44   */
  45   45  static int
  46   46  ilogb_biased(unsigned *px) {
  47   47          int s = 52;
  48   48          unsigned v = px[HIWORD] & ~0x80000000, w = px[LOWORD], t = v;
  49   49  
↓ open down ↓ 13 lines elided ↑ open up ↑
  63   63                  v = (v << s) | w >> (32 - s);
  64   64                  w <<= s;
  65   65          } else {
  66   66                  v = w << (s - 32);
  67   67                  w = 0;
  68   68          }
  69   69          px[HIWORD] = (px[HIWORD] & 0x80000000) | v;
  70   70          px[LOWORD] = w;
  71   71          return (1 - s);
  72   72  }
  73      -#endif  /* defined(USE_FPSCALE) */
       73 +#endif  /* defined(__x86) */
  74   74  
  75   75  double
  76   76  scalbn(double x, int n) {
  77   77          int     *px, ix, hx, k;
  78   78  
  79   79          px = (int *)&x;
  80   80          ix = px[HIWORD];
  81   81          hx = ix & ~0x80000000;
  82   82          k = hx >> 20;
  83   83  
  84   84          if (k == 0x7ff) /* x is inf or NaN */
  85   85                  return (x * one);
  86   86  
  87   87          if (k == 0) {
  88   88                  if ((hx | px[LOWORD]) == 0 || n == 0)
  89   89                          return (x);
  90      -#if defined(USE_FPSCALE) || defined(__x86)
       90 +#if defined(__x86)
  91   91                  x *= two52;
  92   92                  ix = px[HIWORD];
  93   93                  k = ((ix & ~0x80000000) >> 20) - 52;
  94   94  #else
  95   95                  k = ilogb_biased((unsigned *)px);
  96   96                  ix = px[HIWORD];
  97   97  #endif
  98   98                  /* now k is in the range -51..0 */
  99   99                  k += n;
 100  100                  if (k > n)      /* integer overflow occurred */
↓ open down ↓ 20 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX