diff options
-rw-r--r-- | include/asm-x86/Kbuild | 2 | ||||
-rw-r--r-- | include/asm-x86/byteorder.h | 81 | ||||
-rw-r--r-- | include/asm-x86/byteorder_32.h | 58 | ||||
-rw-r--r-- | include/asm-x86/byteorder_64.h | 33 |
4 files changed, 70 insertions, 104 deletions
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild index 435074af1987..26b0dcda5ace 100644 --- a/include/asm-x86/Kbuild +++ b/include/asm-x86/Kbuild | |||
@@ -11,8 +11,6 @@ header-y += sigcontext32.h | |||
11 | header-y += ucontext.h | 11 | header-y += ucontext.h |
12 | header-y += vsyscall32.h | 12 | header-y += vsyscall32.h |
13 | 13 | ||
14 | unifdef-y += byteorder_32.h | ||
15 | unifdef-y += byteorder_64.h | ||
16 | unifdef-y += e820.h | 14 | unifdef-y += e820.h |
17 | unifdef-y += elf_32.h | 15 | unifdef-y += elf_32.h |
18 | unifdef-y += elf_64.h | 16 | unifdef-y += elf_64.h |
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h index eb14b1870ed7..1f2d6d5bf20d 100644 --- a/include/asm-x86/byteorder.h +++ b/include/asm-x86/byteorder.h | |||
@@ -1,13 +1,72 @@ | |||
1 | #ifdef __KERNEL__ | 1 | #ifndef _ASM_X86_BYTEORDER_H |
2 | # ifdef CONFIG_X86_32 | 2 | #define _ASM_X86_BYTEORDER_H |
3 | # include "byteorder_32.h" | 3 | |
4 | # else | 4 | #include <asm/types.h> |
5 | # include "byteorder_64.h" | 5 | #include <linux/compiler.h> |
6 | # endif | 6 | |
7 | #ifdef __GNUC__ | ||
8 | |||
9 | #ifdef __i386__ | ||
10 | |||
11 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
12 | { | ||
13 | #ifdef CONFIG_X86_BSWAP | ||
14 | __asm__("bswap %0" : "=r" (x) : "0" (x)); | ||
7 | #else | 15 | #else |
8 | # ifdef __i386__ | 16 | __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ |
9 | # include "byteorder_32.h" | 17 | "rorl $16,%0\n\t" /* swap words */ |
10 | # else | 18 | "xchgb %b0,%h0" /* swap higher bytes */ |
11 | # include "byteorder_64.h" | 19 | :"=q" (x) |
12 | # endif | 20 | : "0" (x)); |
13 | #endif | 21 | #endif |
22 | return x; | ||
23 | } | ||
24 | |||
25 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) | ||
26 | { | ||
27 | union { | ||
28 | struct { __u32 a,b; } s; | ||
29 | __u64 u; | ||
30 | } v; | ||
31 | v.u = val; | ||
32 | #ifdef CONFIG_X86_BSWAP | ||
33 | asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" | ||
34 | : "=r" (v.s.a), "=r" (v.s.b) | ||
35 | : "0" (v.s.a), "1" (v.s.b)); | ||
36 | #else | ||
37 | v.s.a = ___arch__swab32(v.s.a); | ||
38 | v.s.b = ___arch__swab32(v.s.b); | ||
39 | asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); | ||
40 | #endif | ||
41 | return v.u; | ||
42 | } | ||
43 | |||
44 | #else /* __i386__ */ | ||
45 | |||
46 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) | ||
47 | { | ||
48 | __asm__("bswapq %0" : "=r" (x) : "0" (x)); | ||
49 | return x; | ||
50 | } | ||
51 | |||
52 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
53 | { | ||
54 | __asm__("bswapl %0" : "=r" (x) : "0" (x)); | ||
55 | return x; | ||
56 | } | ||
57 | |||
58 | #endif | ||
59 | |||
60 | /* Do not define swab16. Gcc is smart enough to recognize "C" version and | ||
61 | convert it into rotation or exhange. */ | ||
62 | |||
63 | #define __arch__swab64(x) ___arch__swab64(x) | ||
64 | #define __arch__swab32(x) ___arch__swab32(x) | ||
65 | |||
66 | #define __BYTEORDER_HAS_U64__ | ||
67 | |||
68 | #endif /* __GNUC__ */ | ||
69 | |||
70 | #include <linux/byteorder/little_endian.h> | ||
71 | |||
72 | #endif /* _ASM_X86_BYTEORDER_H */ | ||
diff --git a/include/asm-x86/byteorder_32.h b/include/asm-x86/byteorder_32.h deleted file mode 100644 index a45470a8b74a..000000000000 --- a/include/asm-x86/byteorder_32.h +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | #ifndef _I386_BYTEORDER_H | ||
2 | #define _I386_BYTEORDER_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | #ifdef __GNUC__ | ||
8 | |||
9 | /* For avoiding bswap on i386 */ | ||
10 | #ifdef __KERNEL__ | ||
11 | #endif | ||
12 | |||
13 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
14 | { | ||
15 | #ifdef CONFIG_X86_BSWAP | ||
16 | __asm__("bswap %0" : "=r" (x) : "0" (x)); | ||
17 | #else | ||
18 | __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ | ||
19 | "rorl $16,%0\n\t" /* swap words */ | ||
20 | "xchgb %b0,%h0" /* swap higher bytes */ | ||
21 | :"=q" (x) | ||
22 | : "0" (x)); | ||
23 | #endif | ||
24 | return x; | ||
25 | } | ||
26 | |||
27 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) | ||
28 | { | ||
29 | union { | ||
30 | struct { __u32 a,b; } s; | ||
31 | __u64 u; | ||
32 | } v; | ||
33 | v.u = val; | ||
34 | #ifdef CONFIG_X86_BSWAP | ||
35 | asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" | ||
36 | : "=r" (v.s.a), "=r" (v.s.b) | ||
37 | : "0" (v.s.a), "1" (v.s.b)); | ||
38 | #else | ||
39 | v.s.a = ___arch__swab32(v.s.a); | ||
40 | v.s.b = ___arch__swab32(v.s.b); | ||
41 | asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); | ||
42 | #endif | ||
43 | return v.u; | ||
44 | } | ||
45 | |||
46 | /* Do not define swab16. Gcc is smart enough to recognize "C" version and | ||
47 | convert it into rotation or exhange. */ | ||
48 | |||
49 | #define __arch__swab64(x) ___arch__swab64(x) | ||
50 | #define __arch__swab32(x) ___arch__swab32(x) | ||
51 | |||
52 | #define __BYTEORDER_HAS_U64__ | ||
53 | |||
54 | #endif /* __GNUC__ */ | ||
55 | |||
56 | #include <linux/byteorder/little_endian.h> | ||
57 | |||
58 | #endif /* _I386_BYTEORDER_H */ | ||
diff --git a/include/asm-x86/byteorder_64.h b/include/asm-x86/byteorder_64.h deleted file mode 100644 index 5e86c868c75e..000000000000 --- a/include/asm-x86/byteorder_64.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #ifndef _X86_64_BYTEORDER_H | ||
2 | #define _X86_64_BYTEORDER_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <linux/compiler.h> | ||
6 | |||
7 | #ifdef __GNUC__ | ||
8 | |||
9 | static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) | ||
10 | { | ||
11 | __asm__("bswapq %0" : "=r" (x) : "0" (x)); | ||
12 | return x; | ||
13 | } | ||
14 | |||
15 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | ||
16 | { | ||
17 | __asm__("bswapl %0" : "=r" (x) : "0" (x)); | ||
18 | return x; | ||
19 | } | ||
20 | |||
21 | /* Do not define swab16. Gcc is smart enough to recognize "C" version and | ||
22 | convert it into rotation or exhange. */ | ||
23 | |||
24 | #define __arch__swab32(x) ___arch__swab32(x) | ||
25 | #define __arch__swab64(x) ___arch__swab64(x) | ||
26 | |||
27 | #endif /* __GNUC__ */ | ||
28 | |||
29 | #define __BYTEORDER_HAS_U64__ | ||
30 | |||
31 | #include <linux/byteorder/little_endian.h> | ||
32 | |||
33 | #endif /* _X86_64_BYTEORDER_H */ | ||