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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/asinh.c
          +++ new/usr/src/lib/libm/common/C/asinh.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 __asinh = asinh
  31   32  
  32      -/* INDENT OFF */
       33 +
  33   34  /*
  34   35   * asinh(x)
  35   36   * Method :
  36   37   *      Based on
  37   38   *              asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
  38   39   *      we have
  39   40   *      asinh(x) := x  if  1+x*x == 1,
  40   41   *               := sign(x)*(log(x)+ln2)) for large |x|, else
  41   42   *               := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x| > 2, else
  42   43   *               := sign(x)*log1p(|x|+x^2/(1+sqrt(1+x^2)))
  43   44   */
  44      -/* INDENT ON */
  45   45  
  46   46  #include "libm_macros.h"
  47   47  #include <math.h>
  48   48  
  49   49  static const double xxx[] = {
  50      -/* one */       1.00000000000000000000e+00,     /* 3FF00000, 00000000 */
  51      -/* ln2 */       6.93147180559945286227e-01,     /* 3FE62E42, FEFA39EF */
  52      -/* huge */      1.00000000000000000000e+300
       50 +/* one */
       51 +        1.00000000000000000000e+00,     /* 3FF00000, 00000000 */
       52 +/* ln2 */ 6.93147180559945286227e-01,   /* 3FE62E42, FEFA39EF */
       53 +/* huge */ 1.00000000000000000000e+300
  53   54  };
  54      -#define one     xxx[0]
  55      -#define ln2     xxx[1]
  56      -#define huge    xxx[2]
       55 +
       56 +#define one             xxx[0]
       57 +#define ln2             xxx[1]
       58 +#define huge            xxx[2]
  57   59  
  58   60  double
  59      -asinh(double x) {
       61 +asinh(double x)
       62 +{
  60   63          double t, w;
  61   64          int hx, ix;
  62   65  
  63      -        hx = ((int *) &x)[HIWORD];
       66 +        hx = ((int *)&x)[HIWORD];
  64   67          ix = hx & 0x7fffffff;
       68 +
  65   69          if (ix >= 0x7ff00000)
  66   70  #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
  67   71                  return (ix >= 0x7ff80000 ? x : x + x);
  68      -                /* assumes sparc-like QNaN */
       72 +
       73 +        /* assumes sparc-like QNaN */
  69   74  #else
  70      -                return (x + x); /* x is inf or NaN */
       75 +                return (x + x);         /* x is inf or NaN */
  71   76  #endif
  72      -        if (ix < 0x3e300000) {  /* |x|<2**-28 */
       77 +
       78 +        if (ix < 0x3e300000) {          /* |x|<2**-28 */
  73   79                  if (huge + x > one)
  74   80                          return (x);     /* return x inexact except 0 */
  75   81          }
  76      -        if (ix > 0x41b00000) {  /* |x| > 2**28 */
       82 +
       83 +        if (ix > 0x41b00000) {          /* |x| > 2**28 */
  77   84                  w = log(fabs(x)) + ln2;
  78   85          } else if (ix > 0x40000000) {
  79   86                  /* 2**28 > |x| > 2.0 */
  80   87                  t = fabs(x);
  81   88                  w = log(2.0 * t + one / (sqrt(x * x + one) + t));
  82   89          } else {
  83   90                  /* 2.0 > |x| > 2**-28 */
  84   91                  t = x * x;
  85   92                  w = log1p(fabs(x) + t / (one + sqrt(one + t)));
  86   93          }
       94 +
  87   95          return (hx > 0 ? w : -w);
  88   96  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX