diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2009-01-06 17:56:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 21:10:27 -0500 |
commit | 5d30a683888c60b8f93bef3ddc139d1a91ca58f4 (patch) | |
tree | 4cd79bc83d2c97bc95a934b0251757d2170b0140 /arch/x86/include/asm/byteorder.h | |
parent | f4d2b14501bb7f9a3fa75c07ec0940068fadf728 (diff) |
x86: introduce asm/swab.h
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/include/asm/byteorder.h')
-rw-r--r-- | arch/x86/include/asm/byteorder.h | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/arch/x86/include/asm/byteorder.h b/arch/x86/include/asm/byteorder.h index f110ad417df3..7c49917e3d9d 100644 --- a/arch/x86/include/asm/byteorder.h +++ b/arch/x86/include/asm/byteorder.h | |||
@@ -1,65 +1,7 @@ | |||
1 | #ifndef _ASM_X86_BYTEORDER_H | 1 | #ifndef _ASM_X86_BYTEORDER_H |
2 | #define _ASM_X86_BYTEORDER_H | 2 | #define _ASM_X86_BYTEORDER_H |
3 | 3 | ||
4 | #include <asm/types.h> | 4 | #include <asm/swab.h> |
5 | #include <linux/compiler.h> | 5 | #include <linux/byteorder/little_endian.h> |
6 | |||
7 | #define __LITTLE_ENDIAN | ||
8 | |||
9 | static inline __attribute_const__ __u32 __arch_swab32(__u32 val) | ||
10 | { | ||
11 | #ifdef __i386__ | ||
12 | # ifdef CONFIG_X86_BSWAP | ||
13 | asm("bswap %0" : "=r" (val) : "0" (val)); | ||
14 | # else | ||
15 | asm("xchgb %b0,%h0\n\t" /* swap lower bytes */ | ||
16 | "rorl $16,%0\n\t" /* swap words */ | ||
17 | "xchgb %b0,%h0" /* swap higher bytes */ | ||
18 | : "=q" (val) | ||
19 | : "0" (val)); | ||
20 | # endif | ||
21 | |||
22 | #else /* __i386__ */ | ||
23 | asm("bswapl %0" | ||
24 | : "=r" (val) | ||
25 | : "0" (val)); | ||
26 | #endif | ||
27 | return val; | ||
28 | } | ||
29 | #define __arch_swab32 __arch_swab32 | ||
30 | |||
31 | static inline __attribute_const__ __u64 __arch_swab64(__u64 val) | ||
32 | { | ||
33 | #ifdef __i386__ | ||
34 | union { | ||
35 | struct { | ||
36 | __u32 a; | ||
37 | __u32 b; | ||
38 | } s; | ||
39 | __u64 u; | ||
40 | } v; | ||
41 | v.u = val; | ||
42 | # ifdef CONFIG_X86_BSWAP | ||
43 | asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" | ||
44 | : "=r" (v.s.a), "=r" (v.s.b) | ||
45 | : "0" (v.s.a), "1" (v.s.b)); | ||
46 | # else | ||
47 | v.s.a = __arch_swab32(v.s.a); | ||
48 | v.s.b = __arch_swab32(v.s.b); | ||
49 | asm("xchgl %0,%1" | ||
50 | : "=r" (v.s.a), "=r" (v.s.b) | ||
51 | : "0" (v.s.a), "1" (v.s.b)); | ||
52 | # endif | ||
53 | return v.u; | ||
54 | #else /* __i386__ */ | ||
55 | asm("bswapq %0" | ||
56 | : "=r" (val) | ||
57 | : "0" (val)); | ||
58 | return val; | ||
59 | #endif | ||
60 | } | ||
61 | #define __arch_swab64 __arch_swab64 | ||
62 | |||
63 | #include <linux/byteorder.h> | ||
64 | 6 | ||
65 | #endif /* _ASM_X86_BYTEORDER_H */ | 7 | #endif /* _ASM_X86_BYTEORDER_H */ |