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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/R/tanf.c
          +++ new/usr/src/lib/libm/common/R/tanf.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 2005 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  #pragma weak __tanf = tanf
  30   32  
  31   33  #include "libm.h"
  32   34  
  33   35  extern const int _TBL_ipio2_inf[];
  34   36  extern int __rem_pio2m(double *, double *, int, int, int, const int *);
       37 +
  35   38  #if defined(__i386) && !defined(__amd64)
  36   39  extern int __swapRP(int);
  37   40  #endif
  38   41  
  39   42  static const double C[] = {
  40   43          1.0,
  41   44          4.46066928428959230679140546271810308098793029785e-0003,
  42   45          4.92165316309189027066395283327437937259674072266e+0000,
  43   46          -7.11410648161473480044492134766187518835067749023e-0001,
  44   47          4.08549808374053391446523164631798863410949707031e+0000,
↓ open down ↓ 2 lines elided ↑ open up ↑
  47   50          -1.50565540968422650891511693771462887525558471680e+0000,
  48   51          -1.81484378878349295050043110677506774663925170898e+0000,
  49   52          3.333335997532835641297409611782510896641e-0001,
  50   53          2.999997598248363761541668282006867229939e+00,
  51   54          0.636619772367581343075535,     /* 2^ -1  * 1.45F306DC9C883 */
  52   55          0.5,
  53   56          1.570796326734125614166,        /* 2^  0  * 1.921FB54400000 */
  54   57          6.077100506506192601475e-11,    /* 2^-34  * 1.0B4611A626331 */
  55   58  };
  56   59  
  57      -#define one     C[0]
  58      -#define P0      C[1]
  59      -#define P1      C[2]
  60      -#define P2      C[3]
  61      -#define P3      C[4]
  62      -#define P4      C[5]
  63      -#define P5      C[6]
  64      -#define P6      C[7]
  65      -#define P7      C[8]
  66      -#define T0      C[9]
  67      -#define T1      C[10]
  68      -#define invpio2 C[11]
  69      -#define half    C[12]
  70      -#define pio2_1  C[13]
  71      -#define pio2_t  C[14]
       60 +#define one             C[0]
       61 +#define P0              C[1]
       62 +#define P1              C[2]
       63 +#define P2              C[3]
       64 +#define P3              C[4]
       65 +#define P4              C[5]
       66 +#define P5              C[6]
       67 +#define P6              C[7]
       68 +#define P7              C[8]
       69 +#define T0              C[9]
       70 +#define T1              C[10]
       71 +#define invpio2         C[11]
       72 +#define half            C[12]
       73 +#define pio2_1          C[13]
       74 +#define pio2_t          C[14]
  72   75  
  73   76  float
  74   77  tanf(float x)
  75   78  {
  76      -        double  y, z, w;
  77      -        float   f;
  78      -        int     n, ix, hx, hy;
       79 +        double y, z, w;
       80 +        float f;
       81 +        int n, ix, hx, hy;
  79   82          volatile int i __unused;
  80   83  
  81   84          hx = *((int *)&x);
  82   85          ix = hx & 0x7fffffff;
  83   86  
  84   87          y = (double)x;
  85   88  
  86      -        if (ix <= 0x4016cbe4) {         /* |x| < 3*pi/4 */
  87      -                if (ix <= 0x3f490fdb) {         /* |x| < pi/4 */
       89 +        if (ix <= 0x4016cbe4) {                         /* |x| < 3*pi/4 */
       90 +                if (ix <= 0x3f490fdb) {                 /* |x| < pi/4 */
  88   91                          if (ix < 0x3c000000) {          /* |x| < 2**-7 */
  89   92                                  if (ix <= 0x39800000) { /* |x| < 2**-12 */
  90   93                                          i = (int)y;
  91   94  #ifdef lint
  92   95                                          i = i;
  93   96  #endif
  94   97                                          return (x);
  95   98                                  }
       99 +
  96  100                                  return ((float)((y * T0) * (T1 + y * y)));
  97  101                          }
      102 +
  98  103                          z = y * y;
  99      -                        return ((float)(((P0 * y) * (P1 + z * (P2 + z)) *
 100      -                            (P3 + z * (P4 + z))) *
 101      -                            (P5 + z * (P6 + z * (P7 + z)))));
      104 +                        return ((float)(((P0 * y) * (P1 + z * (P2 + z)) * (P3 +
      105 +                            z * (P4 + z))) * (P5 + z * (P6 + z *
      106 +                            (P7 + z)))));
 102  107                  }
      108 +
 103  109                  if (hx > 0)
 104  110                          y = (y - pio2_1) - pio2_t;
 105  111                  else
 106  112                          y = (y + pio2_1) + pio2_t;
      113 +
 107  114                  hy = ((int *)&y)[HIWORD] & ~0x80000000;
 108      -                if (hy < 0x3f800000) {          /* |y| < 2**-7 */
      115 +
      116 +                if (hy < 0x3f800000) {  /* |y| < 2**-7 */
 109  117                          z = (y * T0) * (T1 + y * y);
 110  118                          return ((float)(-one / z));
 111  119                  }
      120 +
 112  121                  z = y * y;
 113  122                  w = ((P0 * y) * (P1 + z * (P2 + z)) * (P3 + z * (P4 + z))) *
 114  123                      (P5 + z * (P6 + z * (P7 + z)));
 115  124                  return ((float)(-one / w));
 116  125          }
 117  126  
 118      -        if (ix <= 0x49c90fdb) { /* |x| < 2^19*pi */
      127 +        if (ix <= 0x49c90fdb) {         /* |x| < 2^19*pi */
 119  128  #if defined(__i386) && !defined(__amd64)
 120      -                int     rp;
      129 +                int rp;
 121  130  
 122  131                  rp = __swapRP(fp_extended);
 123  132  #endif
 124  133                  w = y * invpio2;
      134 +
 125  135                  if (hx < 0)
 126  136                          n = (int)(w - half);
 127  137                  else
 128  138                          n = (int)(w + half);
      139 +
 129  140                  y = (y - n * pio2_1) - n * pio2_t;
 130  141  #if defined(__i386) && !defined(__amd64)
 131  142                  if (rp != fp_extended)
 132  143                          (void) __swapRP(rp);
 133  144  #endif
 134  145          } else {
 135  146                  if (ix >= 0x7f800000)
 136      -                        return (x / x); /* sin(Inf or NaN) is NaN */
      147 +                        return (x / x);         /* sin(Inf or NaN) is NaN */
      148 +
 137  149                  hy = ((int *)&y)[HIWORD];
 138  150                  n = ((hy >> 20) & 0x7ff) - 1046;
 139  151                  ((int *)&w)[HIWORD] = (hy & 0xfffff) | 0x41600000;
 140  152                  ((int *)&w)[LOWORD] = ((int *)&y)[LOWORD];
 141  153                  n = __rem_pio2m(&w, &y, n, 1, 0, _TBL_ipio2_inf);
      154 +
 142  155                  if (hy < 0) {
 143  156                          y = -y;
 144  157                          n = -n;
 145  158                  }
 146  159          }
 147  160  
 148  161          hy = ((int *)&y)[HIWORD] & ~0x80000000;
      162 +
 149  163          if (hy < 0x3f800000) {          /* |y| < 2**-7 */
 150  164                  z = (y * T0) * (T1 + y * y);
 151      -                f = ((n & 1) == 0)? (float)z : (float)(-one / z);
      165 +                f = ((n & 1) == 0) ? (float)z : (float)(-one / z);
 152  166                  return (f);
 153  167          }
      168 +
 154  169          z = y * y;
 155      -        w = ((P0 * y) * (P1 + z * (P2 + z)) * (P3 + z * (P4 + z))) *
 156      -            (P5 + z * (P6 + z * (P7 + z)));
 157      -        f = ((n & 1) == 0)? (float)w : (float)(-one / w);
      170 +        w = ((P0 * y) * (P1 + z * (P2 + z)) * (P3 + z * (P4 + z))) * (P5 + z *
      171 +            (P6 + z * (P7 + z)));
      172 +        f = ((n & 1) == 0) ? (float)w : (float)(-one / w);
 158  173          return (f);
 159  174  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX