Rev 6588 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6588 | Rev 6936 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _ASM_GENERIC_BUG_H |
1 | #ifndef _LINUX_BUG_H |
2 | #define _ASM_GENERIC_BUG_H |
2 | #define _LINUX_BUG_H |
Line -... | Line 3... | ||
- | 3 | ||
3 | 4 | #include |
|
Line 4... | Line 5... | ||
4 | #include |
5 | #include |
5 | - | ||
6 | int printf(const char *fmt, ...); |
- | |
7 | 6 | ||
8 | #define __WARN() printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
7 | enum bug_trap_type { |
9 | //#define __WARN_printf(arg...) printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
- | |
10 | #define __WARN_printf(arg...) do { printf(arg); __WARN(); } while (0) |
- | |
11 | - | ||
12 | #define WARN(condition, format...) ({ \ |
- | |
13 | int __ret_warn_on = !!(condition); \ |
- | |
14 | if (unlikely(__ret_warn_on)) \ |
8 | BUG_TRAP_TYPE_NONE = 0, |
15 | __WARN_printf(format); \ |
9 | BUG_TRAP_TYPE_WARN = 1, |
16 | unlikely(__ret_warn_on); \ |
- | |
17 | }) |
10 | BUG_TRAP_TYPE_BUG = 2, |
18 | - | ||
19 | - | ||
20 | #define WARN_ON(condition) ({ \ |
- | |
21 | int __ret_warn_on = !!(condition); \ |
- | |
22 | if (unlikely(__ret_warn_on)) \ |
- | |
23 | __WARN(); \ |
11 | }; |
24 | unlikely(__ret_warn_on); \ |
- | |
25 | }) |
12 | |
26 | 13 | struct pt_regs; |
|
27 | - | ||
28 | #define WARN_ONCE(condition, format...) ({ \ |
14 | |
29 | static bool __warned; \ |
- | |
30 | int __ret_warn_once = !!(condition); \ |
15 | #ifdef __CHECKER__ |
31 | \ |
16 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) |
32 | if (unlikely(__ret_warn_once)) \ |
- | |
33 | if (WARN(!__warned, format)) \ |
17 | #define BUILD_BUG_ON_ZERO(e) (0) |
34 | __warned = true; \ |
- | |
35 | unlikely(__ret_warn_once); \ |
- | |
36 | }) |
- | |
37 | 18 | #define BUILD_BUG_ON_NULL(e) ((void*)0) |
|
38 | - | ||
39 | #define WARN_ON_ONCE(condition) ({ \ |
19 | #define BUILD_BUG_ON_INVALID(e) (0) |
40 | static bool __warned; \ |
- | |
41 | int __ret_warn_once = !!(condition); \ |
- | |
42 | \ |
- | |
43 | if (unlikely(__ret_warn_once)) \ |
- | |
44 | if (WARN_ON(!__warned)) \ |
- | |
45 | __warned = true; \ |
- | |
46 | unlikely(__ret_warn_once); \ |
- | |
47 | }) |
20 | #define BUILD_BUG_ON_MSG(cond, msg) (0) |
48 | - | ||
49 | #define BUG() do { \ |
21 | #define BUILD_BUG_ON(condition) (0) |
50 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
- | |
51 | } while (0) |
- | |
Line 52... | Line 22... | ||
52 | 22 | #define BUILD_BUG() (0) |
|
53 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
23 | #else /* __CHECKER__ */ |
54 | 24 | ||
Line 111... | Line 81... | ||
111 | * build time, you should use BUILD_BUG to detect if it is |
81 | * build time, you should use BUILD_BUG to detect if it is |
112 | * unexpectedly used. |
82 | * unexpectedly used. |
113 | */ |
83 | */ |
114 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") |
84 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") |
Line -... | Line 85... | ||
- | 85 | ||
Line -... | Line 86... | ||
- | 86 | #endif /* __CHECKER__ */ |
|
- | 87 | ||
Line -... | Line 88... | ||
- | 88 | #ifdef CONFIG_GENERIC_BUG |
|
- | 89 | #include |
|
- | 90 | ||
- | 91 | static inline int is_warning_bug(const struct bug_entry *bug) |
|
Line 115... | Line -... | ||
115 | - | ||
116 | 92 | { |
|
Line -... | Line 93... | ||
- | 93 | return bug->flags & BUGFLAG_WARNING; |
|
- | 94 | } |
|
- | 95 | ||
- | 96 | const struct bug_entry *find_bug(unsigned long bugaddr); |
|
- | 97 | ||
- | 98 | enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs); |
|
- | 99 | ||
- | 100 | /* These are defined by the architecture */ |
|
- | 101 | int is_valid_bugaddr(unsigned long addr); |
|
- | 102 | ||
- | 103 | #else /* !CONFIG_GENERIC_BUG */ |
|
- | 104 | ||
- | 105 | static inline enum bug_trap_type report_bug(unsigned long bug_addr, |
|
- | 106 | struct pt_regs *regs) |
|
117 | 107 | { |