Use __signbit inline.

This commit is contained in:
Ulrich Drepper 1997-04-02 14:43:52 +00:00
parent b9a0a7fbcd
commit 231e25e2a3

View File

@ -27,10 +27,12 @@
#define float_type double #define float_type double
#endif #endif
#define __CONCATX(a,b) __CONCAT(a,b) #define CONCATX(a,b) __CONCAT(a,b)
#define s(name) CONCATX(name,SUFF)
#define m81(func) __m81_u(s(func))
float_type float_type
__CONCATX(__ieee754_atan2,SUFF) (float_type y, float_type x) s(__ieee754_atan2) (float_type y, float_type x)
{ {
float_type pi, pi_2, z; float_type pi, pi_2, z;
@ -40,41 +42,41 @@ __CONCATX(__ieee754_atan2,SUFF) (float_type y, float_type x)
z = x + y; z = x + y;
else if (y == 0) else if (y == 0)
{ {
if (signbit (x)) if (m81(__signbit) (x))
z = signbit (y) ? -pi : pi; z = m81(__signbit) (y) ? -pi : pi;
else else
z = y; z = y;
} }
else if (__m81_u(__CONCATX(__isinf,SUFF)) (x)) else if (m81(__isinf) (x))
{ {
if (__m81_u(__CONCATX(__isinf,SUFF)) (y)) if (m81(__isinf) (y))
{ {
float_type pi_4; float_type pi_4;
__asm ("fscale%.w %#-1, %0" : "=f" (pi_4) : "0" (pi_2)); __asm ("fscale%.w %#-2, %0" : "=f" (pi_4) : "0" (pi));
z = x > 0 ? pi_4 : 3 * pi_4; z = x > 0 ? pi_4 : 3 * pi_4;
} }
else else
z = x > 0 ? 0 : pi; z = x > 0 ? 0 : pi;
if (signbit (y)) if (m81(__signbit) (y))
z = -z; z = -z;
} }
else if (__m81_u(__CONCATX(__isinf,SUFF)) (y)) else if (m81(__isinf) (y))
z = y > 0 ? pi_2 : -pi_2; z = y > 0 ? pi_2 : -pi_2;
else if (x > 0) else if (x > 0)
{ {
if (y > 0) if (y > 0)
{ {
if (x > y) if (x > y)
z = __m81_u(__CONCATX(__atan,SUFF)) (y / x); z = m81(__atan) (y / x);
else else
z = pi_2 - __m81_u(__CONCATX(__atan,SUFF)) (x / y); z = pi_2 - m81(__atan) (x / y);
} }
else else
{ {
if (x > -y) if (x > -y)
z = __m81_u(__CONCATX(__atan,SUFF)) (y / x); z = m81(__atan) (y / x);
else else
z = -pi_2 - __m81_u(__CONCATX(__atan,SUFF)) (x / y); z = -pi_2 - m81(__atan) (x / y);
} }
} }
else else
@ -82,16 +84,16 @@ __CONCATX(__ieee754_atan2,SUFF) (float_type y, float_type x)
if (y < 0) if (y < 0)
{ {
if (-x > y) if (-x > y)
z = -pi + __m81_u(__CONCATX(__atan,SUFF)) (y / x); z = -pi + m81(__atan) (y / x);
else else
z = -pi_2 - __m81_u(__CONCATX(__atan,SUFF)) (x / y); z = -pi_2 - m81(__atan) (x / y);
} }
else else
{ {
if (-x > y) if (-x > y)
z = pi + __m81_u(__CONCATX(__atan,SUFF)) (y / x); z = pi + m81(__atan) (y / x);
else else
z = pi_2 - __m81_u(__CONCATX(__atan,SUFF)) (x / y); z = pi_2 - m81(__atan) (x / y);
} }
} }
return z; return z;