summaryrefslogtreecommitdiffstats
path: root/include/linux/percpu.h
diff options
context:
space:
mode:
authorJan Blunck <jblunck@suse.de>2006-09-25 23:30:53 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 08:48:44 -0700
commit632bbfeee4f042c05bc65150b4433a297d3fe387 (patch)
treece67b5fa4bec38610fc0ecb9b20be6aa69763bb3 /include/linux/percpu.h
parent0a2966b48fb784e437520e400ddc94874ddbd4e8 (diff)
downloadop-kernel-dev-632bbfeee4f042c05bc65150b4433a297d3fe387.zip
op-kernel-dev-632bbfeee4f042c05bc65150b4433a297d3fe387.tar.gz
[PATCH] trigger a syntax error if percpu macros are incorrectly used
get_cpu_var()/per_cpu()/__get_cpu_var() arguments must be simple identifiers. Otherwise the arch dependent implementations might break. This patch enforces the correct usage of the macros by producing a syntax error if the variable is not a simple identifier. Signed-off-by: Jan Blunck <jblunck@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/percpu.h')
-rw-r--r--include/linux/percpu.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index cb9039a..f926490 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -11,8 +11,14 @@
#define PERCPU_ENOUGH_ROOM 32768
#endif
-/* Must be an lvalue. */
-#define get_cpu_var(var) (*({ preempt_disable(); &__get_cpu_var(var); }))
+/*
+ * Must be an lvalue. Since @var must be a simple identifier,
+ * we force a syntax error here if it isn't.
+ */
+#define get_cpu_var(var) (*({ \
+ extern int simple_indentifier_##var(void); \
+ preempt_disable(); \
+ &__get_cpu_var(var); }))
#define put_cpu_var(var) preempt_enable()
#ifdef CONFIG_SMP
OpenPOWER on IntegriCloud