Skip to contentSkip to conversation

BUG_ON() not arch-specific.

PATCH In review Rusty Russell 3 participants 4 messages Dec 5, 2001 – Dec 8, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 BUG_ON() not arch-specific.

Hi all,

We only need one BUG_ON implementation, surely. Genericized
and moved to linux/kernel.h.

Cheers,
Rusty.

include/linux/kernel.h +1 -0
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/linux/kernel.h working-2.5.1-pre5-percpu/include/linux/kernel.h
@@ -176,4 +176,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
include/asm-alpha/page.h +0 -12
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/asm-alpha/page.h working-2.5.1-pre5-percpu/include/asm-alpha/page.h
@@ -67,18 +67,6 @@
 
 #define PAGE_BUG(page)	BUG()
 
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((long)(condition)))\
-			BUG();			\
-	} while (0)
-
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((int)(condition)))	\
-			BUG();			\
-	} while (0)
-
 /* Pure 2^n version of get_order */
 extern __inline__ int get_order(unsigned long size)
 {
include/asm-i386/page.h +0 -6
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/asm-i386/page.h working-2.5.1-pre5-percpu/include/asm-i386/page.h
@@ -101,12 +101,6 @@
 	BUG(); \
 } while (0)
 
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((int)(condition)))	\
-			BUG();			\
-	} while (0)
-
 /* Pure 2^n version of get_order */
 static __inline__ int get_order(unsigned long size)
 {

--
Premature optmztion is rt of all evl. --DK

#1 lore raw
Quoted 4 lines · Rusty Russell

Hi all,

We only need one BUG_ON implementation, surely. Genericized
and moved to linux/kernel.h.

Yes, fine.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to Rusty Russell

include/linux/kernel.h line 179

Quoted 7 lines · [email protected] said:
include/linux/kernel.h +1 -0
@@ -176,4 +176,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)

You'll need to add #include <linux/compiler.h> to linux/kernel.h if you do that. Let's not make the include files any more broken than they already are :)

--
dwmw2

#3 lore raw

In message <[email protected]> you write:

Quoted 3 lines

You'll need to add #include <linux/compiler.h> to linux/kernel.h if you do that. Let's not make the include files any more broken than they already are :)

Ack. Linus, please apply.

include/linux/kernel.h +2 -0
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/linux/kernel.h working-2.5.1-pre5-percpu/include/linux/kernel.h
@@ -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 */
@@ -176,4 +177,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
include/asm-alpha/page.h +0 -12
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/asm-alpha/page.h working-2.5.1-pre5-percpu/include/asm-alpha/page.h
@@ -67,18 +67,6 @@
 
 #define PAGE_BUG(page)	BUG()
 
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((long)(condition)))\
-			BUG();			\
-	} while (0)
-
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((int)(condition)))	\
-			BUG();			\
-	} while (0)
-
 /* Pure 2^n version of get_order */
 extern __inline__ int get_order(unsigned long size)
 {
include/asm-i386/page.h +0 -6
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.1-pre5/include/asm-i386/page.h working-2.5.1-pre5-percpu/include/asm-i386/page.h
@@ -101,12 +101,6 @@
 	BUG(); \
 } while (0)
 
-#define BUG_ON(condition)			\
-	do {					\
-		if (unlikely((int)(condition)))	\
-			BUG();			\
-	} while (0)
-
 /* Pure 2^n version of get_order */
 static __inline__ int get_order(unsigned long size)
 {

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.