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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/tanhl.c
          +++ new/usr/src/lib/libm/common/Q/tanhl.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 __tanhl = tanhl
  31   32  
  32   33  /*
  33   34   * tanhl(x) returns the hyperbolic tangent of x
  34   35   *
↓ open down ↓ 3 lines elided ↑ open up ↑
  38   39   *        0      <  x <=  small    :  tanhl(x) := x
  39   40   *                                                -expm1l(-2x)
  40   41   *        small  <  x <=  1        :  tanhl(x) := --------------
  41   42   *                                               expm1l(-2x) + 2
  42   43   *                                                        2
  43   44   *        1      <= x <= threshold :  tanhl(x) := 1 -  ---------------
  44   45   *                                                    expm1l(2x) + 2
  45   46   *     threshold <  x <= INF       :  tanhl(x) := 1.
  46   47   *
  47   48   * where
  48      - *      single :        small = 1.e-5           threshold = 11.0
  49      - *      double :        small = 1.e-10          threshold = 22.0
  50      - *      quad   :        small = 1.e-20          threshold = 45.0
       49 + *      single :        small = 1.e-5           threshold = 11.0
       50 + *      double :        small = 1.e-10          threshold = 22.0
       51 + *      quad   :        small = 1.e-20          threshold = 45.0
  51   52   *
  52   53   * Note: threshold was chosen so that
  53   54   *              fl(1.0+2/(expm1(2*threshold)+2)) == 1.
  54   55   *
  55   56   * Special cases:
  56   57   *      tanhl(NaN) is NaN;
  57   58   *      only tanhl(0.0)=0.0 is exact for finite argument.
  58   59   */
  59   60  
  60   61  #include "libm.h"
  61   62  #include "longdouble.h"
  62   63  
  63      -static const long double small = 1.0e-20L, one = 1.0, two = 2.0,
       64 +static const long double small = 1.0e-20L,
       65 +        one = 1.0,
       66 +        two = 2.0,
  64   67  #ifndef lint
  65   68          big = 1.0e+20L,
  66   69  #endif
  67   70          threshold = 45.0L;
  68   71  
  69   72  long double
  70      -tanhl(long double x) {
       73 +tanhl(long double x)
       74 +{
  71   75          long double t, y, z;
  72   76          int signx;
       77 +
  73   78  #ifndef lint
  74   79          volatile long double dummy;
  75   80  #endif
  76   81  
  77   82          if (isnanl(x))
  78   83                  return (x + x);         /* x is NaN */
       84 +
  79   85          signx = signbitl(x);
  80   86          t = fabsl(x);
  81   87          z = one;
       88 +
  82   89          if (t <= threshold) {
  83      -                if (t > one)
       90 +                if (t > one) {
  84   91                          z = one - two / (expm1l(t + t) + two);
  85      -                else if (t > small) {
       92 +                } else if (t > small) {
  86   93                          y = expm1l(-t - t);
  87   94                          z = -y / (y + two);
  88   95                  } else {
  89   96  #ifndef lint
  90   97                          dummy = t + big;
  91      -                                                        /* inexact if t != 0 */
       98 +                        /* inexact if t != 0 */
  92   99  #endif
  93  100                          return (x);
  94  101                  }
  95      -        } else if (!finitel(t))
      102 +        } else if (!finitel(t)) {
  96  103                  return (copysignl(one, x));
  97      -        else
      104 +        } else {
  98  105                  return (signx ? -z + small * small : z - small * small);
      106 +        }
      107 +
  99  108          return (signx ? -z : z);
 100  109  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX