1 #ifndef _ASM_POWERPC_BUG_H
2 #define _ASM_POWERPC_BUG_H
5 #include <asm/asm-compat.h>
8 * Define an illegal instr to trap on the bug.
9 * We don't use 0 because that marks the end of a function
10 * in the ELF ABI. That's "Boo Boo" in case you wonder...
12 #define BUG_OPCODE .long 0x00b00b00 /* For asm */
13 #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
18 #include <asm/asm-offsets.h>
19 #ifdef CONFIG_DEBUG_BUGVERBOSE
20 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
21 .section __bug_table
,"a"
22 5001: PPC_LONG
\addr
, 5002f
24 .org
5001b
+BUG_ENTRY_SIZE
31 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
32 .section __bug_table
,"a"
35 .org
5001b
+BUG_ENTRY_SIZE
40 #else /* !__ASSEMBLY__ */
41 /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
42 sizeof(struct bug_entry), respectively */
43 #ifdef CONFIG_DEBUG_BUGVERBOSE
44 #define _EMIT_BUG_ENTRY \
45 ".section __bug_table,\"a\"\n" \
46 "2:\t" PPC_LONG "1b, %0\n" \
51 #define _EMIT_BUG_ENTRY \
52 ".section __bug_table,\"a\"\n" \
53 "2:\t" PPC_LONG "1b\n" \
60 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
61 * optimisations. However depending on the complexity of the condition
62 * some compiler versions may not produce optimal results.
66 __asm__ __volatile__( \
69 : : "i" (__FILE__), "i" (__LINE__), \
70 "i" (0), "i" (sizeof(struct bug_entry))); \
74 #define BUG_ON(x) do { \
75 if (__builtin_constant_p(x)) { \
79 __asm__ __volatile__( \
80 "1: "PPC_TLNEI" %4,0\n" \
82 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
83 "i" (sizeof(struct bug_entry)), \
84 "r" ((__force long)(x))); \
88 #define __WARN_TAINT(taint) do { \
89 __asm__ __volatile__( \
92 : : "i" (__FILE__), "i" (__LINE__), \
93 "i" (BUGFLAG_TAINT(taint)), \
94 "i" (sizeof(struct bug_entry))); \
97 #define WARN_ON(x) ({ \
98 int __ret_warn_on = !!(x); \
99 if (__builtin_constant_p(__ret_warn_on)) { \
103 __asm__ __volatile__( \
104 "1: "PPC_TLNEI" %4,0\n" \
106 : : "i" (__FILE__), "i" (__LINE__), \
107 "i" (BUGFLAG_TAINT(TAINT_WARN)), \
108 "i" (sizeof(struct bug_entry)), \
109 "r" (__ret_warn_on)); \
111 unlikely(__ret_warn_on); \
114 #define HAVE_ARCH_BUG
115 #define HAVE_ARCH_BUG_ON
116 #define HAVE_ARCH_WARN_ON
117 #endif /* __ASSEMBLY __ */
120 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
122 #else /* !__ASSEMBLY__ */
123 #define _EMIT_BUG_ENTRY
125 #endif /* CONFIG_BUG */
127 #include <asm-generic/bug.h>
129 #endif /* __KERNEL__ */
130 #endif /* _ASM_POWERPC_BUG_H */