All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: marcelo@conectiva.com.br
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] add BUG_ON to 2.4 #1
Date: 25 Jan 2002 18:14:05 -0500	[thread overview]
Message-ID: <1012000446.3799.77.camel@phantasy> (raw)

The following patch adds the BUG_ON (as seen on TV and 2.5) define to
the 2.4 kernel.  This will help in portability and back-porting from 2.5
to 2.4, plus BUG_ON is a nice optimization and aids readability.

For the unaware, BUG_ON(condition) calls bug on !condition, which is
marked unlikely().

This is the generalized arch-independent BUG_ON as in later 2.5 kernels.

Marcelo, please apply.

	Robert Love

--- linux-2.4.18-pre7/include/linux/kernel.h	Thu Jan 24 13:48:18 2002
+++ linux/include/linux/kernel.h	Fri Jan 25 17:53:54 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


             reply	other threads:[~2002-01-25 23:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-25 23:14 Robert Love [this message]
2002-01-26  3:17 ` [PATCH] add BUG_ON to 2.4 #1 John Levon
2002-01-26  3:22   ` Robert Love
2002-01-26  3:27     ` John Levon

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=1012000446.3799.77.camel@phantasy \
    --to=rml@tech9.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.