diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-10-08 10:18:26 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-10-08 10:18:26 -0400 |
commit | 7edb55ce06ab1fa716a062cd1cb6682585bb449d (patch) | |
tree | 3fed82e7c3f86ac57f3e9d6f314044b7dbdb8d03 /sysdeps/ieee754/dbl-64 | |
parent | 187da0aedcd9d0a2fb34477bef41549681ba1273 (diff) | |
download | glibc-7edb55ce06ab1fa716a062cd1cb6682585bb449d.tar.gz |
Optimize use of isnan, isinf, finite
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_finite.c | 1 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_isinf_ns.c | 20 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_isnan.c | 1 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c | 1 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c | 20 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c | 1 |
6 files changed, 44 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_finite.c b/sysdeps/ieee754/dbl-64/s_finite.c index 90de0f9d11..2ca3bf2454 100644 --- a/sysdeps/ieee754/dbl-64/s_finite.c +++ b/sysdeps/ieee754/dbl-64/s_finite.c @@ -22,6 +22,7 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $"; #include "math.h" #include "math_private.h" +#undef __finite #ifdef __STDC__ int __finite(double x) #else diff --git a/sysdeps/ieee754/dbl-64/s_isinf_ns.c b/sysdeps/ieee754/dbl-64/s_isinf_ns.c new file mode 100644 index 0000000000..065522ed80 --- /dev/null +++ b/sysdeps/ieee754/dbl-64/s_isinf_ns.c @@ -0,0 +1,20 @@ +/* + * Written by Ulrich Drepper <drepper@gmail.com>. + */ + +/* + * __isinf_ns(x) returns != 0 if x is ±inf, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#undef __isinf_ns +int +__isinf_ns (double x) +{ + int32_t hx,lx; + EXTRACT_WORDS(hx,lx,x); + return !(lx | ((hx & 0x7fffffff) ^ 0x7ff00000)); +} diff --git a/sysdeps/ieee754/dbl-64/s_isnan.c b/sysdeps/ieee754/dbl-64/s_isnan.c index 3a089e99a8..74e8291609 100644 --- a/sysdeps/ieee754/dbl-64/s_isnan.c +++ b/sysdeps/ieee754/dbl-64/s_isnan.c @@ -22,6 +22,7 @@ static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $"; #include "math.h" #include "math_private.h" +#undef __isnan #ifdef __STDC__ int __isnan(double x) #else diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c index 585f63e571..93a39a6835 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c @@ -17,6 +17,7 @@ #include "math.h" #include "math_private.h" +#undef __finite int __finite(double x) { diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c new file mode 100644 index 0000000000..09dcc94532 --- /dev/null +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c @@ -0,0 +1,20 @@ +/* + * Written by Ulrich Drepper <drepper@gmail.com>. + */ + +/* + * __isinf_ns(x) returns != 0 if x is ±inf, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#undef __isinf_ns +int +__isinf_ns (double x) +{ + int64_t ix; + EXTRACT_WORDS64(ix,x); + return (ix & UINT64_C(0x7fffffffffffffff)) == UINT64_C(0x7ff0000000000000); +} diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c index 3b08c54dd4..65dc8934f9 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c @@ -18,6 +18,7 @@ #include "math.h" #include "math_private.h" +#undef __isnan #ifdef __STDC__ int __isnan(double x) #else |