summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-09-22 00:21:08 +0000
committerLennart Poettering <lennart@poettering.net>2007-09-22 00:21:08 +0000
commit9db42672d466ceec4f3d69f03e2d72ea18a8d62e (patch)
tree54d594e1693d1c957cf6e962da48180135be94fb /src
parentf26de8077d02c8bba2ed96b4dfb0e6d9f9a2485b (diff)
make use of byte swap builtins of gcc if they are available
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1880 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/endianmacros.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pulsecore/endianmacros.h b/src/pulsecore/endianmacros.h
index a29699b9..e2801c10 100644
--- a/src/pulsecore/endianmacros.h
+++ b/src/pulsecore/endianmacros.h
@@ -31,10 +31,21 @@
#error "Please include config.h before including this file!"
#endif
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
+#ifdef HAVE_BYTESWAP_H
+#define INT16_SWAP(x) ((int16_t) bswap_16((uint16_t) x))
+#define UINT16_SWAP(x) ((uint16_t) bswap_16((uint16_t) x))
+#define INT32_SWAP(x) ((int32_t) bswap_32((uint32_t) x))
+#define UINT32_SWAP(x) ((uint32_t) bswap_32((uint32_t) x))
+#else
#define INT16_SWAP(x) ( (int16_t) ( ((uint16_t) x >> 8) | ((uint16_t) x << 8) ) )
#define UINT16_SWAP(x) ( (uint16_t) ( ((uint16_t) x >> 8) | ((uint16_t) x << 8) ) )
#define INT32_SWAP(x) ( (int32_t) ( ((uint32_t) x >> 24) | ((uint32_t) x << 24) | (((uint32_t) x & 0xFF00) << 8) | ((((uint32_t) x) >> 8) & 0xFF00) ) )
#define UINT32_SWAP(x) ( (uint32_t) ( ((uint32_t) x >> 24) | ((uint32_t) x << 24) | (((uint32_t) x & 0xFF00) << 8) | ((((uint32_t) x) >> 8) & 0xFF00) ) )
+#endif
#define MAYBE_INT32_SWAP(c,x) ((c) ? INT32_SWAP(x) : x)
#define MAYBE_UINT32_SWAP(c,x) ((c) ? UINT32_SWAP(x) : x)