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]
Message-Id: <1173581437.32234.168.camel@localhost.localdomain>
Date:	Sun, 11 Mar 2007 13:50:37 +1100
From:	Rusty Russell <rusty@...tcorp.com.au>
To:	Jan Engelhardt <jengelh@...ux01.gwdg.de>
Cc:	lkml - Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Andi Kleen <ak@...e.de>
Subject: Re: [PATCH] Use more gcc extensions in the Linux headers

On Sat, 2007-03-10 at 02:04 +0100, Jan Engelhardt wrote:
> Getting back at the macro, how would you like to have it merged?

Well, this is what I sent to Linus and Andrew (many thanks to those who
made appropriately whimsical *or* useful comments):

diff -r 1ccdf46b0f41 include/linux/compiler-gcc.h
--- a/include/linux/compiler-gcc.h	Sat Mar 10 09:55:29 2007 +1100
+++ b/include/linux/compiler-gcc.h	Sat Mar 10 11:06:35 2007 +1100
@@ -22,6 +22,9 @@
     __asm__ ("" : "=r"(__ptr) : "0"(ptr));		\
     (typeof(ptr)) (__ptr + (off)); })
 
+/* &a[0] degrades to a pointer: a different type from an array */
+#define __must_be_array(a) \
+  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
 
 #define inline		inline		__attribute__((always_inline))
 #define __inline__	__inline__	__attribute__((always_inline))
diff -r 1ccdf46b0f41 include/linux/compiler-intel.h
--- a/include/linux/compiler-intel.h	Sat Mar 10 09:55:29 2007 +1100
+++ b/include/linux/compiler-intel.h	Sat Mar 10 11:06:25 2007 +1100
@@ -21,4 +21,7 @@
      __ptr = (unsigned long) (ptr);				\
     (typeof(ptr)) (__ptr + (off)); })
 
+/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */
+#define __must_be_array(a) 0
+
 #endif
diff -r 1ccdf46b0f41 include/linux/kernel.h
--- a/include/linux/kernel.h	Sat Mar 10 09:55:29 2007 +1100
+++ b/include/linux/kernel.h	Sat Mar 10 11:06:16 2007 +1100
@@ -35,7 +35,8 @@ 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]) + __must_be_array(arr))
+
 #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))


-
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