From: Trent Piepho <xyzzy@speakeasy.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>,
Rusty Russell <rusty@rustcorp.com.au>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Use more gcc extensions in the Linux headers
Date: Sat, 10 Mar 2007 12:36:41 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.58.0703101229090.15510@shell4.speakeasy.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0703090938450.10832@woody.linux-foundation.org>
On Fri, 9 Mar 2007, Linus Torvalds wrote:
> On Fri, 9 Mar 2007, Christoph Hellwig wrote:
> Well, since Rusty's macro was hoddible *anyway*, I don't think I'd apply
> it as-is. Breaking icc for something that ugly and not-very-important
> simply makes no sense.
>
> There are better ways to do this.
>
> For one, you could (and should!) abstract these kinds of things out,
> rather than put them in another macro that really does something totally
> different. Then, the macro could have become
>
> #define ARRAY_SIZE (sizeof_expression + 0*error_if_not_array)
/* Error if X is a pointer, 0 otherwise */
#define ERROR_IF_POINTER(x) \
sizeof(int[-__builtin_types_compatible_p(typeof(x), typeof(&x[0]))])
/* Warning (div by zero) if x is a pointer, 0 otherwise */
#define WARN_IF_POINTER(x) \
(0/!__builtin_types_compatible_p(typeof(x), typeof(&x[0])))
The gcc docs say __builtin_types_compatible_p returns 1 or 0, so the !!
isn't necessary. And my gcc at least returns 0 for sizeof(int[0]).
next prev parent reply other threads:[~2007-03-10 20:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-09 5:56 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 [this message]
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
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=Pine.LNX.4.58.0703101229090.15510@shell4.speakeasy.net \
--to=xyzzy@speakeasy.org \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.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
all inboxes | Powered by JetHome®