From f80063e9aed834699ee74b7f8a302bd5c4b7fa6e Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 2 Jun 2004 18:22:18 -0700 Subject: [PATCH] [PATCH] ppc32: Reduce WARN_ON(0) to nothing 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 Signed-off-by: Linus Torvalds --- include/asm-ppc/bug.h | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/include/asm-ppc/bug.h b/include/asm-ppc/bug.h index ff3be2d387bfa..6b2579d9d4ee0 100644 --- a/include/asm-ppc/bug.h +++ b/include/asm-ppc/bug.h @@ -23,26 +23,30 @@ struct bug_entry { : : "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 -- 2.53.0