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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/R/atan2f.c
          +++ new/usr/src/lib/libm/common/R/atan2f.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 __atan2f = atan2f
  30   32  
  31   33  #include "libm.h"
  32   34  
  33   35  #if defined(__i386) && !defined(__amd64)
↓ open down ↓ 196 lines elided ↑ open up ↑
 230  232          1.55156792769518947e+00,
 231  233          1.55227992472688747e+00,
 232  234          1.55294108165534417e+00,
 233  235          1.55355665560036682e+00,
 234  236          1.55413120308095598e+00,
 235  237          1.55466869295126031e+00,
 236  238          1.55517259817441977e+00,
 237  239  };
 238  240  
 239  241  static const double
 240      -        pio4    =  7.8539816339744827900e-01,
 241      -        pio2    =  1.5707963267948965580e+00,
 242      -        negpi   = -3.1415926535897931160e+00,
 243      -        q1      = -3.3333333333296428046e-01,
 244      -        q2      =  1.9999999186853752618e-01,
 245      -        zero    =  0.0;
 246      -
      242 +        pio4 = 7.8539816339744827900e-01,
      243 +        pio2 = 1.5707963267948965580e+00,
      244 +        negpi = -3.1415926535897931160e+00,
      245 +        q1 = -3.3333333333296428046e-01,
      246 +        q2 = 1.9999999186853752618e-01,
      247 +        zero = 0.0;
 247  248  static const float two24 = 16777216.0;
 248  249  
 249  250  float
 250  251  atan2f(float fy, float fx)
 251  252  {
 252      -        double  a, t, s, dbase;
 253      -        float   x, y, base;
 254      -        int     i, k, hx, hy, ix, iy, sign;
      253 +        double a, t, s, dbase;
      254 +        float x, y, base;
      255 +        int i, k, hx, hy, ix, iy, sign;
      256 +
 255  257  #if defined(__i386) && !defined(__amd64)
 256      -        int     rp;
      258 +        int rp;
 257  259  #endif
 258  260  
 259  261          iy = *(int *)&fy;
 260  262          ix = *(int *)&fx;
 261  263          hy = iy & ~0x80000000;
 262  264          hx = ix & ~0x80000000;
 263  265  
 264  266          sign = 0;
      267 +
 265  268          if (hy > hx) {
 266  269                  x = fy;
 267  270                  y = fx;
 268  271                  i = hx;
 269  272                  hx = hy;
 270  273                  hy = i;
      274 +
 271  275                  if (iy < 0) {
 272  276                          x = -x;
 273  277                          sign = 1;
 274  278                  }
      279 +
 275  280                  if (ix < 0) {
 276  281                          y = -y;
 277  282                          a = pio2;
 278  283                  } else {
 279  284                          a = -pio2;
 280  285                          sign = 1 - sign;
 281  286                  }
 282  287          } else {
 283  288                  y = fy;
 284  289                  x = fx;
      290 +
 285  291                  if (iy < 0) {
 286  292                          y = -y;
 287  293                          sign = 1;
 288  294                  }
      295 +
 289  296                  if (ix < 0) {
 290  297                          x = -x;
 291  298                          a = negpi;
 292  299                          sign = 1 - sign;
 293  300                  } else {
 294  301                          a = zero;
 295  302                  }
 296  303          }
 297  304  
 298  305          if (hx >= 0x7f800000 || hx - hy >= 0x0c800000) {
 299  306                  if (hx >= 0x7f800000) {
 300      -                        if (hx > 0x7f800000) /* nan */
      307 +                        if (hx > 0x7f800000)    /* nan */
 301  308                                  return (x * y);
 302  309                          else if (hy >= 0x7f800000)
 303  310                                  a += pio4;
 304  311                  } else if ((int)a == 0) {
 305  312                          a = (double)y / x;
 306  313                  }
 307      -                return ((float)((sign)? -a : a));
      314 +
      315 +                return ((float)((sign) ? -a : a));
 308  316          }
 309  317  
 310  318          if (hy < 0x00800000) {
 311  319                  if (hy == 0)
 312      -                        return ((float)((sign)? -a : a));
      320 +                        return ((float)((sign) ? -a : a));
      321 +
 313  322                  /* scale subnormal y */
 314  323                  y *= two24;
 315  324                  x *= two24;
 316  325                  hy = *(int *)&y;
 317  326                  hx = *(int *)&x;
 318  327          }
 319  328  
 320  329  #if defined(__i386) && !defined(__amd64)
 321  330          rp = __swapRP(fp_extended);
 322  331  #endif
 323  332          k = (hy - hx + 0x3f800000) & 0xfff80000;
 324      -        if (k >= 0x3c800000) {  /* |y/x| >= 1/64 */
      333 +
      334 +        if (k >= 0x3c800000) {          /* |y/x| >= 1/64 */
 325  335                  *(int *)&base = k;
 326  336                  k = (k - 0x3c800000) >> 19;
 327  337                  a += TBL[k];
 328  338          } else {
 329  339                  /*
 330  340                   * For some reason this is faster on USIII than just
 331  341                   * doing t = y/x in this case.
 332  342                   */
 333  343                  *(int *)&base = 0;
 334  344          }
      345 +
 335  346          dbase = (double)base;
 336  347          t = (y - x * dbase) / (x + y * dbase);
 337  348          s = t * t;
 338  349          a = (a + t) + t * s * (q1 + s * q2);
 339  350  #if defined(__i386) && !defined(__amd64)
 340  351          if (rp != fp_extended)
 341  352                  (void) __swapRP(rp);
 342  353  #endif
 343      -        return ((float)((sign)? -a : a));
      354 +        return ((float)((sign) ? -a : a));
 344  355  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX