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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/atan2.c
          +++ new/usr/src/lib/libm/common/C/atan2.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 2006 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  #pragma weak __atan2 = atan2
  30   32  
  31   33  #include "libm.h"
  32   34  
  33   35  /*
↓ open down ↓ 351 lines elided ↑ open up ↑
 385  387          1.5707963267948965580e+00,
 386  388          6.1232339957367658860e-17,
 387  389          -3.1415926535897931160e+00,
 388  390          -1.2246467991473531772e-16,
 389  391          -3.33333333333327571893331786354179101074860633009e-0001,
 390  392          +1.99999999942671624230086497610394721817438631379e-0001,
 391  393          -1.42856965565428636896183013324727205980484158356e-0001,
 392  394          +1.10894981496317081405107718475040168084164825641e-0001,
 393  395  };
 394  396  
 395      -#define zero    C[0]
 396      -#define twom3   C[1]
 397      -#define two110  C[2]
 398      -#define pio4    C[3]
 399      -#define pio2    C[4]
 400      -#define pio2_lo C[5]
 401      -#define mpi     C[6]
 402      -#define mpi_lo  C[7]
 403      -#define p1      C[8]
 404      -#define p2      C[9]
 405      -#define p3      C[10]
 406      -#define p4      C[11]
      397 +#define zero            C[0]
      398 +#define twom3           C[1]
      399 +#define two110          C[2]
      400 +#define pio4            C[3]
      401 +#define pio2            C[4]
      402 +#define pio2_lo         C[5]
      403 +#define mpi             C[6]
      404 +#define mpi_lo          C[7]
      405 +#define p1              C[8]
      406 +#define p2              C[9]
      407 +#define p3              C[10]
      408 +#define p4              C[11]
 407  409  
 408  410  double
 409      -atan2(double oy, double ox) {
 410      -        double  ah, al, t, xh, x, y, z;
 411      -        int     i, k, hx, hy, sx, sy;
      411 +atan2(double oy, double ox)
      412 +{
      413 +        double ah, al, t, xh, x, y, z;
      414 +        int i, k, hx, hy, sx, sy;
      415 +
 412  416  #ifndef lint
 413      -        volatile int    inexact __unused;
      417 +        volatile int inexact __unused;
 414  418  #endif
 415  419  
 416  420          hy = ((int *)&oy)[HIWORD];
 417  421          sy = hy & 0x80000000;
 418  422          hy &= ~0x80000000;
 419  423  
 420  424          hx = ((int *)&ox)[HIWORD];
 421  425          sx = hx & 0x80000000;
 422  426          hx &= ~0x80000000;
 423  427  
 424  428          if (hy > hx || (hy == hx && ((unsigned *)&oy)[LOWORD] >
 425  429              ((unsigned *)&ox)[LOWORD])) {
 426  430                  i = hx;
 427  431                  hx = hy;
 428  432                  hy = i;
 429  433                  x = fabs(oy);
 430  434                  y = fabs(ox);
      435 +
 431  436                  if (sx) {
 432  437                          ah = pio2;
 433  438                          al = pio2_lo;
 434  439                  } else {
 435  440                          ah = -pio2;
 436  441                          al = -pio2_lo;
 437  442                          sy ^= 0x80000000;
 438  443                  }
 439  444          } else {
 440  445                  x = fabs(ox);
 441  446                  y = fabs(oy);
      447 +
 442  448                  if (sx) {
 443  449                          ah = mpi;
 444  450                          al = mpi_lo;
 445  451                          sy ^= 0x80000000;
 446  452                  } else {
 447  453                          ah = al = zero;
 448  454                  }
 449  455          }
 450  456  
 451  457          if (hx >= 0x7fe00000 || hx - hy >= 0x03600000) {
 452  458                  if (hx >= 0x7ff00000) {
 453  459                          if (((hx ^ 0x7ff00000) | ((int *)&x)[LOWORD]) != 0)
 454  460                                  return (ox * oy);
      461 +
 455  462                          if (hy >= 0x7ff00000)
 456  463                                  ah += pio4;
      464 +
 457  465  #ifndef lint
 458  466                          inexact = (int)ah;      /* inexact if ah != 0 */
 459  467  #endif
 460      -                        return ((sy)? -ah : ah);
      468 +                        return ((sy) ? -ah : ah);
 461  469                  }
      470 +
 462  471                  if (hx - hy >= 0x03600000) {
 463  472                          if ((int)ah == 0)
 464  473                                  ah = y / x;
 465      -                        return ((sy)? -ah : ah);
      474 +
      475 +                        return ((sy) ? -ah : ah);
 466  476                  }
      477 +
 467  478                  y *= twom3;
 468  479                  x *= twom3;
 469  480                  hy -= 0x00300000;
 470  481                  hx -= 0x00300000;
 471  482          } else if (hy < 0x00100000) {
 472  483                  if ((hy | ((int *)&y)[LOWORD]) == 0) {
 473  484                          if ((hx | ((int *)&x)[LOWORD]) == 0)
 474  485                                  return (_SVID_libm_err(ox, oy, 3));
      486 +
 475  487  #ifndef lint
 476  488                          inexact = (int)ah;      /* inexact if ah != 0 */
 477  489  #endif
 478      -                        return ((sy)? -ah : ah);
      490 +                        return ((sy) ? -ah : ah);
 479  491                  }
      492 +
 480  493                  y *= two110;
 481  494                  x *= two110;
 482  495                  hy = ((int *)&y)[HIWORD];
 483  496                  hx = ((int *)&x)[HIWORD];
 484  497          }
 485  498  
 486  499          k = (((hx - hy) + 0x00004000) >> 13) & ~0x3;
      500 +
 487  501          if (k > 644)
 488  502                  k = 644;
      503 +
 489  504          ah += TBL[k];
 490      -        al += TBL[k+1];
 491      -        t = TBL[k+2];
      505 +        al += TBL[k + 1];
      506 +        t = TBL[k + 2];
 492  507  
 493  508          xh = x;
 494  509          ((int *)&xh)[LOWORD] = 0;
 495  510          z = ((y - t * xh) - t * (x - xh)) / (x + y * t);
 496  511          x = z * z;
 497  512          t = ah + (z + (al + (z * x) * (p1 + x * (p2 + x * (p3 + x * p4)))));
 498      -        return ((sy)? -t : t);
      513 +        return ((sy) ? -t : t);
 499  514  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX