fedora core 6 1.2949 + vserver 2.2.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
12 #ifdef CONFIG_GENERIC_BUG
13 #ifndef __ASSEMBLY__
14 struct bug_entry {
15         unsigned long   bug_addr;
16 #ifdef CONFIG_DEBUG_BUGVERBOSE
17         const char      *file;
18         unsigned short  line;
19 #endif
20         unsigned short  flags;
21 };
22 #endif          /* __ASSEMBLY__ */
23
24 #define BUGFLAG_WARNING (1<<0)
25 #endif  /* CONFIG_GENERIC_BUG */
26
27 #ifndef HAVE_ARCH_BUG
28 #define BUG() do { \
29         printk("BUG: failure at %s:%d/%s()! (%s)\n", __FILE__, __LINE__, __FUNCTION__, print_tainted()); \
30         panic("BUG!"); \
31 } while (0)
32 #endif
33
34 #ifndef HAVE_ARCH_BUG_ON
35 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
36 #endif
37
38 #ifndef HAVE_ARCH_WARN_ON
39 #define WARN_ON(condition) ({                                           \
40         typeof(condition) __ret_warn_on = (condition);                  \
41         if (unlikely(__ret_warn_on)) {                                  \
42                 printk("BUG: warning at %s:%d/%s() (%s)\n", __FILE__, __LINE__, __FUNCTION__, print_tainted()); \
43                 dump_stack();                                           \
44         }                                                               \
45         unlikely(__ret_warn_on);                                        \
46 })
47 #endif
48
49 #else /* !CONFIG_BUG */
50 #ifndef HAVE_ARCH_BUG
51 #define BUG()
52 #endif
53
54 #ifndef HAVE_ARCH_BUG_ON
55 #define BUG_ON(condition) do { if (condition) ; } while(0)
56 #endif
57
58 #ifndef HAVE_ARCH_WARN_ON
59 #define WARN_ON(condition) ({                                           \
60         typeof(condition) __ret_warn_on = (condition);                  \
61         unlikely(__ret_warn_on);                                        \
62 })
63 #endif
64 #endif
65
66 #define WARN_ON_ONCE(condition) ({                              \
67         static int __warned;                                    \
68         typeof(condition) __ret_warn_once = (condition);        \
69                                                                 \
70         if (unlikely(__ret_warn_once))                          \
71                 if (WARN_ON(!__warned))                         \
72                         __warned = 1;                           \
73         unlikely(__ret_warn_once);                              \
74 })
75
76 #ifdef CONFIG_SMP
77 # define WARN_ON_SMP(x)                 WARN_ON(x)
78 #else
79 # define WARN_ON_SMP(x)                 do { } while (0)
80 #endif
81
82 #endif