Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
[pv_ops_mirror.git] / include / asm-generic / bug.h
blob2632328d8646840aab41c8e401a1088e922754f2
1 #ifndef _ASM_GENERIC_BUG_H
2 #define _ASM_GENERIC_BUG_H
4 #include <linux/compiler.h>
6 #ifdef CONFIG_BUG
8 #ifdef CONFIG_GENERIC_BUG
9 #ifndef __ASSEMBLY__
10 struct bug_entry {
11 unsigned long bug_addr;
12 #ifdef CONFIG_DEBUG_BUGVERBOSE
13 const char *file;
14 unsigned short line;
15 #endif
16 unsigned short flags;
18 #endif /* __ASSEMBLY__ */
20 #define BUGFLAG_WARNING (1<<0)
21 #endif /* CONFIG_GENERIC_BUG */
23 #ifndef HAVE_ARCH_BUG
24 #define BUG() do { \
25 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
26 panic("BUG!"); \
27 } while (0)
28 #endif
30 #ifndef HAVE_ARCH_BUG_ON
31 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
32 #endif
34 #ifndef __WARN
35 #ifndef __ASSEMBLY__
36 extern void warn_on_slowpath(const char *file, const int line);
37 #define WANT_WARN_ON_SLOWPATH
38 #endif
39 #define __WARN() warn_on_slowpath(__FILE__, __LINE__)
40 #endif
42 #ifndef WARN_ON
43 #define WARN_ON(condition) ({ \
44 int __ret_warn_on = !!(condition); \
45 if (unlikely(__ret_warn_on)) \
46 __WARN(); \
47 unlikely(__ret_warn_on); \
49 #endif
51 #else /* !CONFIG_BUG */
52 #ifndef HAVE_ARCH_BUG
53 #define BUG()
54 #endif
56 #ifndef HAVE_ARCH_BUG_ON
57 #define BUG_ON(condition) do { if (condition) ; } while(0)
58 #endif
60 #ifndef HAVE_ARCH_WARN_ON
61 #define WARN_ON(condition) ({ \
62 int __ret_warn_on = !!(condition); \
63 unlikely(__ret_warn_on); \
65 #endif
66 #endif
68 #define WARN_ON_ONCE(condition) ({ \
69 static int __warned; \
70 int __ret_warn_once = !!(condition); \
72 if (unlikely(__ret_warn_once)) \
73 if (WARN_ON(!__warned)) \
74 __warned = 1; \
75 unlikely(__ret_warn_once); \
78 #ifdef CONFIG_SMP
79 # define WARN_ON_SMP(x) WARN_ON(x)
80 #else
81 # define WARN_ON_SMP(x) do { } while (0)
82 #endif
84 #endif