[PATCH] ppc64: Fix issue with gcc 4.0 compiled kernels

Anton Blanchard anton at samba.org
Tue Aug 23 15:34:43 EST 2005


Hi,

I recently had a BUG_ON() go off spuriously on a gcc 4.0 compiled
kernel. It turns out gcc-4.0 was removing a sign extension while earlier
gcc versions would not. Thinking this to be a compiler bug, I submitted
a report:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23422

It turns out we need to cast the input in order to tell gcc to sign
extend it.

Thanks to Andrew Pinski for his help on this bug.

Signed-off-by: Anton Blanchard <anton at samba.org>

Index: gr_work/include/asm-ppc64/bug.h
===================================================================
--- gr_work.orig/include/asm-ppc64/bug.h	2005-07-08 22:34:03.000000000 -0500
+++ gr_work/include/asm-ppc64/bug.h	2005-08-16 09:26:23.940170149 -0500
@@ -43,8 +43,8 @@
 		".section __bug_table,\"a\"\n\t"		\
 		"	.llong 1b,%1,%2,%3\n"			\
 		".previous"					\
-		: : "r" (x), "i" (__LINE__), "i" (__FILE__),	\
-		    "i" (__FUNCTION__));			\
+		: : "r" ((long long)(x)), "i" (__LINE__),	\
+		    "i" (__FILE__), "i" (__FUNCTION__));	\
 } while (0)
 
 #define WARN_ON(x) do {						\
@@ -53,7 +53,8 @@
 		".section __bug_table,\"a\"\n\t"		\
 		"	.llong 1b,%1,%2,%3\n"			\
 		".previous"					\
-		: : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP),	\
+		: : "r" ((long long)(x)),			\
+		    "i" (__LINE__ + BUG_WARNING_TRAP),		\
 		    "i" (__FILE__), "i" (__FUNCTION__));	\
 } while (0)
 



More information about the Linuxppc64-dev mailing list