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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/LD/__sincosl.c
          +++ new/usr/src/lib/libm/common/LD/__sincosl.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      -/* INDENT OFF */
       31 +
  31   32  /*
  32   33   * long double __k_sincos( long double x, long double y, long double *c )
  33   34   * kernel sincosl 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   * return sinl(x) with *c = cosl(x)
  37   38   *
  38   39   * Table look up algorithm
  39   40   *      see __k_sinl() and __k_cosl()
  40   41   */
  41   42  
  42   43  #include "libm.h"
  43   44  
  44   45  #include <sys/isa_defs.h>
  45   46  
  46   47  extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[],
  47   48          _TBL_cosl_lo[];
  48      -static const long double
  49      -one     = 1.0,
       49 +static const long double one = 1.0;
       50 +
  50   51  /*
  51   52   * |sin(x) - (x+pp1*x^3+...+pp5*x^11)| <= 2^-122.32 for |x|<1/64
  52   53   */
  53      -pp1     = -1.666666666666666666666666666586782940810e-0001L,
  54      -pp2     =  8.333333333333333333333003723660929317540e-0003L,
  55      -pp3     = -1.984126984126984076045903483778337804470e-0004L,
  56      -pp4     =  2.755731922361906641319723106210900949413e-0006L,
  57      -pp5     = -2.505198398570947019093998469135012057673e-0008L,
       54 +static const long double
       55 +        pp1 = -1.666666666666666666666666666586782940810e-0001L,
       56 +        pp2 = 8.333333333333333333333003723660929317540e-0003L,
       57 +        pp3 = -1.984126984126984076045903483778337804470e-0004L,
       58 +        pp4 = 2.755731922361906641319723106210900949413e-0006L,
       59 +        pp5 = -2.505198398570947019093998469135012057673e-0008L;
       60 +
  58   61  /*
  59   62   * |(sin(x) - (x+p1*x^3+...+p8*x^17)|
  60   63   * |------------------------------- | <= 2^-116.17 for |x|<0.1953125
  61   64   * |                 x              |
  62   65   */
  63      -p1      =  -1.666666666666666666666666666666211262297e-0001L,
  64      -p2      =   8.333333333333333333333333301497876908541e-0003L,
  65      -p3      =  -1.984126984126984126984041302881180621922e-0004L,
  66      -p4      =   2.755731922398589064100587351307269621093e-0006L,
  67      -p5      =  -2.505210838544163129378906953765595393873e-0008L,
  68      -p6      =   1.605904383643244375050998243778534074273e-0010L,
  69      -p7      =  -7.647162722800685516901456114270824622699e-0013L,
  70      -p8      =   2.810046428661902961725428841068844462603e-0015L,
       66 +static const long double
       67 +        p1 = -1.666666666666666666666666666666211262297e-0001L,
       68 +        p2 = 8.333333333333333333333333301497876908541e-0003L,
       69 +        p3 = -1.984126984126984126984041302881180621922e-0004L,
       70 +        p4 = 2.755731922398589064100587351307269621093e-0006L,
       71 +        p5 = -2.505210838544163129378906953765595393873e-0008L,
       72 +        p6 = 1.605904383643244375050998243778534074273e-0010L,
       73 +        p7 = -7.647162722800685516901456114270824622699e-0013L,
       74 +        p8 = 2.810046428661902961725428841068844462603e-0015L;
       75 +
  71   76  /*
  72   77   *
  73   78   * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128
  74   79   */
  75      -qq1     =  -4.999999999999999999999999999999378373641e-0001L,
  76      -qq2     =   4.166666666666666666666665478399327703130e-0002L,
  77      -qq3     =  -1.388888888888888888058211230618051613494e-0003L,
  78      -qq4     =   2.480158730156105377771585658905303111866e-0005L,
  79      -qq5     =  -2.755728099762526325736488376695157008736e-0007L,
       80 +static const long double
       81 +        qq1 = -4.999999999999999999999999999999378373641e-0001L,
       82 +        qq2 = 4.166666666666666666666665478399327703130e-0002L,
       83 +        qq3 = -1.388888888888888888058211230618051613494e-0003L,
       84 +        qq4 = 2.480158730156105377771585658905303111866e-0005L,
       85 +        qq5 = -2.755728099762526325736488376695157008736e-0007L;
       86 +
  80   87  /*
  81   88   *
  82   89   * |cos(x) - (1+q1*x^2+...+ q8*x^16)| <= 2^-117.11 for |x|<= 0.15625
  83   90   */
  84      -q1      =  -4.999999999999999999999999999999756416975e-0001L,
  85      -q2      =   4.166666666666666666666666664006066577258e-0002L,
  86      -q3      =  -1.388888888888888888888877700363937169637e-0003L,
  87      -q4      =   2.480158730158730158494468463031814083559e-0005L,
  88      -q5      =  -2.755731922398586276322819250356005542871e-0007L,
  89      -q6      =   2.087675698767424261441959760729854017855e-0009L,
  90      -q7      =  -1.147074481239662089072452129010790774761e-0011L,
  91      -q8      =   4.777761647399651599730663422263531034782e-0014L;
  92      -/* INDENT ON */
       91 +static const long double
       92 +        q1 = -4.999999999999999999999999999999756416975e-0001L,
       93 +        q2 = 4.166666666666666666666666664006066577258e-0002L,
       94 +        q3 = -1.388888888888888888888877700363937169637e-0003L,
       95 +        q4 = 2.480158730158730158494468463031814083559e-0005L,
       96 +        q5 = -2.755731922398586276322819250356005542871e-0007L,
       97 +        q6 = 2.087675698767424261441959760729854017855e-0009L,
       98 +        q7 = -1.147074481239662089072452129010790774761e-0011L,
       99 +        q8 = 4.777761647399651599730663422263531034782e-0014L;
      100 +
      101 +
  93  102  long double
  94      -__k_sincosl(long double x, long double y, long double *c) {
      103 +__k_sincosl(long double x, long double y, long double *c)
      104 +{
  95  105          long double a1, a2, t, t1, t2, z, w;
  96      -        int *pt = (int *) &t, *px = (int *) &x;
      106 +        int *pt = (int *)&t, *px = (int *)&x;
  97  107          int i, j, hx, ix;
  98  108  
  99  109          t = 1.0;
 100  110  #if defined(__i386) || defined(__amd64)
 101  111          XTOI(px, hx);
 102  112  #else
 103  113          hx = px[0];
 104  114  #endif
 105  115          ix = hx & 0x7fffffff;
      116 +
 106  117          if (ix < 0x3ffc4000) {
 107      -                if (ix < 0x3fc60000)
 108      -                        if (((int) x) == 0) {
      118 +                if (ix < 0x3fc60000) {
      119 +                        if (((int)x) == 0) {
 109  120                                  *c = one;
 110  121                                  return (x);
 111      -                        }       /* generate inexact */
      122 +                        }               /* generate inexact */
      123 +                }
      124 +
 112  125                  z = x * x;
 113  126  
 114  127                  if (ix < 0x3ff80000) {
 115  128                          *c = one + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 +
 116      -                                z * qq5))));
      129 +                            z * qq5))));
 117  130                          t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 +
 118      -                                z * p6)))));
      131 +                            z * p6)))));
 119  132                  } else {
 120  133                          *c = one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + z *
 121      -                                (q5 + z * (q6 + z * (q7 + z * q8)))))));
      134 +                            (q5 + z * (q6 + z * (q7 + z * q8)))))));
 122  135                          t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 +
 123      -                                z * (p6 + z * (p7 + z * p8)))))));
      136 +                            z * (p6 + z * (p7 + z * p8)))))));
 124  137                  }
 125  138  
 126  139                  t = y + x * t;
 127  140                  return (x + t);
 128  141          }
      142 +
 129  143          j = (ix + 0x400) & 0x7ffff800;
 130  144          i = (j - 0x3ffc4000) >> 11;
 131  145  #if defined(__i386) || defined(__amd64)
 132  146          ITOX(j, pt);
 133  147  #else
 134  148          pt[0] = j;
 135  149  #endif
      150 +
 136  151          if (hx > 0)
 137  152                  x = y - (t - x);
 138  153          else
 139  154                  x = (-y) - (t + x);
      155 +
 140  156          a1 = _TBL_sinl_hi[i];
 141  157          z = x * x;
 142  158          t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
 143      -        w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z *
 144      -                pp5)))));
      159 +        w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5)))));
 145  160          a2 = _TBL_cosl_hi[i];
 146  161          t2 = _TBL_cosl_lo[i] - (a1 * w - a2 * t);
 147  162          *c = a2 + t2;
 148  163          t1 = a2 * w + a1 * t;
 149  164          t1 += _TBL_sinl_lo[i];
      165 +
 150  166          if (hx < 0)
 151  167                  return (-a1 - t1);
 152  168          else
 153  169                  return (a1 + t1);
 154  170  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX