blob: f07bb716fc044bf7b68700b2fc1f481f25efe5d3 [file] [log] [blame]
Masahiro Yamada84b8bf62016-01-24 23:27:48 +09001#ifndef _LINUX_BUG_H
2#define _LINUX_BUG_H
3
Masahiro Yamada0a70fb42017-09-16 14:10:45 +09004#include <vsprintf.h> /* for panic() */
Masahiro Yamada059a4802017-09-16 14:10:44 +09005#include <linux/build_bug.h>
Masahiro Yamada0a70fb42017-09-16 14:10:45 +09006#include <linux/compiler.h>
7#include <linux/printk.h>
8
9#define BUG() do { \
10 printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
11 panic("BUG!"); \
12} while (0)
13
14#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
15
16#define WARN_ON(condition) ({ \
17 int __ret_warn_on = !!(condition); \
18 if (unlikely(__ret_warn_on)) \
19 printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
20 unlikely(__ret_warn_on); \
21})
22
23#define WARN_ON_ONCE(condition) ({ \
24 static bool __warned; \
25 int __ret_warn_once = !!(condition); \
26 \
27 if (unlikely(__ret_warn_once && !__warned)) { \
28 __warned = true; \
29 WARN_ON(1); \
30 } \
31 unlikely(__ret_warn_once); \
32})
Masahiro Yamada84b8bf62016-01-24 23:27:48 +090033
34#endif /* _LINUX_BUG_H */