patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / asm-s390 / percpu.h
1 #ifndef __ARCH_S390_PERCPU__
2 #define __ARCH_S390_PERCPU__
3
4 #include <asm-generic/percpu.h>
5 #include <asm/lowcore.h>
6
7 /*
8  * For builtin kernel code s390 uses the generic implementation for
9  * per cpu data, with the exception that the offset of the cpu local
10  * data area is cached in the cpu's lowcore memory
11  * For 64 bit module code s390 forces the use of a GOT slot for the
12  * address of the per cpu variable. This is needed because the module
13  * may be more than 4G above the per cpu area.
14  */
15 #if defined(__s390x__) && defined(MODULE)
16 #define __get_got_cpu_var(var,offset) \
17   (*({ unsigned long *__ptr; \
18        asm ( "larl %0,per_cpu__"#var"@GOTENT" : "=a" (__ptr) ); \
19        ((typeof(&per_cpu__##var))((*__ptr) + offset)); \
20     }))
21 #undef __get_cpu_var
22 #define __get_cpu_var(var) __get_got_cpu_var(var,S390_lowcore.percpu_offset)
23 #undef per_cpu
24 #define per_cpu(var,cpu) __get_got_cpu_var(var,__per_cpu_offset[cpu])
25 #else
26 #undef __get_cpu_var
27 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, S390_lowcore.percpu_offset))
28 #endif
29
30 #endif /* __ARCH_S390_PERCPU__ */