tfix nan64 - plan9port - [fork] Plan 9 from user space
(HTM) git clone git://src.adamsgaard.dk/plan9port
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 35920e96a1bd6dcc5c803582ce9568c2f0a4fdc1
(DIR) parent e54f9a4ad2f163f9455f3de4b3e5574884391790
(HTM) Author: rsc <devnull@localhost>
Date: Thu, 10 May 2007 04:18:22 +0000
fix nan64
Diffstat:
M src/lib9/fmt/nan64.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c
t@@ -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;
}