~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/bug.h

Version: ~ [ linux-5.1-rc1 ] ~ [ linux-5.0.2 ] ~ [ linux-4.20.16 ] ~ [ linux-4.19.29 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.106 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.163 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.176 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.136 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.63 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_BUG_H
  3 #define _LINUX_BUG_H
  4 
  5 #include <asm/bug.h>
  6 #include <linux/compiler.h>
  7 #include <linux/build_bug.h>
  8 
  9 enum bug_trap_type {
 10         BUG_TRAP_TYPE_NONE = 0,
 11         BUG_TRAP_TYPE_WARN = 1,
 12         BUG_TRAP_TYPE_BUG = 2,
 13 };
 14 
 15 struct pt_regs;
 16 
 17 #ifdef __CHECKER__
 18 #define MAYBE_BUILD_BUG_ON(cond) (0)
 19 #else /* __CHECKER__ */
 20 
 21 #define MAYBE_BUILD_BUG_ON(cond)                        \
 22         do {                                            \
 23                 if (__builtin_constant_p((cond)))       \
 24                         BUILD_BUG_ON(cond);             \
 25                 else                                    \
 26                         BUG_ON(cond);                   \
 27         } while (0)
 28 
 29 #endif  /* __CHECKER__ */
 30 
 31 #ifdef CONFIG_GENERIC_BUG
 32 #include <asm-generic/bug.h>
 33 
 34 static inline int is_warning_bug(const struct bug_entry *bug)
 35 {
 36         return bug->flags & BUGFLAG_WARNING;
 37 }
 38 
 39 struct bug_entry *find_bug(unsigned long bugaddr);
 40 
 41 enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
 42 
 43 /* These are defined by the architecture */
 44 int is_valid_bugaddr(unsigned long addr);
 45 
 46 void generic_bug_clear_once(void);
 47 
 48 #else   /* !CONFIG_GENERIC_BUG */
 49 
 50 static inline enum bug_trap_type report_bug(unsigned long bug_addr,
 51                                             struct pt_regs *regs)
 52 {
 53         return BUG_TRAP_TYPE_BUG;
 54 }
 55 
 56 
 57 static inline void generic_bug_clear_once(void) {}
 58 
 59 #endif  /* CONFIG_GENERIC_BUG */
 60 
 61 /*
 62  * Since detected data corruption should stop operation on the affected
 63  * structures. Return value must be checked and sanely acted on by caller.
 64  */
 65 static inline __must_check bool check_data_corruption(bool v) { return v; }
 66 #define CHECK_DATA_CORRUPTION(condition, fmt, ...)                       \
 67         check_data_corruption(({                                         \
 68                 bool corruption = unlikely(condition);                   \
 69                 if (corruption) {                                        \
 70                         if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
 71                                 pr_err(fmt, ##__VA_ARGS__);              \
 72                                 BUG();                                   \
 73                         } else                                           \
 74                                 WARN(1, fmt, ##__VA_ARGS__);             \
 75                 }                                                        \
 76                 corruption;                                              \
 77         }))
 78 
 79 #endif  /* _LINUX_BUG_H */
 80 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp