[PATCH] Fix generic WARN_ON message
[linux-2.6/mini2440.git] / include / asm-generic / bug.h
bloba06eecd48292a68d4611b43e263390b4320f7c15
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)!=0)) BUG(); } while(0)
32 #endif
34 #ifndef HAVE_ARCH_WARN_ON
35 #define WARN_ON(condition) ({ \
36 typeof(condition) __ret_warn_on = (condition); \
37 if (unlikely(__ret_warn_on)) { \
38 printk("WARNING at %s:%d %s()\n", __FILE__, \
39 __LINE__, __FUNCTION__); \
40 dump_stack(); \
41 } \
42 unlikely(__ret_warn_on); \
44 #endif
46 #else /* !CONFIG_BUG */
47 #ifndef HAVE_ARCH_BUG
48 #define BUG()
49 #endif
51 #ifndef HAVE_ARCH_BUG_ON
52 #define BUG_ON(condition) do { if (condition) ; } while(0)
53 #endif
55 #ifndef HAVE_ARCH_WARN_ON
56 #define WARN_ON(condition) ({ \
57 typeof(condition) __ret_warn_on = (condition); \
58 unlikely(__ret_warn_on); \
60 #endif
61 #endif
63 #define WARN_ON_ONCE(condition) ({ \
64 static int __warned; \
65 typeof(condition) __ret_warn_once = (condition); \
67 if (unlikely(__ret_warn_once)) \
68 if (WARN_ON(!__warned)) \
69 __warned = 1; \
70 unlikely(__ret_warn_once); \
73 #ifdef CONFIG_SMP
74 # define WARN_ON_SMP(x) WARN_ON(x)
75 #else
76 # define WARN_ON_SMP(x) do { } while (0)
77 #endif
79 #endif