aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/byteorder.h
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-17 12:11:02 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-01-17 12:11:02 +0000
commit201c511f5a11b2317070146dd5f83f1832fc45f5 (patch)
tree93ec73e84a481d125f8e95f7cc68d90a2aaa685d /xen/include/asm-x86/byteorder.h
parentd74f5aa06311f5bb5ee39d0fbd32707336cf61d0 (diff)
downloadxen-201c511f5a11b2317070146dd5f83f1832fc45f5.tar.gz
xen-201c511f5a11b2317070146dd5f83f1832fc45f5.tar.bz2
xen-201c511f5a11b2317070146dd5f83f1832fc45f5.zip
[XEN] Include byteorder functions from Linux.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/include/asm-x86/byteorder.h')
-rw-r--r--xen/include/asm-x86/byteorder.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/xen/include/asm-x86/byteorder.h b/xen/include/asm-x86/byteorder.h
new file mode 100644
index 0000000000..eb52ae2f11
--- /dev/null
+++ b/xen/include/asm-x86/byteorder.h
@@ -0,0 +1,36 @@
+#ifndef __ASM_X86_BYTEORDER_H__
+#define __ASM_X86_BYTEORDER_H__
+
+#include <asm/types.h>
+#include <xen/compiler.h>
+
+static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
+{
+ asm("bswap %0" : "=r" (x) : "0" (x));
+ return x;
+}
+
+static inline __attribute_const__ __u64 ___arch__swab64(__u64 val)
+{
+ union {
+ struct { __u32 a,b; } s;
+ __u64 u;
+ } v;
+ v.u = val;
+ asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
+ : "=r" (v.s.a), "=r" (v.s.b)
+ : "0" (v.s.a), "1" (v.s.b));
+ return v.u;
+}
+
+/* Do not define swab16. Gcc is smart enough to recognize "C" version and
+ convert it into rotation or exhange. */
+
+#define __arch__swab64(x) ___arch__swab64(x)
+#define __arch__swab32(x) ___arch__swab32(x)
+
+#define __BYTEORDER_HAS_U64__
+
+#include <xen/byteorder/little_endian.h>
+
+#endif /* __ASM_X86_BYTEORDER_H__ */