summaryrefslogtreecommitdiffstats
path: root/lib/msun/bsdsrc/b_log.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2005-09-19 11:28:19 +0000
committerbde <bde@FreeBSD.org>2005-09-19 11:28:19 +0000
commit41d865435ac7d52c49e8ad66905a5fb7999b78e8 (patch)
tree806a6edd24f235f0d6a473af5d92d9125b66fc08 /lib/msun/bsdsrc/b_log.c
parent20c3ecf25a2f9e0ba99871b8d74286366fa50351 (diff)
downloadFreeBSD-src-41d865435ac7d52c49e8ad66905a5fb7999b78e8.zip
FreeBSD-src-41d865435ac7d52c49e8ad66905a5fb7999b78e8.tar.gz
Fixed aliasing bugs in TRUNC() by using the fdlibm macros for access
to doubles as bits. fdlibm-1.1 had similar aliasing bugs, but these were fixed by NetBSD or Cygnus before a modified version of fdlibm was imported in 1994. TRUNC() is only used by tgamma() and some implementation-detail functions. The aliasing bugs were detected by compiling with gcc -O2 but don't seem to have broken tgamma() on i386's or amd64's. They broke my modified version of tgamma(). Moved the definition of TRUNC() to mathimpl.h so that it can be fixed in one place, although the general version is even slower than necessary because it has to operate on pointers to volatiles to handle its arg sometimes being volatile. Inefficiency of the fdlibm macros slows down libm generally, and tgamma() is a relatively unimportant part of libm. The macros act as if on 32-bit words in memory, so they are hard to optimize to direct actions on 64-bit double registers for (non-i386) machines where this is possible. The optimization is too hard for gcc on amd64's, and declaring variables as volatile makes it impossible.
Diffstat (limited to 'lib/msun/bsdsrc/b_log.c')
-rw-r--r--lib/msun/bsdsrc/b_log.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/msun/bsdsrc/b_log.c b/lib/msun/bsdsrc/b_log.c
index 95d366d..b9f1473 100644
--- a/lib/msun/bsdsrc/b_log.c
+++ b/lib/msun/bsdsrc/b_log.c
@@ -77,9 +77,6 @@ __FBSDID("$FreeBSD$");
* +Inf return +Inf
*/
-#define endian (((*(int *) &one)) ? 1 : 0)
-#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
-
#define N 128
/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
@@ -438,7 +435,7 @@ __log__D(x) double x;
#endif
{
int m, j;
- double F, f, g, q, u, v, u2, one = 1.0;
+ double F, f, g, q, u, v, u2;
volatile double u1;
struct Double r;
OpenPOWER on IntegriCloud