Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -16,13 +16,15 @@
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
+
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -404,13 +406,15 @@
#define p2 C[9]
#define p3 C[10]
#define p4 C[11]
double
-atan2(double oy, double ox) {
+atan2(double oy, double ox)
+{
double ah, al, t, xh, x, y, z;
int i, k, hx, hy, sx, sy;
+
#ifndef lint
volatile int inexact __unused;
#endif
hy = ((int *)&oy)[HIWORD];
@@ -426,10 +430,11 @@
i = hx;
hx = hy;
hy = i;
x = fabs(oy);
y = fabs(ox);
+
if (sx) {
ah = pio2;
al = pio2_lo;
} else {
ah = -pio2;
@@ -437,10 +442,11 @@
sy ^= 0x80000000;
}
} else {
x = fabs(ox);
y = fabs(oy);
+
if (sx) {
ah = mpi;
al = mpi_lo;
sy ^= 0x80000000;
} else {
@@ -450,50 +456,59 @@
if (hx >= 0x7fe00000 || hx - hy >= 0x03600000) {
if (hx >= 0x7ff00000) {
if (((hx ^ 0x7ff00000) | ((int *)&x)[LOWORD]) != 0)
return (ox * oy);
+
if (hy >= 0x7ff00000)
ah += pio4;
+
#ifndef lint
inexact = (int)ah; /* inexact if ah != 0 */
#endif
- return ((sy)? -ah : ah);
+ return ((sy) ? -ah : ah);
}
+
if (hx - hy >= 0x03600000) {
if ((int)ah == 0)
ah = y / x;
- return ((sy)? -ah : ah);
+
+ return ((sy) ? -ah : ah);
}
+
y *= twom3;
x *= twom3;
hy -= 0x00300000;
hx -= 0x00300000;
} else if (hy < 0x00100000) {
if ((hy | ((int *)&y)[LOWORD]) == 0) {
if ((hx | ((int *)&x)[LOWORD]) == 0)
return (_SVID_libm_err(ox, oy, 3));
+
#ifndef lint
inexact = (int)ah; /* inexact if ah != 0 */
#endif
- return ((sy)? -ah : ah);
+ return ((sy) ? -ah : ah);
}
+
y *= two110;
x *= two110;
hy = ((int *)&y)[HIWORD];
hx = ((int *)&x)[HIWORD];
}
k = (((hx - hy) + 0x00004000) >> 13) & ~0x3;
+
if (k > 644)
k = 644;
+
ah += TBL[k];
- al += TBL[k+1];
- t = TBL[k+2];
+ al += TBL[k + 1];
+ t = TBL[k + 2];
xh = x;
((int *)&xh)[LOWORD] = 0;
z = ((y - t * xh) - t * (x - xh)) / (x + y * t);
x = z * z;
t = ah + (z + (al + (z * x) * (p1 + x * (p2 + x * (p3 + x * p4)))));
- return ((sy)? -t : t);
+ return ((sy) ? -t : t);
}