diff options
Diffstat (limited to 'include/asm-generic/bug.h')
| -rw-r--r-- | include/asm-generic/bug.h | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 0cd9711895fa..a5250895155e 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
| @@ -16,12 +16,15 @@ | |||
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #ifndef HAVE_ARCH_WARN_ON | 18 | #ifndef HAVE_ARCH_WARN_ON |
| 19 | #define WARN_ON(condition) do { \ | 19 | #define WARN_ON(condition) ({ \ |
| 20 | if (unlikely((condition)!=0)) { \ | 20 | typeof(condition) __ret_warn_on = (condition); \ |
| 21 | printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \ | 21 | if (unlikely(__ret_warn_on)) { \ |
| 22 | dump_stack(); \ | 22 | printk("BUG: warning at %s:%d/%s()\n", __FILE__, \ |
| 23 | } \ | 23 | __LINE__, __FUNCTION__); \ |
| 24 | } while (0) | 24 | dump_stack(); \ |
| 25 | } \ | ||
| 26 | unlikely(__ret_warn_on); \ | ||
| 27 | }) | ||
| 25 | #endif | 28 | #endif |
| 26 | 29 | ||
| 27 | #else /* !CONFIG_BUG */ | 30 | #else /* !CONFIG_BUG */ |
| @@ -34,8 +37,24 @@ | |||
| 34 | #endif | 37 | #endif |
| 35 | 38 | ||
| 36 | #ifndef HAVE_ARCH_WARN_ON | 39 | #ifndef HAVE_ARCH_WARN_ON |
| 37 | #define WARN_ON(condition) do { if (condition) ; } while(0) | 40 | #define WARN_ON(condition) unlikely((condition)) |
| 41 | #endif | ||
| 38 | #endif | 42 | #endif |
| 43 | |||
| 44 | #define WARN_ON_ONCE(condition) ({ \ | ||
| 45 | static int __warn_once = 1; \ | ||
| 46 | typeof(condition) __ret_warn_once = (condition);\ | ||
| 47 | \ | ||
| 48 | if (likely(__warn_once)) \ | ||
| 49 | if (WARN_ON(__ret_warn_once)) \ | ||
| 50 | __warn_once = 0; \ | ||
| 51 | unlikely(__ret_warn_once); \ | ||
| 52 | }) | ||
| 53 | |||
| 54 | #ifdef CONFIG_SMP | ||
| 55 | # define WARN_ON_SMP(x) WARN_ON(x) | ||
| 56 | #else | ||
| 57 | # define WARN_ON_SMP(x) do { } while (0) | ||
| 39 | #endif | 58 | #endif |
| 40 | 59 | ||
| 41 | #endif | 60 | #endif |
