vserver 2.0 rc7
[linux-2.6.git] / include / asm-ppc / bug.h
1 #ifndef _PPC_BUG_H
2 #define _PPC_BUG_H
3
4 struct bug_entry {
5         unsigned long   bug_addr;
6         int             line;
7         const char      *file;
8         const char      *function;
9 };
10
11 /*
12  * If this bit is set in the line number it means that the trap
13  * is for WARN_ON rather than BUG or BUG_ON.
14  */
15 #define BUG_WARNING_TRAP        0x1000000
16
17 #ifdef CONFIG_BUG
18 #define BUG() do {                                                       \
19         __asm__ __volatile__(                                            \
20                 "1:     twi 31,0,0\n"                                    \
21                 ".section __bug_table,\"a\"\n\t"                         \
22                 "       .long 1b,%0,%1,%2\n"                             \
23                 ".previous"                                              \
24                 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
25 } while (0)
26
27 #define BUG_ON(x) do {                                                  \
28         if (!__builtin_constant_p(x) || (x)) {                          \
29                 __asm__ __volatile__(                                   \
30                         "1:     twnei %0,0\n"                           \
31                         ".section __bug_table,\"a\"\n\t"                \
32                         "       .long 1b,%1,%2,%3\n"                    \
33                         ".previous"                                     \
34                         : : "r" (x), "i" (__LINE__), "i" (__FILE__),    \
35                             "i" (__FUNCTION__));                        \
36         }                                                               \
37 } while (0)
38
39 #define WARN_ON(x) do {                                                 \
40         if (!__builtin_constant_p(x) || (x)) {                          \
41                 __asm__ __volatile__(                                   \
42                         "1:     twnei %0,0\n"                           \
43                         ".section __bug_table,\"a\"\n\t"                \
44                         "       .long 1b,%1,%2,%3\n"                    \
45                         ".previous"                                     \
46                         : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
47                             "i" (__FILE__), "i" (__FUNCTION__));        \
48         }                                                               \
49 } while (0)
50
51 #define HAVE_ARCH_BUG
52 #define HAVE_ARCH_BUG_ON
53 #define HAVE_ARCH_WARN_ON
54 #endif
55
56 #include <asm-generic/bug.h>
57
58 #endif