aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/byteorder.h
diff options
context:
space:
mode:
authorMatthew Fioravante <matthew.fioravante@jhuapl.edu>2012-10-08 14:36:29 +0100
committerMatthew Fioravante <matthew.fioravante@jhuapl.edu>2012-10-08 14:36:29 +0100
commit7ab9bbf9f8b922a25eb3d37ff5fd9b6a730bf85c (patch)
tree4edde95b2a64b63bfce840fe45243c977436b6aa /extras/mini-os/include/byteorder.h
parent5691487f3100c5176da4f0acbbb39b09b6180e05 (diff)
downloadxen-7ab9bbf9f8b922a25eb3d37ff5fd9b6a730bf85c.tar.gz
xen-7ab9bbf9f8b922a25eb3d37ff5fd9b6a730bf85c.tar.bz2
xen-7ab9bbf9f8b922a25eb3d37ff5fd9b6a730bf85c.zip
minios: Add endian, byteswap, and wordsize macros to mini-os
This patch addes byte swapping macros and endian support to mini-os. Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'extras/mini-os/include/byteorder.h')
-rw-r--r--extras/mini-os/include/byteorder.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/extras/mini-os/include/byteorder.h b/extras/mini-os/include/byteorder.h
new file mode 100644
index 0000000000..c0e29dfc3b
--- /dev/null
+++ b/extras/mini-os/include/byteorder.h
@@ -0,0 +1,36 @@
+#ifndef MINIOS_BYTEORDER_H
+#define MINIOS_BYTEORDER_H
+
+#include <mini-os/byteswap.h>
+#include <mini-os/endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be16_to_cpu(v) bswap_16(v)
+#define be32_to_cpu(v) bswap_32(v)
+#define be64_to_cpu(v) bswap_64(v)
+
+#define le16_to_cpu(v) (v)
+#define le32_to_cpu(v) (v)
+#define le64_to_cpu(v) (v)
+
+#else /*__BIG_ENDIAN*/
+#define be16_to_cpu(v) (v)
+#define be32_to_cpu(v) (v)
+#define be64_to_cpu(v) (v)
+
+#define le16_to_cpu(v) bswap_16(v)
+#define le32_to_cpu(v) bswap_32(v)
+#define le64_to_cpu(v) bswap_64(v)
+
+#endif
+
+#define cpu_to_be16(v) be16_to_cpu(v)
+#define cpu_to_be32(v) be32_to_cpu(v)
+#define cpu_to_be64(v) be64_to_cpu(v)
+
+#define cpu_to_le16(v) le16_to_cpu(v)
+#define cpu_to_le32(v) le32_to_cpu(v)
+#define cpu_to_le64(v) le64_to_cpu(v)
+
+
+#endif