1 #ifndef __ASM_X86_BYTEORDER_H__
2 #define __ASM_X86_BYTEORDER_H__
3 
4 #include <asm/types.h>
5 #include <xen/compiler.h>
6 
___arch__swab32(__u32 x)7 static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
8 {
9     asm("bswap %0" : "=r" (x) : "0" (x));
10     return x;
11 }
12 
___arch__swab64(__u64 val)13 static inline __attribute_const__ __u64 ___arch__swab64(__u64 val)
14 {
15     union {
16         struct { __u32 a,b; } s;
17         __u64 u;
18     } v;
19     v.u = val;
20     asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
21         : "=r" (v.s.a), "=r" (v.s.b)
22         : "0" (v.s.a), "1" (v.s.b));
23     return v.u;
24 }
25 
26 /* Do not define swab16.  Gcc is smart enough to recognize "C" version and
27    convert it into rotation or exhange.  */
28 
29 #define __arch__swab64(x) ___arch__swab64(x)
30 #define __arch__swab32(x) ___arch__swab32(x)
31 
32 #define __BYTEORDER_HAS_U64__
33 
34 #include <xen/byteorder/little_endian.h>
35 
36 #endif /* __ASM_X86_BYTEORDER_H__ */
37