public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.4: BUG_ON (1/2)
@ 2002-03-21  0:15 Robert Love
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2002-03-21  0:15 UTC (permalink / raw)
  To: marcelo, alan; +Cc: linux-kernel

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


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

* [PATCH] 2.4: BUG_ON (1/2)
@ 2002-04-03  2:59 Robert Love
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2002-04-03  2:59 UTC (permalink / raw)
  To: marcelo, alan; +Cc: linux-kernel

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();

This is not really about sprinkling BUG_ONs everywhere but helping
backporting.  And I like BUG_ON :)

This patch is against 2.4.19-pre5, but also applies to 2.4.19-pre4-ac3. 
Alan and Marcelo - please apply.

        Robert Love

diff -urN linux-2.4.19-pre5/include/linux/kernel.h linux/include/linux/kernel.h
--- linux-2.4.19-pre5/include/linux/kernel.h	Sat Mar 30 18:26:41 2002
+++ linux/include/linux/kernel.h	Sat Mar 30 18:30:18 2002
@@ -184,4 +184,6 @@
 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
 };
 
-#endif
+#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
+
+#endif /* _LINUX_KERNEL_H */


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

end of thread, other threads:[~2002-04-03  3:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-03  2:59 [PATCH] 2.4: BUG_ON (1/2) Robert Love
  -- strict thread matches above, loose matches on Subject: below --
2002-03-21  0:15 Robert Love

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