diff options
Diffstat (limited to 'include/asm-powerpc/bug.h')
-rw-r--r-- | include/asm-powerpc/bug.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/include/asm-powerpc/bug.h b/include/asm-powerpc/bug.h index 99817a802ca4..f44b529e3298 100644 --- a/include/asm-powerpc/bug.h +++ b/include/asm-powerpc/bug.h | |||
@@ -30,34 +30,60 @@ struct bug_entry *find_bug(unsigned long bugaddr); | |||
30 | 30 | ||
31 | #ifdef CONFIG_BUG | 31 | #ifdef CONFIG_BUG |
32 | 32 | ||
33 | /* | ||
34 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time | ||
35 | * optimisations. However depending on the complexity of the condition | ||
36 | * some compiler versions may not produce optimal results. | ||
37 | */ | ||
38 | |||
33 | #define BUG() do { \ | 39 | #define BUG() do { \ |
34 | __asm__ __volatile__( \ | 40 | __asm__ __volatile__( \ |
35 | "1: twi 31,0,0\n" \ | 41 | "1: twi 31,0,0\n" \ |
36 | ".section __bug_table,\"a\"\n" \ | 42 | ".section __bug_table,\"a\"\n" \ |
37 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ | 43 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ |
38 | ".previous" \ | 44 | ".previous" \ |
39 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ | 45 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ |
40 | } while (0) | 46 | } while (0) |
41 | 47 | ||
42 | #define BUG_ON(x) do { \ | 48 | #define BUG_ON(x) do { \ |
43 | __asm__ __volatile__( \ | 49 | if (__builtin_constant_p(x)) { \ |
50 | if (x) \ | ||
51 | BUG(); \ | ||
52 | } else { \ | ||
53 | __asm__ __volatile__( \ | ||
44 | "1: "PPC_TLNEI" %0,0\n" \ | 54 | "1: "PPC_TLNEI" %0,0\n" \ |
45 | ".section __bug_table,\"a\"\n" \ | 55 | ".section __bug_table,\"a\"\n" \ |
46 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ | 56 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
47 | ".previous" \ | 57 | ".previous" \ |
48 | : : "r" ((long)(x)), "i" (__LINE__), \ | 58 | : : "r" ((long)(x)), "i" (__LINE__), \ |
49 | "i" (__FILE__), "i" (__FUNCTION__)); \ | 59 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
60 | } \ | ||
50 | } while (0) | 61 | } while (0) |
51 | 62 | ||
52 | #define WARN_ON(x) do { \ | 63 | #define __WARN() do { \ |
53 | __asm__ __volatile__( \ | 64 | __asm__ __volatile__( \ |
65 | "1: twi 31,0,0\n" \ | ||
66 | ".section __bug_table,\"a\"\n" \ | ||
67 | "\t"PPC_LONG" 1b,%0,%1,%2\n" \ | ||
68 | ".previous" \ | ||
69 | : : "i" (__LINE__ + BUG_WARNING_TRAP), \ | ||
70 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
71 | } while (0) | ||
72 | |||
73 | #define WARN_ON(x) do { \ | ||
74 | if (__builtin_constant_p(x)) { \ | ||
75 | if (x) \ | ||
76 | __WARN(); \ | ||
77 | } else { \ | ||
78 | __asm__ __volatile__( \ | ||
54 | "1: "PPC_TLNEI" %0,0\n" \ | 79 | "1: "PPC_TLNEI" %0,0\n" \ |
55 | ".section __bug_table,\"a\"\n" \ | 80 | ".section __bug_table,\"a\"\n" \ |
56 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ | 81 | "\t"PPC_LONG" 1b,%1,%2,%3\n" \ |
57 | ".previous" \ | 82 | ".previous" \ |
58 | : : "r" ((long)(x)), \ | 83 | : : "r" ((long)(x)), \ |
59 | "i" (__LINE__ + BUG_WARNING_TRAP), \ | 84 | "i" (__LINE__ + BUG_WARNING_TRAP), \ |
60 | "i" (__FILE__), "i" (__FUNCTION__)); \ | 85 | "i" (__FILE__), "i" (__FUNCTION__)); \ |
86 | } \ | ||
61 | } while (0) | 87 | } while (0) |
62 | 88 | ||
63 | #define HAVE_ARCH_BUG | 89 | #define HAVE_ARCH_BUG |