public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Use more gcc extensions in the Linux headers
Date: Fri, 9 Mar 2007 07:52:45 +0000	[thread overview]
Message-ID: <20070309075245.GD8798@infradead.org> (raw)
In-Reply-To: <1173419792.32234.131.camel@localhost.localdomain>

On Fri, Mar 09, 2007 at 04:56:32PM +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.
> 
> 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)

This needs a comment explaning why we're doing this, and maybe a little
explanation of the combination of gcc magic and C trickery used to implement
it to the brave non-uberhacker people trying to understand linux headers.


  parent reply	other threads:[~2007-03-09  7:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20070309075245.GD8798@infradead.org \
    --to=hch@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox