summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-06-02 01:49:00 +0000
committerNeil Brown <neilb@suse.de>2006-06-02 01:49:00 +0000
commitefd441d17b5a6cfab37b60154492aa81c24b7db2 (patch)
tree351f62db2f432469578abcbcd8ecb36d00378120
parenta524a7ee7e104580bc46c4049e3f23c505319f24 (diff)
downloadmdadm-efd441d17b5a6cfab37b60154492aa81c24b7db2.tar.gz
mdadm-efd441d17b5a6cfab37b60154492aa81c24b7db2.tar.xz
mdadm-efd441d17b5a6cfab37b60154492aa81c24b7db2.zip
Finally (I hope) get byteorder stuff portable.
/usr/include/endian.h and /usr/include/byteswap.h together can give us almost what we need... Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--mdadm.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/mdadm.h b/mdadm.h
index 848c6f1..b7ae967 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -73,13 +73,24 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
#include "bitmap.h"
#include <endian.h>
-/* #include "asm/byteorder.h" Redhat don't like this so... */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# include <linux/byteorder/little_endian.h>
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# include <linux/byteorder/big_endian.h>
-#elif __BYTE_ORDER == __PDP_ENDIAN
-# include <linux/byteorder/pdp_endian.h>
+#include <byteswap.h>
+/* Redhat don't like to #include <asm/byteorder.h>, and
+ * some time include <linux/byteorder/xxx_endian.h> isn't enough,
+ * and there is no standard conversion function so... */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define __cpu_to_le16(_x) (_x)
+#define __cpu_to_le32(_x) (_x)
+#define __cpu_to_le64(_x) (_x)
+#define __le16_to_cpu(_x) (_x)
+#define __le32_to_cpu(_x) (_x)
+#define __le64_to_cpu(_x) (_x)
+#elif BYTE_ORDER == BIG_ENDIAN
+#define __cpu_to_le16(_x) bswap_16(_x)
+#define __cpu_to_le32(_x) bswap_32(_x)
+#define __cpu_to_le64(_x) bswap_64(_x)
+#define __le16_to_cpu(_x) bswap_16(_x)
+#define __le32_to_cpu(_x) bswap_32(_x)
+#define __le64_to_cpu(_x) bswap_64(_x)
#else
# error "unknown endianness."
#endif