Re: uml fails to compile due to missing offsetof

Roland Dreier
2006-11-19T17:08:50Z

> I fail to see how arch/um/sys-i386/user-offsets.c can compile since
> offsetof() was declared __KERNEL__ only in include/linux/stddef.h.
> Does it work for anyone else? If so, is linux/stddef.h or
> /usr/include/linux/stddef.h used during compilation?
> The x86_64 variant looks weird as well, linux/stddef.h is appearently
> included via some other headers.

Yes, the

#include <linux/stddef.h>

looks weird to me. AFAIK the C standard says that offsetof() comes
from plain old <stddef.h>. Does the (untested) patch below fix the
build for you?

diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 6f4ef2b..447306b 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -2,7 +2,7 @@ #include <stdio.h>
#include <signal.h>
#include <asm/ptrace.h>
#include <asm/user.h>
-#include <linux/stddef.h>
+#include <stddef.h>
#include <sys/poll.h>

#define DEFINE(sym, val) \