1 #ifndef _X86_64_PERCPU_H
2 #define _X86_64_PERCPU_H
3 #include <lwk/compiler.h>
5 /* Same as asm-generic/percpu.h, except that we store the per cpu offset
6 in the PDA. Longer term the PDA and every per cpu variable
7 should be just put into a single section and referenced directly
12 #define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
13 #define __my_cpu_offset() read_pda(data_offset)
15 /* Separate out the type, so (int[3], foo) works. */
16 #define DEFINE_PER_CPU(type, name) \
17 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
19 /* var is in discarded region: offset to particular copy we want */
20 #define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
21 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
23 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
25 #endif /* _X86_64_PERCPU_H */