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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/R/expf.c
          +++ new/usr/src/lib/libm/common/R/expf.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  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   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
       25 +
  24   26  /*
  25   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  #pragma weak __expf = expf
  30   32  
  31      -/* INDENT OFF */
       33 +
  32   34  /*
  33   35   * float expf(float x);
  34   36   * Code by K.C. Ng for SUN 5.0 libmopt
  35   37   * 11/5/99
  36   38   * Method :
  37   39   *      1. For |x| >= 2^7, either underflow/overflow.
  38   40   *         More precisely:
  39   41   *              x > 88.722839355...(0x42B17218) => overflow;
  40   42   *              x < -103.97207642..(0xc2CFF1B4) => underflow.
  41   43   *      2. For |x| <  2^-6, use polynomail
↓ open down ↓ 51 lines elided ↑ open up ↑
  93   95   *      for finite argument, only exp(0) = 1 is exact.
  94   96   *
  95   97   * Accuracy:
  96   98   *      All calculations are done in double precision except for
  97   99   *      the case |x| < 2^-6.  When |x| < 2^-6, the error is less
  98  100   *      than 0.55 ulp.  When |x| >= 2^-6 and the result is normal,
  99  101   *      the error is less than 0.51 ulp.  When FDTOS_TRAPS_... is
 100  102   *      defined and the result is subnormal, the error can be as
 101  103   *      large as 0.75 ulp.
 102  104   */
 103      -/* INDENT ON */
 104  105  
 105  106  #include "libm.h"
 106  107  
 107  108  /*
 108  109   * ET[k] = exp(j*2^(7-6i)) , where j = k mod 64, i = k/64
 109  110   */
 110  111  static const double ET[] = {
 111  112          1.00000000000000000000e+00, 1.00000000186264514923e+00,
 112  113          1.00000000372529029846e+00, 1.00000000558793544769e+00,
 113  114          1.00000000745058059692e+00, 1.00000000931322574615e+00,
↓ open down ↓ 210 lines elided ↑ open up ↑
 324  325          1.0f,
 325  326          5.0000000951292138e-01F,
 326  327          1.6666518897347284e-01F,
 327  328          3.4028234663852885981170E+38F,
 328  329          1.1754943508222875079688E-38F,
 329  330  #if defined(FDTOS_TRAPS_INCOMPLETE_IN_FNS_MODE)
 330  331          8.67361737988403547205962240695953369140625e-19F
 331  332  #endif
 332  333  };
 333  334  
 334      -#define zero    F[0]
 335      -#define one     F[1]
 336      -#define p1      F[2]
 337      -#define p2      F[3]
 338      -#define big     F[4]
 339      -#define tiny    F[5]
      335 +#define zero            F[0]
      336 +#define one             F[1]
      337 +#define p1              F[2]
      338 +#define p2              F[3]
      339 +#define big             F[4]
      340 +#define tiny            F[5]
 340  341  #if defined(FDTOS_TRAPS_INCOMPLETE_IN_FNS_MODE)
 341      -#define twom60  F[6]
      342 +#define twom60          F[6]
 342  343  #endif
 343  344  
 344  345  float
 345      -expf(float xf) {
 346      -        double  w, p, q;
 347      -        int     hx, ix, n;
      346 +expf(float xf)
      347 +{
      348 +        double w, p, q;
      349 +        int hx, ix, n;
 348  350  
 349  351          hx = *(int *)&xf;
 350  352          ix = hx & ~0x80000000;
 351  353  
 352      -        if (ix < 0x3c800000) {  /* |x| < 2**-6 */
      354 +        if (ix < 0x3c800000) {          /* |x| < 2**-6 */
 353  355                  if (ix < 0x38800000)    /* |x| < 2**-14 */
 354  356                          return (one + xf);
      357 +
 355  358                  return (one + (xf + (xf * xf) * (p1 + xf * p2)));
 356  359          }
 357  360  
 358      -        n = ix >> 23;           /* biased exponent */
      361 +        n = ix >> 23;                           /* biased exponent */
 359  362  
 360      -        if (n >= 0x86) {        /* |x| >= 2^7 */
 361      -                if (n >= 0xff) {        /* x is nan of +-inf */
      363 +        if (n >= 0x86) {                        /* |x| >= 2^7 */
      364 +                if (n >= 0xff) {                /* x is nan of +-inf */
 362  365                          if (hx == 0xff800000)
 363  366                                  return (zero);  /* exp(-inf)=0 */
      367 +
 364  368                          return (xf * xf);       /* exp(nan/inf) is nan or inf */
 365  369                  }
      370 +
 366  371                  if (hx > 0)
 367  372                          return (big * big);     /* overflow */
 368  373                  else
 369  374                          return (tiny * tiny);   /* underflow */
 370  375          }
 371  376  
 372  377          ix -= n << 23;
      378 +
 373  379          if (hx > 0)
 374  380                  ix += 0x800000;
 375  381          else
 376  382                  ix = 0x800000 - ix;
 377      -        if (n >= 0x7f) {        /* n >= 0 */
      383 +
      384 +        if (n >= 0x7f) {                /* n >= 0 */
 378  385                  ix <<= n - 0x7f;
 379  386                  w = ET[(ix & 0x3f) + 64] * ET[((ix >> 6) & 0x3f) + 128];
 380      -                p = ET[((ix >> 12) & 0x3f) + 192] *
 381      -                    ET[((ix >> 18) & 0x3f) + 256];
      387 +                p = ET[((ix >> 12) & 0x3f) + 192] * ET[((ix >> 18) & 0x3f) +
      388 +                    256];
 382  389                  q = ET[((ix >> 24) & 0x3f) + 320];
 383  390          } else {
 384  391                  ix <<= n - 0x79;
 385  392                  w = ET[ix & 0x3f] * ET[((ix >> 6) & 0x3f) + 64];
 386      -                p = ET[((ix >> 12) & 0x3f) + 128] *
 387      -                    ET[((ix >> 18) & 0x3f) + 192];
      393 +                p = ET[((ix >> 12) & 0x3f) + 128] * ET[((ix >> 18) & 0x3f) +
      394 +                    192];
 388  395                  q = ET[((ix >> 24) & 0x3f) + 256];
 389  396          }
      397 +
 390  398          xf = (float)((w * p) * (hx < 0 ? q * EN[n - 0x79] : q));
 391  399  #if defined(FDTOS_TRAPS_INCOMPLETE_IN_FNS_MODE)
 392  400          if ((unsigned)hx >= 0xc2800000u) {
 393      -                if ((unsigned)hx >= 0xc2aeac50) { /* force underflow */
 394      -                        volatile float  t = tiny;
      401 +                if ((unsigned)hx >= 0xc2aeac50) {       /* force underflow */
      402 +                        volatile float t = tiny;
      403 +
 395  404                          t *= t;
 396  405                  }
      406 +
 397  407                  return (xf * twom60);
 398  408          }
 399  409  #endif
 400  410          return (xf);
 401  411  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX