summaryrefslogtreecommitdiff
path: root/src/radeon_macros.h
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2008-06-25 17:09:11 +1000
committerDave Airlie <airlied@linux.ie>2008-06-25 17:09:11 +1000
commit52459745ec05de88adbc087e9566fe6d97ef424b (patch)
treeeb37849461f6bfcfc8b91225a75d0140f76a718b /src/radeon_macros.h
parent67a6ac0001bc9d062aa426384a11a41fa7a1c09a (diff)
ati: hopefully fix byteswap mess for those other OSes.
Diffstat (limited to 'src/radeon_macros.h')
-rw-r--r--src/radeon_macros.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/radeon_macros.h b/src/radeon_macros.h
index 3675dc51..afe442ea 100644
--- a/src/radeon_macros.h
+++ b/src/radeon_macros.h
@@ -51,7 +51,23 @@
#include "compiler.h"
+#if HAVE_BYTESWAP_H
#include <byteswap.h>
+#elif defined(USE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#else
+#define bswap_16(value) \
+ ((((value) & 0xff) << 8) | ((value) >> 8))
+
+#define bswap_32(value) \
+ (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
+ (uint32_t)bswap_16((uint16_t)((value) >> 16)))
+
+#define bswap_64(value) \
+ (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
+ << 32) | \
+ (uint64_t)bswap_32((uint32_t)((value) >> 32)))
+#endif
#if X_BYTE_ORDER == X_BIG_ENDIAN
#define le32_to_cpu(x) bswap_32(x)