x86: merge byteorder_32/64.h

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+70 -104
-2
include/asm-x86/Kbuild
··· 11 header-y += ucontext.h 12 header-y += vsyscall32.h 13 14 - unifdef-y += byteorder_32.h 15 - unifdef-y += byteorder_64.h 16 unifdef-y += e820.h 17 unifdef-y += elf_32.h 18 unifdef-y += elf_64.h
··· 11 header-y += ucontext.h 12 header-y += vsyscall32.h 13 14 unifdef-y += e820.h 15 unifdef-y += elf_32.h 16 unifdef-y += elf_64.h
+70 -11
include/asm-x86/byteorder.h
··· 1 - #ifdef __KERNEL__ 2 - # ifdef CONFIG_X86_32 3 - # include "byteorder_32.h" 4 - # else 5 - # include "byteorder_64.h" 6 - # endif 7 #else 8 - # ifdef __i386__ 9 - # include "byteorder_32.h" 10 - # else 11 - # include "byteorder_64.h" 12 - # endif 13 #endif
··· 1 + #ifndef _ASM_X86_BYTEORDER_H 2 + #define _ASM_X86_BYTEORDER_H 3 + 4 + #include <asm/types.h> 5 + #include <linux/compiler.h> 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)); 15 #else 16 + __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ 17 + "rorl $16,%0\n\t" /* swap words */ 18 + "xchgb %b0,%h0" /* swap higher bytes */ 19 + :"=q" (x) 20 + : "0" (x)); 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 */
-58
include/asm-x86/byteorder_32.h
··· 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 */
···
-33
include/asm-x86/byteorder_64.h
··· 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 */
···