summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2004-09-07 18:00:28 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-07 18:00:28 -0700
commit7f5b660168a7c5aa405be819787ad67791faa8d0 (patch)
treeec5d0c951a6b16b20de53d6a241e84c798f263a0 /include/linux
parent50baf47ee1b944404cf28f03de265f6b72ad4dd2 (diff)
[PATCH] Work around gcc 3.5 offsetof bug
Current gcc 3.5 doesn't compile a x86-64 kernel, because it doesn't recognize the offsetof used in asm-offset.c to be constant. Use __builtin_offsetof for this instead. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/compiler-gcc3.h4
-rw-r--r--include/linux/stddef.h6
2 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
index 54a461e06614..eec2f88c4301 100644
--- a/include/linux/compiler-gcc3.h
+++ b/include/linux/compiler-gcc3.h
@@ -28,3 +28,7 @@
#if __GNUC_MINOR__ >= 4
#define __must_check __attribute__((warn_unused_result))
#endif
+
+#if __GNUC_MINOR__ >= 5
+#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
+#endif
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index dfa23221524e..b3a2cadf90f2 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_STDDEF_H
#define _LINUX_STDDEF_H
+#include <linux/compiler.h>
+
#undef NULL
#if defined(__cplusplus)
#define NULL 0
@@ -9,6 +11,10 @@
#endif
#undef offsetof
+#ifdef __compiler_offsetof
+#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
+#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
#endif