0001
0002 #ifndef _ASM_X86_SWAB_H
0003 #define _ASM_X86_SWAB_H
0004
0005 #include <linux/types.h>
0006 #include <linux/compiler.h>
0007
0008 static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
0009 {
0010 asm("bswapl %0" : "=r" (val) : "0" (val));
0011 return val;
0012 }
0013 #define __arch_swab32 __arch_swab32
0014
0015 static inline __attribute_const__ __u64 __arch_swab64(__u64 val)
0016 {
0017 #ifdef __i386__
0018 union {
0019 struct {
0020 __u32 a;
0021 __u32 b;
0022 } s;
0023 __u64 u;
0024 } v;
0025 v.u = val;
0026 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
0027 : "=r" (v.s.a), "=r" (v.s.b)
0028 : "0" (v.s.a), "1" (v.s.b));
0029 return v.u;
0030 #else
0031 asm("bswapq %0" : "=r" (val) : "0" (val));
0032 return val;
0033 #endif
0034 }
0035 #define __arch_swab64 __arch_swab64
0036
0037 #endif