1 #ifndef _ASM_GENERIC_BUG_H
2 #define _ASM_GENERIC_BUG_H
4 #include <linux/compiler.h>
7 extern void __WARN_ON(const char *func
, const char *file
, const int line
);
8 #endif /* __ASSEMBLY__ */
12 #ifdef CONFIG_GENERIC_BUG
15 #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
16 unsigned long bug_addr
;
18 signed int bug_addr_disp
;
20 #ifdef CONFIG_DEBUG_BUGVERBOSE
21 #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
30 #endif /* __ASSEMBLY__ */
32 #define BUGFLAG_WARNING (1<<0)
33 #endif /* CONFIG_GENERIC_BUG */
36 * Don't use BUG() or BUG_ON() unless there's really no way out; one
37 * example might be detecting data structure corruption in the middle
38 * of an operation that can't be backed out of. If the (sub)system
39 * can somehow continue operating, perhaps with reduced functionality,
40 * it's probably not BUG-worthy.
42 * If you're tempted to BUG(), think again: is completely giving up
43 * really the *only* solution? There are usually better options, where
44 * users don't need to reboot ASAP and can mostly shut down cleanly.
48 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
53 #ifndef HAVE_ARCH_BUG_ON
54 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
58 * WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
59 * significant issues that need prompt attention if they should ever
60 * appear at runtime. Use the versions with printk format strings
61 * to provide better diagnostics.
65 extern void warn_slowpath(const char *file
, const int line
,
66 const char *fmt
, ...) __attribute__((format(printf
, 3, 4)));
67 #define WANT_WARN_ON_SLOWPATH
69 #define __WARN() warn_slowpath(__FILE__, __LINE__, NULL)
70 #define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg)
72 #define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
76 #define WARN_ON(condition) ({ \
77 int __ret_warn_on = !!(condition); \
78 if (unlikely(__ret_warn_on)) \
80 unlikely(__ret_warn_on); \
85 #define WARN(condition, format...) ({ \
86 int __ret_warn_on = !!(condition); \
87 if (unlikely(__ret_warn_on)) \
88 __WARN_printf(format); \
89 unlikely(__ret_warn_on); \
93 #else /* !CONFIG_BUG */
98 #ifndef HAVE_ARCH_BUG_ON
99 #define BUG_ON(condition) do { if (condition) ; } while(0)
102 #ifndef HAVE_ARCH_WARN_ON
103 #define WARN_ON(condition) ({ \
104 int __ret_warn_on = !!(condition); \
105 unlikely(__ret_warn_on); \
110 static inline int __attribute__ ((format(printf
, 2, 3)))
111 __WARN(int condition
, const char *fmt
, ...) { return condition
; }
112 #define WARN(condition, format...) __WARN(!!(condition), format)
117 #define WARN_ON_ONCE(condition) ({ \
118 static int __warned; \
119 int __ret_warn_once = !!(condition); \
121 if (unlikely(__ret_warn_once)) \
122 if (WARN_ON(!__warned)) \
124 unlikely(__ret_warn_once); \
127 #define WARN_ONCE(condition, format...) ({ \
128 static int __warned; \
129 int __ret_warn_once = !!(condition); \
131 if (unlikely(__ret_warn_once)) \
132 if (WARN(!__warned, format)) \
134 unlikely(__ret_warn_once); \
137 #define WARN_ON_RATELIMIT(condition, state) \
138 WARN_ON((condition) && __ratelimit(state))
141 # define WARN_ON_SMP(x) WARN_ON(x)
143 # define WARN_ON_SMP(x) do { } while (0)
146 #ifdef CONFIG_PREEMPT_RT
147 # define BUG_ON_RT(c) BUG_ON(c)
148 # define BUG_ON_NONRT(c) do { } while (0)
149 # define WARN_ON_RT(condition) WARN_ON(condition)
150 # define WARN_ON_NONRT(condition) do { } while (0)
151 # define WARN_ON_ONCE_NONRT(condition) do { } while (0)
153 # define BUG_ON_RT(c) do { } while (0)
154 # define BUG_ON_NONRT(c) BUG_ON(c)
155 # define WARN_ON_RT(condition) do { } while (0)
156 # define WARN_ON_NONRT(condition) WARN_ON(condition)
157 # define WARN_ON_ONCE_NONRT(condition) WARN_ON_ONCE(condition)