blob: 1a565a9d2fa72f0860fb4496eb2454f88b1e4556 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_GENERIC_BUG_H
2#define _ASM_GENERIC_BUG_H
3
4#include <linux/compiler.h>
5#include <linux/config.h>
6
Matt Mackallc8538a72005-05-01 08:59:01 -07007#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#ifndef HAVE_ARCH_BUG
9#define BUG() do { \
Ingo Molnar91368d72006-03-23 03:00:54 -080010 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 panic("BUG!"); \
12} while (0)
13#endif
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#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)) { \
Ingo Molnar91368d72006-03-23 03:00:54 -080022 printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 dump_stack(); \
24 } \
25} while (0)
26#endif
27
Matt Mackallc8538a72005-05-01 08:59:01 -070028#else /* !CONFIG_BUG */
29#ifndef HAVE_ARCH_BUG
30#define BUG()
31#endif
32
Matt Mackallc8538a72005-05-01 08:59:01 -070033#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 Torvalds1da177e2005-04-16 15:20:36 -070042#endif