From: Robert Love <rml@tech9.net>
To: marcelo@conectiva.com.br, alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.4: BUG_ON (1/2)
Date: 20 Mar 2002 19:15:54 -0500 [thread overview]
Message-ID: <1016669760.15474.265.camel@phantasy> (raw)
Marcelo and Alan,
The attached patch adds 2.5's BUG_ON construct to the 2.4 kernel. This
is done to facilitate portability and back-porting 2.4 <=> 2.5, because
BUG_ON is a very readable construct, and because it is a small
optimization over standard BUG.
For the unaware, BUG_ON(condition) is basically
if (unlikely(condition) != 0) BUG();
There was some talk in one of Andrew's aa-vm threads over introducing
BUG_ON in 2.4 - so I resend this patch. There was also talk of a new
name (Jeff Garzik mentioned kassert). This is fine, but since much of
the goal is portability between 2.4 and 2.5 the change needs to
subsequently be made in 2.5. We can handle that later, if need be.
This patch is against 2.4.19-pre4, but also applies to 2.4.19-ac. Alan
and Marcelo - please apply.
Robert Love
diff -urN linux-2.4.19-pre4/include/linux/kernel.h linux/include/linux/kernel.h
--- linux-2.4.19-pre4/include/linux/kernel.h Wed Mar 20 17:43:58 2002
+++ linux/include/linux/kernel.h Wed Mar 20 17:51:38 2002
@@ -11,6 +11,7 @@
#include <linux/linkage.h>
#include <linux/stddef.h>
#include <linux/types.h>
+#include <linux/compiler.h>
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
@@ -181,4 +182,5 @@
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
+#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#endif
next reply other threads:[~2002-03-21 0:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-21 0:15 Robert Love [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-04-03 2:59 [PATCH] 2.4: BUG_ON (1/2) Robert Love
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=1016669760.15474.265.camel@phantasy \
--to=rml@tech9.net \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/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