[PATCH][PPC32] Reduce WARN_ON(0) to nothing

From: Paul Mackerras
Date: Thu Jun 03 2004 - 07:19:26 EST


The last patch I sent means that we have WARN_ON(0) in a couple of
places when CONFIG_PREEMPT=n. This patch makes that reduce to
nothing (rather than a conditional trap on a 0 value), and also makes
BUG_ON(0) reduce to nothing for completeness.

Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>

diff -urN linux-2.5/include/asm-ppc/bug.h pmac-2.5/include/asm-ppc/bug.h
--- linux-2.5/include/asm-ppc/bug.h 2003-06-08 08:08:29.000000000 +1000
+++ pmac-2.5/include/asm-ppc/bug.h 2004-06-03 21:35:42.385963144 +1000
@@ -23,26 +23,30 @@
: : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
} while (0)

-#define BUG_ON(x) do { \
- __asm__ __volatile__( \
- "1: twnei %0,0\n" \
- ".section __bug_table,\"a\"\n\t" \
- " .long 1b,%1,%2,%3\n" \
- ".previous" \
- : : "r" (x), "i" (__LINE__), "i" (__FILE__), \
- "i" (__FUNCTION__)); \
+#define BUG_ON(x) do { \
+ if (!__builtin_constant_p(x) || (x)) { \
+ __asm__ __volatile__( \
+ "1: twnei %0,0\n" \
+ ".section __bug_table,\"a\"\n\t" \
+ " .long 1b,%1,%2,%3\n" \
+ ".previous" \
+ : : "r" (x), "i" (__LINE__), "i" (__FILE__), \
+ "i" (__FUNCTION__)); \
+ } \
} while (0)

-#define PAGE_BUG(page) do { BUG(); } while (0)
+#define PAGE_BUG(page) BUG()

-#define WARN_ON(x) do { \
- __asm__ __volatile__( \
- "1: twnei %0,0\n" \
- ".section __bug_table,\"a\"\n\t" \
- " .long 1b,%1,%2,%3\n" \
- ".previous" \
- : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
- "i" (__FILE__), "i" (__FUNCTION__)); \
+#define WARN_ON(x) do { \
+ if (!__builtin_constant_p(x) || (x)) { \
+ __asm__ __volatile__( \
+ "1: twnei %0,0\n" \
+ ".section __bug_table,\"a\"\n\t" \
+ " .long 1b,%1,%2,%3\n" \
+ ".previous" \
+ : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
+ "i" (__FILE__), "i" (__FUNCTION__)); \
+ } \
} while (0)

#endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/