Skip to contentSkip to conversation

uml fails to compile due to missing offsetof

DISCUSSION Olaf Hering 3 participants 7 messages Nov 19, 2006 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 4 lines · Olaf Hering

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?

It obviously works for me. offsetof is very standard C. I'd venture to say that a system which can't find it has a broken gcc installation.

Quoted 2 lines

If so, is linux/stddef.h or /usr/include/linux/stddef.h used during compilation?

/usr/include/linux/stddef.h (but see below) - this is a userspace file, so it builds against libc headers.

Quoted 2 lines

The x86_64 variant looks weird as well, linux/stddef.h is appearently included via some other headers.

Well, /usr/include/linux/stddef.h on my x86_64 box has no offsetof, despite being FC5 just like my i386 laptop. Yay for consistency.

However, there is a /usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h which defines offsetof (and there's a corresponding file on my laptop), so I bet that's the true source of offsetof.

Jeff

Signature · 1 line
Work email - jdike at linux dot intel dot com
#2 lore raw
Quoted 8 lines · Jeff Dike
Quoted 4 lines · Olaf Hering

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?

It obviously works for me. offsetof is very standard C. I'd venture to say that a system which can't find it has a broken gcc installation.

How do you get _STDDEF_H defined in /usr/lib/gcc/<target>/<vers>/include/stddef.h ?
For me _STDDEF_H remains undefined, and /usr/include/linux/stddef.h has offsetof inside __KERNEL__.

#4 lore raw
In reply to Olaf Hering
Quoted 6 lines

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?

arch/um/sys-i386/user-offsets.c +1 -1
index 6f4ef2b..447306b 100644
@@ -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) \
#5 lore raw
Quoted 3 lines · Roland Dreier

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?

Yes, it does.

#3 lore raw
In reply to Olaf Hering
Quoted 4 lines · Olaf Hering

How do you get _STDDEF_H defined in /usr/lib/gcc/<target>/<vers>/include/stddef.h ?
For me _STDDEF_H remains undefined, and /usr/include/linux/stddef.h has offsetof inside __KERNEL__.

I guess that the __KERNEL__ is your problem. I don't see that anything like that has any business being in the libc headers. In the other case of this that I looked at, the stuff in /usr/include/linux/ had been replaced by (or /usr/include/linux symlinked to) a kernel include/linux.

Jeff

Signature · 1 line
Work email - jdike at linux dot intel dot com
#6 lore raw
In reply to Roland Dreier
Quoted 2 lines · Roland Dreier

looks weird to me. AFAIK the C standard says that offsetof() comes from plain old <stddef.h>.

Yes, sorry.

Fixed in my tree, will be send to mainline shortly.

Jeff

Signature · 1 line
Work email - jdike at linux dot intel dot com