diff options
Diffstat (limited to 'tools/source/stream/stream.cxx')
-rw-r--r-- | tools/source/stream/stream.cxx | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index a0c8428bbd76..810dbd09d6b7 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -91,7 +91,15 @@ inline static void SwapLongUInt( unsigned int& r ) #ifdef UNX inline static void SwapFloat( float& r ) { - *((sal_uInt32*)(void*)&r) = SWAPLONG( *((sal_uInt32*)(void*)&r) ); + union + { + float f; + sal_uInt32 c; + } s; + + s.f = r; + s.c = SWAPLONG( s.c ); + r = s.f; } inline static void SwapDouble( double& r ) { @@ -101,12 +109,19 @@ inline static void SwapDouble( double& r ) } else { - sal_uInt32* c = (sal_uInt32*)(void*)&r; - c[0] ^= c[1]; // zwei 32-Bit-Werte in situ vertauschen - c[1] ^= c[0]; - c[0] ^= c[1]; - c[0] = SWAPLONG(c[0]); // und die beiden 32-Bit-Werte selbst in situ drehen - c[1] = SWAPLONG(c[1]); + union + { + double d; + sal_uInt32 c[2]; + } s; + + s.d = r; + s.c[0] ^= s.c[1]; // zwei 32-Bit-Werte in situ vertauschen + s.c[1] ^= s.c[0]; + s.c[0] ^= s.c[1]; + s.c[0] = SWAPLONG(s.c[0]); // und die beiden 32-Bit-Werte selbst in situ drehen + s.c[1] = SWAPLONG(s.c[1]); + r = s.d; } } #endif |