4 #include <linux/linkage.h>
6 #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
7 #define BUGFLAG_UNWINDER (1 << 1)
9 #ifdef CONFIG_GENERIC_BUG
11 #define HAVE_ARCH_WARN_ON
18 * %4 - sizeof(struct bug_entry)
20 * The trapa opcode itself sits in %0.
21 * The %O notation is used to avoid # generation.
23 * The offending file and line are encoded in the __bug_table section.
25 #ifdef CONFIG_DEBUG_BUGVERBOSE
26 #define _EMIT_BUG_ENTRY \
27 "\t.pushsection __bug_table,\"aw\"\n" \
28 "2:\t.long 1b, %O1\n" \
29 "\t.short %O2, %O3\n" \
33 #define _EMIT_BUG_ENTRY \
34 "\t.pushsection __bug_table,\"aw\"\n" \
43 __asm__ __volatile__ ( \
47 : "n" (TRAPA_BUG_OPCODE), \
49 "i" (__LINE__), "i" (0), \
50 "i" (sizeof(struct bug_entry))); \
54 #define __WARN_FLAGS(flags) \
56 __asm__ __volatile__ ( \
60 : "n" (TRAPA_BUG_OPCODE), \
63 "i" (BUGFLAG_WARNING|(flags)), \
64 "i" (sizeof(struct bug_entry))); \
67 #define WARN_ON(x) ({ \
68 int __ret_warn_on = !!(x); \
69 if (__builtin_constant_p(__ret_warn_on)) { \
73 if (unlikely(__ret_warn_on)) \
76 unlikely(__ret_warn_on); \
79 #define UNWINDER_BUG() \
81 __asm__ __volatile__ ( \
85 : "n" (TRAPA_BUG_OPCODE), \
88 "i" (BUGFLAG_UNWINDER), \
89 "i" (sizeof(struct bug_entry))); \
92 #define UNWINDER_BUG_ON(x) ({ \
93 int __ret_unwinder_on = !!(x); \
94 if (__builtin_constant_p(__ret_unwinder_on)) { \
95 if (__ret_unwinder_on) \
98 if (unlikely(__ret_unwinder_on)) \
101 unlikely(__ret_unwinder_on); \
106 #define UNWINDER_BUG BUG
107 #define UNWINDER_BUG_ON BUG_ON
109 #endif /* CONFIG_GENERIC_BUG */
111 #include <asm-generic/bug.h>
115 /* arch/sh/kernel/traps.c */
116 extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));
117 extern void die_if_kernel(const char *str, struct pt_regs *regs, long err);
118 extern void die_if_no_fixup(const char *str, struct pt_regs *regs, long err);
120 #endif /* __ASM_SH_BUG_H */