mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[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>
This commit is contained in:
parent
0a2966b48f
commit
632bbfeee4
4 changed files with 31 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue