vserver 1.9.3
[linux-2.6.git] / include / asm-ppc64 / bug.h
1 #ifndef _PPC64_BUG_H
2 #define _PPC64_BUG_H
3
4 /*
5  * Define an illegal instr to trap on the bug.
6  * We don't use 0 because that marks the end of a function
7  * in the ELF ABI.  That's "Boo Boo" in case you wonder...
8  */
9 #define BUG_OPCODE .long 0x00b00b00  /* For asm */
10 #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
11
12 #ifndef __ASSEMBLY__
13
14 struct bug_entry {
15         unsigned long   bug_addr;
16         long            line;
17         const char      *file;
18         const char      *function;
19 };
20
21 /*
22  * If this bit is set in the line number it means that the trap
23  * is for WARN_ON rather than BUG or BUG_ON.
24  */
25 #define BUG_WARNING_TRAP        0x1000000
26
27 #define BUG() do {                                                       \
28         __asm__ __volatile__(                                            \
29                 "1:     twi 31,0,0\n"                                    \
30                 ".section __bug_table,\"a\"\n\t"                         \
31                 "       .llong 1b,%0,%1,%2\n"                            \
32                 ".previous"                                              \
33                 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
34 } while (0)
35
36 #define BUG_ON(x) do {                                          \
37         __asm__ __volatile__(                                   \
38                 "1:     tdnei %0,0\n"                           \
39                 ".section __bug_table,\"a\"\n\t"                \
40                 "       .llong 1b,%1,%2,%3\n"                   \
41                 ".previous"                                     \
42                 : : "r" (x), "i" (__LINE__), "i" (__FILE__),    \
43                     "i" (__FUNCTION__));                        \
44 } while (0)
45
46 #define WARN_ON(x) do {                                         \
47         __asm__ __volatile__(                                   \
48                 "1:     tdnei %0,0\n"                           \
49                 ".section __bug_table,\"a\"\n\t"                \
50                 "       .llong 1b,%1,%2,%3\n"                   \
51                 ".previous"                                     \
52                 : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
53                     "i" (__FILE__), "i" (__FUNCTION__));        \
54 } while (0)
55
56 #endif
57
58 #define HAVE_ARCH_BUG
59 #define HAVE_ARCH_BUG_ON
60 #define HAVE_ARCH_WARN_ON
61 #include <asm-generic/bug.h>
62
63 #endif