public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use more gcc extensions in the Linux headers
@ 2007-03-09  5:56 Rusty Russell
  2007-03-09  6:22 ` Stephen Rothwell
                   ` (6 more replies)
  0 siblings, 7 replies; 29+ messages in thread
From: Rusty Russell @ 2007-03-09  5:56 UTC (permalink / raw)
  To: lkml - Kernel Mailing List; +Cc: Linus Torvalds, Andrew Morton

__builtin_types_compatible_p() has been around since gcc 2.95, and we
don't use it anywhere.  This patch quietly fixes that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff -r f0ff8138f993 include/linux/kernel.h
--- a/include/linux/kernel.h	Fri Mar 09 16:40:25 2007 +1100
+++ b/include/linux/kernel.h	Fri Mar 09 16:44:04 2007 +1100
@@ -35,7 +35,9 @@ extern const char linux_proc_banner[];
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])			      \
+	+ sizeof(typeof(int[1 - 2*!!__builtin_types_compatible_p(typeof(arr), \
+		 typeof(&arr[0]))]))*0)
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))



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

end of thread, other threads:[~2007-03-11 21:41 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09  5:56 [PATCH] Use more gcc extensions in the Linux headers Rusty Russell
2007-03-09  6:22 ` Stephen Rothwell
2007-03-09  6:35 ` Linus Torvalds
2007-03-09  6:50 ` Andrey Panin
2007-03-09  7:53   ` Christoph Hellwig
2007-03-09  9:02     ` Andrey Panin
2007-03-09  9:05       ` Christoph Hellwig
2007-03-09 17:47         ` Linus Torvalds
2007-03-10 20:36           ` Trent Piepho
2007-03-09  7:52 ` Christoph Hellwig
2007-03-09  8:35   ` Jarek Poplawski
2007-03-09 11:27 ` Theodore Ts'o
2007-03-09 16:52 ` Andi Kleen
2007-03-09 22:57 ` Rusty Russell
2007-03-09 23:02   ` Randy Dunlap
2007-03-09 23:09   ` Robert P. J. Day
2007-03-09 23:12   ` Roland Dreier
2007-03-10  1:04   ` Jan Engelhardt
2007-03-11  2:50     ` Rusty Russell
2007-03-11  2:58       ` Jan Engelhardt
2007-03-11  3:19         ` Rusty Russell
2007-03-11 21:40       ` Valdis.Kletnieks
2007-03-10  4:03   ` Valdis.Kletnieks
2007-03-10  4:24     ` Randy Dunlap
2007-03-11 15:56       ` Valdis.Kletnieks
2007-03-10  5:19     ` Nigel Cunningham
2007-03-10 14:01       ` Jan Engelhardt
2007-03-10 15:18         ` Andreas Schwab
2007-03-10 16:53           ` Jan Engelhardt

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