aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2007-10-23 16:37:23 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-23 16:37:23 -0400
commitacbbbe9f5ab52da90a8edec02ec973e7f44dae81 (patch)
tree464bc5bc0358122f0d1135f6f54b58ca1a3cef84 /include
parentd88203d1ab225f208c3f70cf21b025f427245c79 (diff)
x86: merge byteorder_32/64.h
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/asm-x86/Kbuild2
-rw-r--r--include/asm-x86/byteorder.h81
-rw-r--r--include/asm-x86/byteorder_32.h58
-rw-r--r--include/asm-x86/byteorder_64.h33
4 files changed, 70 insertions, 104 deletions
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild
index 435074af198..26b0dcda5ac 100644
--- a/include/asm-x86/Kbuild
+++ b/include/asm-x86/Kbuild
@@ -11,8 +11,6 @@ header-y += sigcontext32.h
11header-y += ucontext.h 11header-y += ucontext.h
12header-y += vsyscall32.h 12header-y += vsyscall32.h
13 13
14unifdef-y += byteorder_32.h
15unifdef-y += byteorder_64.h
16unifdef-y += e820.h 14unifdef-y += e820.h
17unifdef-y += elf_32.h 15unifdef-y += elf_32.h
18unifdef-y += elf_64.h 16unifdef-y += elf_64.h
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h
index eb14b1870ed..1f2d6d5bf20 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
11static __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
25static __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
46static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
47{
48 __asm__("bswapq %0" : "=r" (x) : "0" (x));
49 return x;
50}
51
52static __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 a45470a8b74..00000000000
--- 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
13static __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
27static __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 5e86c868c75..00000000000
--- 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
9static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
10{
11 __asm__("bswapq %0" : "=r" (x) : "0" (x));
12 return x;
13}
14
15static __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 */