mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Proposed patch to kernel.h
@ 2003-05-27 22:51 Paul Mackerras
  2003-05-29  2:00 ` Paul Mackerras
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2003-05-27 22:51 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus,

PowerPC has a conditional trap instruction that I would like to use
for BUG_ON.  I would like to make BUG_ON for ppc look like this:

#define BUG_ON(x) do {						\
	__asm__ __volatile__(					\
		"1:	twnei %0,0\n"				\
		".section __bug_table,\"a\"\n"			\
		"	.long 1b,%1,%2\n"			\
		".previous"					\
		: : "r" (x), "i" (__LINE__), "i" (__FILE__));	\
} while (0)

This avoids a conditional branch and is nice and compact.  (The twnei
instruction takes an exception if the register operand is not equal
to the immediate operand - trap word not equal immediate.)

However, at the moment BUG_ON is unconditionally defined in kernel.h.
The patch below is the simplest way I can see to make it possible for
architectures to supply their own BUG_ON.  Please apply.

Thanks,
Paul.

diff -urN linux-2.5/include/linux/kernel.h pmac-2.5/include/linux/kernel.h
--- linux-2.5/include/linux/kernel.h	2003-05-21 08:27:25.000000000 +1000
+++ pmac-2.5/include/linux/kernel.h	2003-05-26 22:01:54.000000000 +1000
@@ -228,7 +228,9 @@
 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
 };
 
+#ifndef BUG_ON
 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
+#endif
 #define WARN_ON(condition) do { \
 	if (unlikely((condition)!=0)) { \
 		printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-30  7:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-27 22:51 Proposed patch to kernel.h Paul Mackerras
2003-05-29  2:00 ` Paul Mackerras
2003-05-29  2:23   ` Linus Torvalds
2003-05-29 12:32     ` Paul Mackerras
2003-05-30  8:03       ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®