diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2002-08-13 14:17:39 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2002-08-13 14:17:39 +0000 |
commit | f67a15f38ed1e98df4e35e1cb8f4d6a3a146ae76 (patch) | |
tree | 4a967a0ecd2e80104cb3a22940c9b307cbe7b8ff /lib/libc | |
parent | 0c163aab84c1627c534a18e9dc1e4a597654594c (diff) | |
download | FreeBSD-src-f67a15f38ed1e98df4e35e1cb8f4d6a3a146ae76.zip FreeBSD-src-f67a15f38ed1e98df4e35e1cb8f4d6a3a146ae76.tar.gz |
Use a union to access the words of a double as this is less likely
to cause bugs when gcc is more aggressively optimising things.
There are still problems with dtoa mentioned in the PR - maybe
Dan could suggest a patch.
PR: 40209
Submitted by: Dan Lukes <dan@obluda.cz>
Approved by: bde
MFC after: 2 weeks
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdlib/strtod.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/stdlib/strtod.c b/lib/libc/stdlib/strtod.c index eaa7ad0..9295583 100644 --- a/lib/libc/stdlib/strtod.c +++ b/lib/libc/stdlib/strtod.c @@ -222,12 +222,16 @@ extern "C" { Only one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. #endif +union doubleasulongs { + double x; + ULong w[2]; +}; #ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ((ULong *)&x)[1] -#define word1(x) ((ULong *)&x)[0] +#define word0(x) (((union doubleasulongs *)&x)->w)[1] +#define word1(x) (((union doubleasulongs *)&x)->w)[0] #else -#define word0(x) ((ULong *)&x)[0] -#define word1(x) ((ULong *)&x)[1] +#define word0(x) (((union doubleasulongs *)&x)->w)[0] +#define word1(x) (((union doubleasulongs *)&x)->w)[1] #endif /* The following definition of Storeinc is appropriate for MIPS processors. |