]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
02dfc8d7 NK |
2 | #ifndef _TOOLS_ASM_BUG_H |
3 | #define _TOOLS_ASM_BUG_H | |
b32d133a | 4 | |
741a0c59 NK |
5 | #include <linux/compiler.h> |
6 | ||
b32d133a ACM |
7 | #define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0) |
8 | ||
9 | #define WARN(condition, format...) ({ \ | |
10 | int __ret_warn_on = !!(condition); \ | |
11 | if (unlikely(__ret_warn_on)) \ | |
12 | __WARN_printf(format); \ | |
13 | unlikely(__ret_warn_on); \ | |
14 | }) | |
15 | ||
b246a9d2 MW |
16 | #define WARN_ON(condition) ({ \ |
17 | int __ret_warn_on = !!(condition); \ | |
18 | if (unlikely(__ret_warn_on)) \ | |
19 | __WARN_printf("assertion failed at %s:%d\n", \ | |
20 | __FILE__, __LINE__); \ | |
21 | unlikely(__ret_warn_on); \ | |
22 | }) | |
23 | ||
ebb9a9ae MW |
24 | #define WARN_ON_ONCE(condition) ({ \ |
25 | static int __warned; \ | |
26 | int __ret_warn_once = !!(condition); \ | |
27 | \ | |
28 | if (unlikely(__ret_warn_once && !__warned)) { \ | |
29 | __warned = true; \ | |
30 | WARN_ON(1); \ | |
31 | } \ | |
32 | unlikely(__ret_warn_once); \ | |
33 | }) | |
34 | ||
b32d133a ACM |
35 | #define WARN_ONCE(condition, format...) ({ \ |
36 | static int __warned; \ | |
37 | int __ret_warn_once = !!(condition); \ | |
38 | \ | |
39 | if (unlikely(__ret_warn_once)) \ | |
40 | if (WARN(!__warned, format)) \ | |
41 | __warned = 1; \ | |
42 | unlikely(__ret_warn_once); \ | |
43 | }) | |
02dfc8d7 NK |
44 | |
45 | #endif /* _TOOLS_ASM_BUG_H */ |