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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/tanh.c
          +++ new/usr/src/lib/libm/common/C/tanh.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 __tanh = tanh
  31   32  
  32      -/* INDENT OFF */
       33 +
  33   34  /*
  34   35   * TANH(X)
  35   36   * RETURN THE HYPERBOLIC TANGENT OF X
  36   37   * code based on 4.3bsd
  37   38   * Modified by K.C. Ng for sun 4.0, Jan 31, 1987
  38   39   *
  39   40   * Method :
  40   41   *      1. reduce x to non-negative by tanh(-x) = - tanh(x).
  41   42   *      2.
  42   43   *          0      <  x <=  1.e-10 :  tanh(x) := x
↓ open down ↓ 9 lines elided ↑ open up ↑
  52   53   *
  53   54   * Special cases:
  54   55   *      tanh(NaN) is NaN;
  55   56   *      only tanh(0)=0 is exact for finite argument.
  56   57   */
  57   58  
  58   59  #include "libm.h"
  59   60  #include "libm_protos.h"
  60   61  #include <math.h>
  61   62  
  62      -static const double
  63      -        one = 1.0,
  64      -        two = 2.0,
  65      -        small = 1.0e-10,
  66      -        big = 1.0e10;
  67      -/* INDENT ON */
       63 +static const double one = 1.0, two = 2.0, small = 1.0e-10, big = 1.0e10;
       64 +
  68   65  
  69   66  double
  70   67  tanh(double x)
  71   68  {
  72   69          double t, y, z;
  73   70          int signx;
  74   71          volatile double dummy __unused;
  75   72  
  76   73          if (isnan(x))
  77      -                return (x * x); /* + -> * for Cheetah */
       74 +                return (x * x);         /* + -> * for Cheetah */
       75 +
  78   76          signx = signbit(x);
  79   77          t = fabs(x);
  80   78          z = one;
       79 +
  81   80          if (t <= 22.0) {
  82      -                if (t > one)
       81 +                if (t > one) {
  83   82                          z = one - two / (expm1(t + t) + two);
  84      -                else if (t > small) {
       83 +                } else if (t > small) {
  85   84                          y = expm1(-t - t);
  86   85                          z = -y / (y + two);
  87   86                  } else {
  88   87                          /* raise the INEXACT flag for non-zero t */
  89   88                          dummy = t + big;
  90   89  #ifdef lint
  91   90                          dummy = dummy;
  92   91  #endif
  93   92                          return (x);
  94   93                  }
  95      -        } else if (!finite(t))
       94 +        } else if (!finite(t)) {
  96   95                  return (copysign(1.0, x));
  97      -        else
       96 +        } else {
  98   97                  return ((signx != 0) ? -z + small * small : z - small * small);
       98 +        }
  99   99  
 100  100          return ((signx != 0) ? -z : z);
 101  101  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX