summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-08-09 17:03:43 +0200
committerLennart Poettering <lennart@poettering.net>2008-08-09 17:03:43 +0200
commitafbfd5d9375919c0b6dd718d68588a5d7cf18140 (patch)
tree582fdf547f3e2d3ef01c548aa3f77b235027bb63 /src/pulsecore
parent432b4e5f7d9ea722d13bbe4c117a4f9b78091e4f (diff)
adhere to C strict aliasing rules
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/endianmacros.h11
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)