aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-09-13 04:25:13 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-13 11:22:28 -0400
commit921717a2a1cde78c9b2aa971c16510d63efe7320 (patch)
tree500ce20507a4c75e1e179492b7d70f2135e1ca94 /include/linux/kernel.h
parent0f3d2bd54f8fb178f516fc6903366e16e20f7428 (diff)
[PATCH] Make BUILD_BUG_ON fail at compile time.
Force a compiler error instead of a link error, because they are easier to track down. Idea stolen from code by Jan Beulich <jbeulich@novell.com> If the argument to BUILD_BUG_ON evaluates to non-zero the compiler will do: t.c:6: error: size of array `type name' is negative (surprised that gcc doesn't have an extension for this) Signed-off-by: "Andi Kleen" <ak@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 687ba8c9973d..4367ce4db52a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -307,8 +307,8 @@ struct sysinfo {
307 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ 307 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
308}; 308};
309 309
310extern void BUILD_BUG(void); 310/* Force a compilation error if condition is false */
311#define BUILD_BUG_ON(condition) do { if (condition) BUILD_BUG(); } while(0) 311#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
312 312
313#ifdef CONFIG_SYSCTL 313#ifdef CONFIG_SYSCTL
314extern int randomize_va_space; 314extern int randomize_va_space;