```11210 libm should be cstyle(1ONBLD) clean
```

 Split Close Expand all Collapse all
```          --- old/usr/src/lib/libm/common/C/__tan.c
+++ new/usr/src/lib/libm/common/C/__tan.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
18   18   *
19   19   * CDDL HEADER END
20   20   */
21   21
22   22  /*
24   24   */
25 +
25   26  /*
27   28   * Use is subject to license terms.
28   29   */
29   30
30      -/* INDENT OFF */
31 +
31   32  /*
32   33   * __k_tan( double x;  double y; int k )
33   34   * kernel tan/cotan function on [-pi/4, pi/4], pi/4 ~ 0.785398164
34   35   * Input x is assumed to be bounded by ~pi/4 in magnitude.
35   36   * Input y is the tail of x.
36   37   * Input k indicate -- tan if k=0; else -1/tan
37   38   *
38   39   * Table look up algorithm
39   40   *      1. by tan(-x) = -tan(x), need only to consider positive x
40   41   *      2. if x < 5/32 = [0x3fc40000, 0] = 0.15625 , then
41   42   *           if x < 2^-27 (hx < 0x3e400000 0), set w=x with inexact if x !=  0
42   43   *           else
43   44   *              z = x*x;
44   45   *              w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6))))))
45   46   *         return (k == 0)? w: 1/w;
46   47   *      3. else
47   48   *              ht = (hx + 0x4000)&0x7fff8000   (round x to a break point t)
48   49   *              lt = 0
49   50   *              i  = (hy-0x3fc40000)>>15;       (i<=64)
50      - *              x' = (x - t)+y                  (|x'| ~<= 2^-7)
51 + *              x' = (x - t)+y                  (|x'| ~<= 2^-7)
51   52   *         By
52   53   *              tan(t+x')
53   54   *                = (tan(t)+tan(x'))/(1-tan(x')tan(t))
54   55   *         We have
55   56   *                           sin(x')+tan(t)*(tan(t)*sin(x'))
56   57   *                = tan(t) + -------------------------------    for k=0
57   58   *                              cos(x') - tan(t)*sin(x')
58   59   *
59   60   *                           cos(x') - tan(t)*sin(x')
60   61   *                = - --------------------------------------    for k=1
61   62   *                     tan(t) + tan(t)*(cos(x')-1) + sin(x')
62   63   *
63   64   *
64      - *         where        tan(t) is from the table,
65 + *         where        tan(t) is from the table,
65   66   *                      sin(x') = x + pp1*x^3 + pp2*x^5
66   67   *                      cos(x') = 1 + qq1*x^2 + qq2*x^4
67   68   */
68   69
69   70  #include "libm.h"
70   71
71   72  extern const double _TBL_tan_hi[], _TBL_tan_lo[];
73 +
72   74  static const double q[] = {
73      -/* one  = */  1.0,
75 +/* one  = */
76 +        1.0,
77 +
74   78  /*
75   79   *                       2       2       -59.56
76   80   * |sin(x) - pp1*x*(pp2+x *(pp3+x )| <= 2        for |x|<1/64
77   81   */
78      -/* pp1  = */  8.33326120969096230395312119298978359438478946686e-0003,
79      -/* pp2  = */  1.20001038589438965215025680596868692381425944526e+0002,
82 +/* pp1  = */ 8.33326120969096230395312119298978359438478946686e-0003,
83 +/* pp2  = */ 1.20001038589438965215025680596868692381425944526e+0002,
80   84  /* pp3  = */ -2.00001730975089451192161504877731204032897949219e+0001,
81   85
82   86  /*
83   87   *                   2      2        -56.19
84   88   * |cos(x) - (1+qq1*x (qq2+x ))| <= 2        for |x|<=1/128
85   89   */
86      -/* qq1  = */  4.16665486385721928197511942926212213933467864990e-0002,
90 +/* qq1  = */ 4.16665486385721928197511942926212213933467864990e-0002,
87   91  /* qq2  = */ -1.20000339921340035687080671777948737144470214844e+0001,
88   92
89   93  /*
90   94   * |tan(x) - PF(x)|
91   95   * |--------------| <= 2^-58.57 for |x|<0.15625
92   96   * |      x       |
93   97   *
94   98   * where (let z = x*x)
95   99   *      PF(x) = x + (t1*x*z)(t2 + z(t3 + z))(t4 + z)(t5 + z(t6 + z))
96  100   */
97      -/* t1 = */  3.71923358986516816929168705030406272271648049355e-0003,
98      -/* t2 = */  6.02645120354857866118436504621058702468872070312e+0000,
99      -/* t3 = */  2.42627327587398156083509093150496482849121093750e+0000,
100      -/* t4 = */  2.44968983934252770851003333518747240304946899414e+0000,
101      -/* t5 = */  6.07089252571767978849948121933266520500183105469e+0000,
101 +/* t1 = */ 3.71923358986516816929168705030406272271648049355e-0003,
102 +/* t2 = */ 6.02645120354857866118436504621058702468872070312e+0000,
103 +/* t3 = */ 2.42627327587398156083509093150496482849121093750e+0000,
104 +/* t4 = */ 2.44968983934252770851003333518747240304946899414e+0000,
105 +/* t5 = */ 6.07089252571767978849948121933266520500183105469e+0000,
102  106  /* t6 = */ -2.49403756995593761658369658107403665781021118164e+0000,
103  107  };
104  108
105      -
106      -#define one q[0]
107      -#define pp1 q[1]
108      -#define pp2 q[2]
109      -#define pp3 q[3]
110      -#define qq1 q[4]
111      -#define qq2 q[5]
112      -#define t1  q[6]
113      -#define t2  q[7]
114      -#define t3  q[8]
115      -#define t4  q[9]
116      -#define t5  q[10]
117      -#define t6  q[11]
118      -
119      -/* INDENT ON */
109 +#define one             q[0]
110 +#define pp1             q[1]
111 +#define pp2             q[2]
112 +#define pp3             q[3]
113 +#define qq1             q[4]
114 +#define qq2             q[5]
115 +#define t1              q[6]
116 +#define t2              q[7]
117 +#define t3              q[8]
118 +#define t4              q[9]
119 +#define t5              q[10]
120 +#define t6              q[11]
120  121
121  122
122  123  double
123      -__k_tan(double x, double y, int k) {
124 +__k_tan(double x, double y, int k)
125 +{
124  126          double a, t, z, w = 0.0L, s, c, r, rh, xh, xl;
125  127          int i, j, hx, ix;
126  128
127  129          t = one;
128      -        hx = ((int *) &x)[HIWORD];
130 +        hx = ((int *)&x)[HIWORD];
129  131          ix = hx & 0x7fffffff;
130      -        if (ix < 0x3fc40000) {          /* 0.15625 */
131      -                if (ix < 0x3e400000) {  /* 2^-27 */
132      -                        if ((i = (int) x) == 0)         /* generate inexact */
132 +
133 +        if (ix < 0x3fc40000) {                  /* 0.15625 */
134 +                if (ix < 0x3e400000) {          /* 2^-27 */
135 +                        if ((i = (int)x) == 0)  /* generate inexact */
133  136                                  w = x;
137 +
134  138                          t = y;
135  139                  } else {
136  140                          z = x * x;
137      -                        t = y + (((t1 * x) * z) * (t2 + z * (t3 + z))) *
138      -                                ((t4 + z) * (t5 + z * (t6 + z)));
141 +                        t = y + (((t1 * x) * z) * (t2 + z * (t3 + z))) * ((t4 +
142 +                            z) * (t5 + z * (t6 + z)));
139  143                          w = x + t;
140  144                  }
145 +
141  146                  if (k == 0)
142  147                          return (w);
148 +
143  149                  /*
144  150                   * Compute -1/(x+T) with great care
145  151                   * Let r = -1/(x+T), rh = r chopped to 20 bits.
146  152                   * Also let xh  = x+T chopped to 20 bits, xl = (x-xh)+T. Then
147  153                   *   -1/(x+T)   = rh + (-1/(x+T)-rh) = rh + r*(1+rh*(x+T))
148  154                   *              = rh + r*((1+rh*xh)+rh*xl).
149  155                   */
150  156                  rh = r = -one / w;
151      -                ((int *) &rh)[LOWORD] = 0;
157 +                ((int *)&rh)[LOWORD] = 0;
152  158                  xh = w;
153      -                ((int *) &xh)[LOWORD] = 0;
159 +                ((int *)&xh)[LOWORD] = 0;
154  160                  xl = (x - xh) + t;
155  161                  return (rh + r * ((one + rh * xh) + rh * xl));
156  162          }
163 +
157  164          j = (ix + 0x4000) & 0x7fff8000;
158  165          i = (j - 0x3fc40000) >> 15;
159      -        ((int *) &t)[HIWORD] = j;
166 +        ((int *)&t)[HIWORD] = j;
167 +
160  168          if (hx > 0)
161  169                  x = y - (t - x);
162  170          else
163  171                  x = -y - (t + x);
172 +
164  173          a = _TBL_tan_hi[i];
165  174          z = x * x;
166  175          s = (pp1 * x) * (pp2 + z * (pp3 + z));  /* sin(x) */
167  176          t = (qq1 * z) * (qq2 + z);              /* cos(x) - 1 */
177 +
168  178          if (k == 0) {
169  179                  w = a * s;
170  180                  t = _TBL_tan_lo[i] + (s + a * w) / (one - (w - t));
171  181                  return (hx < 0 ? -a - t : a + t);
172  182          } else {
173  183                  w = s + a * t;
174  184                  c = w + _TBL_tan_lo[i];
175  185                  t = a * s - t;
186 +
176  187                  /*
177  188                   * Now try to compute [(1-T)/(a+c)] accurately
178  189                   *
179  190                   * Let r = 1/(a+c), rh = (1-T)*r chopped to 20 bits.
180  191                   * Also let xh = a+c chopped to 20 bits, xl = (a-xh)+c. Then
181  192                   *      (1-T)/(a+c) = rh + ((1-T)/(a+c)-rh)
182  193                   *              = rh + r*(1-T-rh*(a+c))
183  194                   *              = rh + r*((1-T-rh*xh)-rh*xl)
184  195                   *              = rh + r*(((1-rh*xh)-T)-rh*xl)
185  196                   */
186  197                  r = one / (a + c);
187  198                  rh = (one - t) * r;
188      -                ((int *) &rh)[LOWORD] = 0;
199 +                ((int *)&rh)[LOWORD] = 0;
189  200                  xh = a + c;
190      -                ((int *) &xh)[LOWORD] = 0;
201 +                ((int *)&xh)[LOWORD] = 0;
191  202                  xl = (a - xh) + c;
192  203                  z = rh + r * (((one - rh * xh) - t) - rh * xl);
193  204                  return (hx >= 0 ? -z : z);
194  205          }
195  206  }
```
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`