Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / arch / x86 / include / uapi / asm / swab.h
blob7f235c7105c19713c0a22e2e2ea40ea5579895f0
1 #ifndef _ASM_X86_SWAB_H
2 #define _ASM_X86_SWAB_H
4 #include <linux/types.h>
5 #include <linux/compiler.h>
7 static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
9 asm("bswapl %0" : "=r" (val) : "0" (val));
10 return val;
12 #define __arch_swab32 __arch_swab32
14 static inline __attribute_const__ __u64 __arch_swab64(__u64 val)
16 #ifdef __i386__
17 union {
18 struct {
19 __u32 a;
20 __u32 b;
21 } s;
22 __u64 u;
23 } v;
24 v.u = val;
25 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
26 : "=r" (v.s.a), "=r" (v.s.b)
27 : "0" (v.s.a), "1" (v.s.b));
28 return v.u;
29 #else /* __i386__ */
30 asm("bswapq %0" : "=r" (val) : "0" (val));
31 return val;
32 #endif
34 #define __arch_swab64 __arch_swab64
36 #endif /* _ASM_X86_SWAB_H */