blob: 845cb67ad8ea5d40bcb707462d30879255247b81 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Matt Mackallc8538a72005-05-01 08:59:01 -07006#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#ifndef HAVE_ARCH_BUG
8#define BUG() do { \
Ingo Molnar91368d72006-03-23 03:00:54 -08009 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 panic("BUG!"); \
11} while (0)
12#endif
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#ifndef HAVE_ARCH_BUG_ON
15#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
16#endif
17
18#ifndef HAVE_ARCH_WARN_ON
19#define WARN_ON(condition) do { \
20 if (unlikely((condition)!=0)) { \
Ingo Molnar91368d72006-03-23 03:00:54 -080021 printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 dump_stack(); \
23 } \
24} while (0)
25#endif
26
Matt Mackallc8538a72005-05-01 08:59:01 -070027#else /* !CONFIG_BUG */
28#ifndef HAVE_ARCH_BUG
29#define BUG()
30#endif
31
Matt Mackallc8538a72005-05-01 08:59:01 -070032#ifndef HAVE_ARCH_BUG_ON
33#define BUG_ON(condition) do { if (condition) ; } while(0)
34#endif
35
36#ifndef HAVE_ARCH_WARN_ON
37#define WARN_ON(condition) do { if (condition) ; } while(0)
38#endif
39#endif
40
Ingo Molnar74bb6a02006-06-25 05:48:09 -070041#define WARN_ON_ONCE(condition) \
42({ \
43 static int __warn_once = 1; \
44 int __ret = 0; \
45 \
46 if (unlikely((condition) && __warn_once)) { \
47 __warn_once = 0; \
48 WARN_ON(1); \
49 __ret = 1; \
50 } \
51 __ret; \
52})
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#endif