Blame view
include/asm-generic/percpu.h
1.77 KB
1da177e4c
|
1 2 3 |
#ifndef _ASM_GENERIC_PERCPU_H_ #define _ASM_GENERIC_PERCPU_H_ #include <linux/compiler.h> |
ae1ee11be
|
4 |
#include <linux/threads.h> |
1da177e4c
|
5 6 7 8 9 |
#define __GENERIC_PER_CPU #ifdef CONFIG_SMP extern unsigned long __per_cpu_offset[NR_CPUS]; |
a875a69f8
|
10 |
#define per_cpu_offset(x) (__per_cpu_offset[x]) |
1da177e4c
|
11 12 13 |
/* Separate out the type, so (int[3], foo) works. */ #define DEFINE_PER_CPU(type, name) \ __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name |
5fb7dc37d
|
14 15 16 17 |
#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ __attribute__((__section__(".data.percpu.shared_aligned"))) \ __typeof__(type) per_cpu__##name \ ____cacheline_aligned_in_smp |
1da177e4c
|
18 |
/* var is in discarded region: offset to particular copy we want */ |
632bbfeee
|
19 |
#define per_cpu(var, cpu) (*({ \ |
a666ecfbf
|
20 |
extern int simple_identifier_##var(void); \ |
632bbfeee
|
21 |
RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); })) |
1da177e4c
|
22 |
#define __get_cpu_var(var) per_cpu(var, smp_processor_id()) |
bfe5d8341
|
23 |
#define __raw_get_cpu_var(var) per_cpu(var, raw_smp_processor_id()) |
1da177e4c
|
24 25 26 27 28 |
/* A macro to avoid #include hell... */ #define percpu_modcopy(pcpudst, src, size) \ do { \ unsigned int __i; \ |
0a9450227
|
29 |
for_each_possible_cpu(__i) \ |
394e3902c
|
30 31 |
memcpy((pcpudst)+__per_cpu_offset[__i], \ (src), (size)); \ |
1da177e4c
|
32 33 34 35 36 |
} while (0) #else /* ! SMP */ #define DEFINE_PER_CPU(type, name) \ __typeof__(type) per_cpu__##name |
5fb7dc37d
|
37 38 |
#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ DEFINE_PER_CPU(type, name) |
11c80c836
|
39 |
#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var)) |
1da177e4c
|
40 |
#define __get_cpu_var(var) per_cpu__##var |
bfe5d8341
|
41 |
#define __raw_get_cpu_var(var) per_cpu__##var |
1da177e4c
|
42 43 44 45 46 47 48 49 50 |
#endif /* SMP */ #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) #endif /* _ASM_GENERIC_PERCPU_H_ */ |