Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / include / asm-generic / bug.h
1 #ifndef _ASM_GENERIC_BUG_H
2 #define _ASM_GENERIC_BUG_H
3
4 #include <linux/compiler.h>
5
6 #ifndef __ASSEMBLY__
7 extern const char *print_tainted(void);
8 #endif
9
10 #ifdef CONFIG_BUG
11 #ifndef HAVE_ARCH_BUG
12 #define BUG() do { \
13         printk("BUG: failure at %s:%d/%s()! (%s)\n", __FILE__, __LINE__, __FUNCTION__, print_tainted()); \
14         panic("BUG!"); \
15 } while (0)
16 #endif
17
18 #ifndef HAVE_ARCH_BUG_ON
19 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
20 #endif
21
22 #ifndef HAVE_ARCH_WARN_ON
23 #define WARN_ON(condition) do { \
24         if (unlikely((condition)!=0)) { \
25                 printk("BUG: warning at %s:%d/%s() (%s)\n", __FILE__, __LINE__, __FUNCTION__, print_tainted()); \
26                 dump_stack(); \
27         } \
28 } while (0)
29 #endif
30
31 #else /* !CONFIG_BUG */
32 #ifndef HAVE_ARCH_BUG
33 #define BUG()
34 #endif
35
36 #ifndef HAVE_ARCH_BUG_ON
37 #define BUG_ON(condition) do { \
38         if (unlikely((condition)!=0)) { \
39                 printk("BUGging on (%s)\n", #condition); \
40                 BUG(); \
41         } \
42 } while(0)
43 #endif
44
45 #ifndef HAVE_ARCH_WARN_ON
46 #define WARN_ON(condition) do { \
47         if (unlikely((condition)!=0)) { \
48                 printk("BUG: warning: (%s) at %s:%d/%s()\n", \
49                         #condition, __FILE__, __LINE__, __FUNCTION__); \
50                 dump_stack(); \
51         } \
52 } while (0)
53 #endif
54 #endif
55
56 #define WARN_ON_ONCE(condition)                         \
57 ({                                                      \
58         static int __warn_once = 1;                     \
59         int __ret = 0;                                  \
60                                                         \
61         if (unlikely((condition) && __warn_once)) {     \
62                 __warn_once = 0;                        \
63                 WARN_ON(condition);                             \
64                 __ret = 1;                              \
65         }                                               \
66         __ret;                                          \
67 })
68
69 #ifdef CONFIG_SMP
70 # define WARN_ON_SMP(x)                 WARN_ON(x)
71 #else
72 # define WARN_ON_SMP(x)                 do { } while (0)
73 #endif
74
75 #endif