lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 10 Mar 2007 12:36:41 -0800 (PST)
From:	Trent Piepho <xyzzy@...akeasy.org>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
cc:	Christoph Hellwig <hch@...radead.org>,
	Rusty Russell <rusty@...tcorp.com.au>,
	lkml - Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Use more gcc extensions in the Linux headers

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]).
-
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ