blob: 4790f047a89c476624975d51514698f210900a19 [file] [log] [blame]
Namhyung Kim02dfc8d2014-01-09 23:00:54 +09001#ifndef _TOOLS_ASM_BUG_H
2#define _TOOLS_ASM_BUG_H
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -02003
Namhyung Kim741a0c52014-01-09 23:00:55 +09004#include <linux/compiler.h>
5
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -02006#define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0)
7
8#define WARN(condition, format...) ({ \
9 int __ret_warn_on = !!(condition); \
10 if (unlikely(__ret_warn_on)) \
11 __WARN_printf(format); \
12 unlikely(__ret_warn_on); \
13})
14
Matthew Wilcoxb246a9d2016-12-19 11:07:17 -050015#define WARN_ON(condition) ({ \
16 int __ret_warn_on = !!(condition); \
17 if (unlikely(__ret_warn_on)) \
18 __WARN_printf("assertion failed at %s:%d\n", \
19 __FILE__, __LINE__); \
20 unlikely(__ret_warn_on); \
21})
22
Matthew Wilcoxebb9a9a2016-12-14 15:07:56 -080023#define WARN_ON_ONCE(condition) ({ \
24 static int __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})
33
Arnaldo Carvalho de Melob32d1332009-11-24 12:05:15 -020034#define WARN_ONCE(condition, format...) ({ \
35 static int __warned; \
36 int __ret_warn_once = !!(condition); \
37 \
38 if (unlikely(__ret_warn_once)) \
39 if (WARN(!__warned, format)) \
40 __warned = 1; \
41 unlikely(__ret_warn_once); \
42})
Namhyung Kim02dfc8d2014-01-09 23:00:54 +090043
44#endif /* _TOOLS_ASM_BUG_H */