From 9db42672d466ceec4f3d69f03e2d72ea18a8d62e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 22 Sep 2007 00:21:08 +0000 Subject: 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 --- src/pulsecore/endianmacros.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/pulsecore/endianmacros.h') 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 +#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) -- cgit