summaryrefslogtreecommitdiff
path: root/utils/bswap.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-11-21 23:56:34 +0000
committerMike Frysinger <vapier@gentoo.org>2005-11-21 23:56:34 +0000
commitf0daf69b2d5646bb4e22f65a1d22787b6cc2b943 (patch)
treeb86f2496cd0d09ed9c14160da180b243ca43c516 /utils/bswap.h
parent20b2f7bb5e838e1f8bd01608400dd13c5dd17a13 (diff)
fix bswap32/bswap16 macros for non-linux targets as reported by Melange in Bug 553
Diffstat (limited to 'utils/bswap.h')
-rw-r--r--utils/bswap.h28
1 files changed, 12 insertions, 16 deletions
diff --git a/utils/bswap.h b/utils/bswap.h
index 7ca267bdd..6e7f7d336 100644
--- a/utils/bswap.h
+++ b/utils/bswap.h
@@ -32,23 +32,19 @@
#ifdef __linux__
#include <byteswap.h>
#else
-#include <string.h>
-static __inline__ uint32_t bswap_32(uint32_t x)
- {
- uint32_t res;
- swab((void*)&x, (void*)&res, sizeof(uint32_t));
-
- return res;
- }
-
-static __inline__ uint16_t bswap_16(uint16_t x)
- {
- uint16_t res;
-
- swab((void*)&x, (void*)&res, sizeof(uint16_t));
- return res;
- }
+static inline uint32_t bswap_32(uint32_t x)
+{
+ return ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8));
+}
+static inline uint16_t bswap_16(uint16_t x)
+{
+ return ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24));
+}
#endif
#endif