Merge branches 'tracing/kmemtrace2' and 'tracing/ftrace' into tracing/urgent
[deliverable/linux.git] / arch / x86 / include / asm / byteorder.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_BYTEORDER_H
2#define _ASM_X86_BYTEORDER_H
acbbbe9f
TG
3
4#include <asm/types.h>
5#include <linux/compiler.h>
6
ad38dab0 7#define __LITTLE_ENDIAN
acbbbe9f 8
ad38dab0 9static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
acbbbe9f 10{
ad38dab0
HH
11#ifdef __i386__
12# ifdef CONFIG_X86_BSWAP
13 asm("bswap %0" : "=r" (val) : "0" (val));
14# else
34605095
JP
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 */
ad38dab0
HH
18 : "=q" (val)
19 : "0" (val));
20# endif
21
22#else /* __i386__ */
23 asm("bswapl %0"
24 : "=r" (val)
25 : "0" (val));
96a388de 26#endif
ad38dab0 27 return val;
acbbbe9f 28}
ad38dab0 29#define __arch_swab32 __arch_swab32
acbbbe9f 30
ad38dab0 31static inline __attribute_const__ __u64 __arch_swab64(__u64 val)
acbbbe9f 32{
ad38dab0 33#ifdef __i386__
acbbbe9f 34 union {
34605095
JP
35 struct {
36 __u32 a;
37 __u32 b;
38 } s;
acbbbe9f
TG
39 __u64 u;
40 } v;
41 v.u = val;
ad38dab0 42# ifdef CONFIG_X86_BSWAP
34605095 43 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
acbbbe9f
TG
44 : "=r" (v.s.a), "=r" (v.s.b)
45 : "0" (v.s.a), "1" (v.s.b));
ad38dab0
HH
46# else
47 v.s.a = __arch_swab32(v.s.a);
48 v.s.b = __arch_swab32(v.s.b);
34605095
JP
49 asm("xchgl %0,%1"
50 : "=r" (v.s.a), "=r" (v.s.b)
51 : "0" (v.s.a), "1" (v.s.b));
ad38dab0 52# endif
acbbbe9f 53 return v.u;
acbbbe9f 54#else /* __i386__ */
34605095 55 asm("bswapq %0"
ad38dab0
HH
56 : "=r" (val)
57 : "0" (val));
58 return val;
acbbbe9f 59#endif
ad38dab0
HH
60}
61#define __arch_swab64 __arch_swab64
acbbbe9f 62
ad38dab0 63#include <linux/byteorder.h>
acbbbe9f 64
1965aae3 65#endif /* _ASM_X86_BYTEORDER_H */
This page took 0.149928 seconds and 5 git commands to generate.