- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / include / mach-xen / asm / percpu.h
1 #ifndef _ASM_X86_XEN_PERCPU_H
2 #define _ASM_X86_XEN_PERCPU_H
3
4 #include_next <asm/percpu.h>
5
6 #define this_vcpu_read_1 this_cpu_read_1
7 #define this_vcpu_read_2 this_cpu_read_2
8 #define this_vcpu_read_4 this_cpu_read_4
9
10 #ifdef CONFIG_64BIT
11 # define this_vcpu_read_8 this_cpu_read_8
12 #else
13 # define this_vcpu_read_8(pcp) ({ \
14         typeof(pcp) res__; \
15         __asm__ ("movl %%ebx,%%eax\n" \
16                  "movl %%ecx,%%edx\n" \
17                  "cmpxchg8b " __percpu_arg(1) \
18                  : "=&A" (res__) : "m" (pcp)); \
19         res__; })
20 #endif
21
22 #define this_vcpu_read(pcp) __pcpu_size_call_return(this_vcpu_read_, pcp)
23
24 #define percpu_exchange_op(op, var, val)                \
25 ({                                                      \
26         typedef typeof(var) pxo_T__;                    \
27         pxo_T__ pxo_ret__;                              \
28         if (0) {                                        \
29                 pxo_ret__ = (val);                      \
30                 (void)pxo_ret__;                        \
31         }                                               \
32         switch (sizeof(var)) {                          \
33         case 1:                                         \
34                 asm(op "b %0,"__percpu_arg(1)           \
35                     : "=q" (pxo_ret__), "+m" (var)      \
36                     : "0" ((pxo_T__)(val)));            \
37                 break;                                  \
38         case 2:                                         \
39                 asm(op "w %0,"__percpu_arg(1)           \
40                     : "=r" (pxo_ret__), "+m" (var)      \
41                     : "0" ((pxo_T__)(val)));            \
42                 break;                                  \
43         case 4:                                         \
44                 asm(op "l %0,"__percpu_arg(1)           \
45                     : "=r" (pxo_ret__), "+m" (var)      \
46                     : "0" ((pxo_T__)(val)));            \
47                 break;                                  \
48         case 8:                                         \
49                 asm(op "q %0,"__percpu_arg(1)           \
50                     : "=r" (pxo_ret__), "+m" (var)      \
51                     : "0" ((pxo_T__)(val)));            \
52                 break;                                  \
53         default: __bad_percpu_size();                   \
54         }                                               \
55         pxo_ret__;                                      \
56 })
57
58 #define percpu_xchg(var, val)           percpu_exchange_op("xchg", var, val)
59 #define percpu_xadd(var, val)           percpu_exchange_op("xadd", var, val)
60
61 #endif /* _ASM_X86_XEN_PERCPU_H */