diff options
Diffstat (limited to 'include/asm-generic/bug.h')
-rw-r--r-- | include/asm-generic/bug.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index c2c9ba032d46..e5a3f5880001 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -165,10 +165,43 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
165 | #define WARN_ON_RATELIMIT(condition, state) \ | 165 | #define WARN_ON_RATELIMIT(condition, state) \ |
166 | WARN_ON((condition) && __ratelimit(state)) | 166 | WARN_ON((condition) && __ratelimit(state)) |
167 | 167 | ||
168 | /* | ||
169 | * WARN_ON_SMP() is for cases that the warning is either | ||
170 | * meaningless for !SMP or may even cause failures. | ||
171 | * This is usually used for cases that we have | ||
172 | * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked() | ||
173 | * returns 0 for uniprocessor settings. | ||
174 | * It can also be used with values that are only defined | ||
175 | * on SMP: | ||
176 | * | ||
177 | * struct foo { | ||
178 | * [...] | ||
179 | * #ifdef CONFIG_SMP | ||
180 | * int bar; | ||
181 | * #endif | ||
182 | * }; | ||
183 | * | ||
184 | * void func(struct foo *zoot) | ||
185 | * { | ||
186 | * WARN_ON_SMP(!zoot->bar); | ||
187 | * | ||
188 | * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(), | ||
189 | * and should be a nop and return false for uniprocessor. | ||
190 | * | ||
191 | * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set | ||
192 | * and x is true. | ||
193 | */ | ||
168 | #ifdef CONFIG_SMP | 194 | #ifdef CONFIG_SMP |
169 | # define WARN_ON_SMP(x) WARN_ON(x) | 195 | # define WARN_ON_SMP(x) WARN_ON(x) |
170 | #else | 196 | #else |
171 | # define WARN_ON_SMP(x) do { } while (0) | 197 | /* |
198 | * Use of ({0;}) because WARN_ON_SMP(x) may be used either as | ||
199 | * a stand alone line statement or as a condition in an if () | ||
200 | * statement. | ||
201 | * A simple "0" would cause gcc to give a "statement has no effect" | ||
202 | * warning. | ||
203 | */ | ||
204 | # define WARN_ON_SMP(x) ({0;}) | ||
172 | #endif | 205 | #endif |
173 | 206 | ||
174 | #endif | 207 | #endif |