Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_BUG_H |
| 2 | #define _ASM_GENERIC_BUG_H |
| 3 | |
| 4 | #include <linux/compiler.h> |
| 5 | #include <linux/config.h> |
| 6 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 7 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #ifndef HAVE_ARCH_BUG |
| 9 | #define BUG() do { \ |
| 10 | printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ |
| 11 | panic("BUG!"); \ |
| 12 | } while (0) |
| 13 | #endif |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #ifndef HAVE_ARCH_BUG_ON |
| 16 | #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) |
| 17 | #endif |
| 18 | |
| 19 | #ifndef HAVE_ARCH_WARN_ON |
| 20 | #define WARN_ON(condition) do { \ |
| 21 | if (unlikely((condition)!=0)) { \ |
| 22 | printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ |
| 23 | dump_stack(); \ |
| 24 | } \ |
| 25 | } while (0) |
| 26 | #endif |
| 27 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 28 | #else /* !CONFIG_BUG */ |
| 29 | #ifndef HAVE_ARCH_BUG |
| 30 | #define BUG() |
| 31 | #endif |
| 32 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 33 | #ifndef HAVE_ARCH_BUG_ON |
| 34 | #define BUG_ON(condition) do { if (condition) ; } while(0) |
| 35 | #endif |
| 36 | |
| 37 | #ifndef HAVE_ARCH_WARN_ON |
| 38 | #define WARN_ON(condition) do { if (condition) ; } while(0) |
| 39 | #endif |
| 40 | #endif |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #endif |