From: Paul Mackerras <paulus@samba.org>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: Proposed patch to kernel.h
Date: Wed, 28 May 2003 08:51:02 +1000 (EST) [thread overview]
Message-ID: <16083.60374.284044.751867@nanango.paulus.ozlabs.org> (raw)
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__); \
next reply other threads:[~2003-05-27 22:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-27 22:51 Paul Mackerras [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16083.60374.284044.751867@nanango.paulus.ozlabs.org \
--to=paulus@samba.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®