GNU Linux-libre 4.9.311-gnu1
[releases.git] / include / linux / bug.h
1 #ifndef _LINUX_BUG_H
2 #define _LINUX_BUG_H
3
4 #include <asm/bug.h>
5 #include <linux/compiler.h>
6 #include <linux/build_bug.h>
7
8 enum bug_trap_type {
9         BUG_TRAP_TYPE_NONE = 0,
10         BUG_TRAP_TYPE_WARN = 1,
11         BUG_TRAP_TYPE_BUG = 2,
12 };
13
14 struct pt_regs;
15
16 #ifdef __CHECKER__
17 #define MAYBE_BUILD_BUG_ON(cond) (0)
18 #else /* __CHECKER__ */
19
20 #define MAYBE_BUILD_BUG_ON(cond)                        \
21         do {                                            \
22                 if (__builtin_constant_p((cond)))       \
23                         BUILD_BUG_ON(cond);             \
24                 else                                    \
25                         BUG_ON(cond);                   \
26         } while (0)
27
28 #endif  /* __CHECKER__ */
29
30 #ifdef CONFIG_GENERIC_BUG
31 #include <asm-generic/bug.h>
32
33 static inline int is_warning_bug(const struct bug_entry *bug)
34 {
35         return bug->flags & BUGFLAG_WARNING;
36 }
37
38 const struct bug_entry *find_bug(unsigned long bugaddr);
39
40 enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
41
42 /* These are defined by the architecture */
43 int is_valid_bugaddr(unsigned long addr);
44
45 #else   /* !CONFIG_GENERIC_BUG */
46
47 static inline void *find_bug(unsigned long bugaddr)
48 {
49         return NULL;
50 }
51
52 static inline enum bug_trap_type report_bug(unsigned long bug_addr,
53                                             struct pt_regs *regs)
54 {
55         return BUG_TRAP_TYPE_BUG;
56 }
57
58 #endif  /* CONFIG_GENERIC_BUG */
59 #endif  /* _LINUX_BUG_H */