diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-08-09 17:03:43 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-08-09 17:03:43 +0200 |
commit | afbfd5d9375919c0b6dd718d68588a5d7cf18140 (patch) | |
tree | 582fdf547f3e2d3ef01c548aa3f77b235027bb63 | |
parent | 432b4e5f7d9ea722d13bbe4c117a4f9b78091e4f (diff) |
adhere to C strict aliasing rules
-rw-r--r-- | src/pulsecore/endianmacros.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pulsecore/endianmacros.h b/src/pulsecore/endianmacros.h index 26336918..1b94de17 100644 --- a/src/pulsecore/endianmacros.h +++ b/src/pulsecore/endianmacros.h @@ -46,9 +46,14 @@ #endif static inline float PA_FLOAT32_SWAP(float x) { - uint32_t i = *(uint32_t*) &x; - i = PA_UINT32_SWAP(i); - return *(float*) &i; + union { + float f; + uint32_t u; + } t; + + t.f = x; + t.u = PA_UINT32_SWAP(t.u); + return t.f; } #define PA_MAYBE_INT16_SWAP(c,x) ((c) ? PA_INT32_SWAP(x) : x) |