[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0703091808490.5714@CPE00045a9c397f-CM001225dbafb6>
Date: Fri, 9 Mar 2007 18:09:58 -0500 (EST)
From: "Robert P. J. Day" <rpjday@...dspring.com>
To: Rusty Russell <rusty@...tcorp.com.au>
cc: lkml - Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Use more gcc extensions in the Linux headers
On Sat, 10 Mar 2007, Rusty Russell wrote:
> On Fri, 2007-03-09 at 16:56 +1100, Rusty Russell wrote:
> > __builtin_types_compatible_p() has been around since gcc 2.95, and we
> > don't use it anywhere. This patch quietly fixes that.
>
> OK, many people complained that it needed a comment. Good point!
> ==
> Add comment to ARRAY_SIZE macro.
>
> Signed-off-by: Rusty Russell <rusty@...tcorp.com.au>
>
> diff -r 933e410f204f include/linux/kernel.h
> --- a/include/linux/kernel.h Sat Mar 10 09:55:31 2007 +1100
> +++ b/include/linux/kernel.h Sat Mar 10 09:55:53 2007 +1100
> @@ -35,6 +35,7 @@ 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))
>
> +/* GCC is awesome. */
> #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) \
> + sizeof(typeof(int[1 - 2*!!__builtin_types_compatible_p(typeof(arr), \
> typeof(&arr[0]))]))*0)
ah, but is that "universe" kind of awesome, or the "hot dogs" kind of
awesome?
http://youtube.com/watch?v=0rYT0YvQ3hs
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists