plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 35920e96a1bd6dcc5c803582ce9568c2f0a4fdc1
parent e54f9a4ad2f163f9455f3de4b3e5574884391790
Author: rsc <devnull@localhost>
Date:   Thu, 10 May 2007 04:18:22 +0000

fix nan64

Diffstat:
Msrc/lib9/fmt/nan64.c | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c @@ -26,11 +26,18 @@ __NaN(void) int __isNaN(double d) { + /* + * Used to just say x = *(uvlong*)&d, + * but gcc miscompiles that! + */ + union { + uvlong i; + double f; + } u; uvlong x; - double *p; - - p = &d; - x = *(uvlong*)p; + + u.f = d; + x = u.i; /* IEEE 754: exponent bits 0x7FF and non-zero mantissa */ return (x&uvinf) == uvinf && (x&~uvneginf) != 0; }