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