pageflags: get rid of FLAGS_RESERVED
[linux-2.6/kmemtrace.git] / include / asm-sh / bug.h
blobc01718040166e2141fe68357e57fe637e9f20edf
1 #ifndef __ASM_SH_BUG_H
2 #define __ASM_SH_BUG_H
4 #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
6 #ifdef CONFIG_GENERIC_BUG
7 #define HAVE_ARCH_BUG
8 #define HAVE_ARCH_WARN_ON
10 /**
11 * _EMIT_BUG_ENTRY
12 * %1 - __FILE__
13 * %2 - __LINE__
14 * %3 - trap type
15 * %4 - sizeof(struct bug_entry)
17 * The trapa opcode itself sits in %0.
18 * The %O notation is used to avoid # generation.
20 * The offending file and line are encoded in the __bug_table section.
22 #ifdef CONFIG_DEBUG_BUGVERBOSE
23 #define _EMIT_BUG_ENTRY \
24 "\t.pushsection __bug_table,\"a\"\n" \
25 "2:\t.long 1b, %O1\n" \
26 "\t.short %O2, %O3\n" \
27 "\t.org 2b+%O4\n" \
28 "\t.popsection\n"
29 #else
30 #define _EMIT_BUG_ENTRY \
31 "\t.pushsection __bug_table,\"a\"\n" \
32 "2:\t.long 1b\n" \
33 "\t.short %O3\n" \
34 "\t.org 2b+%O4\n" \
35 "\t.popsection\n"
36 #endif
38 #define BUG() \
39 do { \
40 __asm__ __volatile__ ( \
41 "1:\t.short %O0\n" \
42 _EMIT_BUG_ENTRY \
43 : \
44 : "n" (TRAPA_BUG_OPCODE), \
45 "i" (__FILE__), \
46 "i" (__LINE__), "i" (0), \
47 "i" (sizeof(struct bug_entry))); \
48 } while (0)
50 #define __WARN() \
51 do { \
52 __asm__ __volatile__ ( \
53 "1:\t.short %O0\n" \
54 _EMIT_BUG_ENTRY \
55 : \
56 : "n" (TRAPA_BUG_OPCODE), \
57 "i" (__FILE__), \
58 "i" (__LINE__), \
59 "i" (BUGFLAG_WARNING), \
60 "i" (sizeof(struct bug_entry))); \
61 } while (0)
63 #define WARN_ON(x) ({ \
64 int __ret_warn_on = !!(x); \
65 if (__builtin_constant_p(__ret_warn_on)) { \
66 if (__ret_warn_on) \
67 __WARN(); \
68 } else { \
69 if (unlikely(__ret_warn_on)) \
70 __WARN(); \
71 } \
72 unlikely(__ret_warn_on); \
75 #endif /* CONFIG_GENERIC_BUG */
77 #include <asm-generic/bug.h>
79 #endif /* __ASM_SH_BUG_H */