Thread (21 messages) 21 messages, 6 authors, 2021-11-23

Re: [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code

From: Arnd Bergmann <arnd@arndb.de>
Date: 2021-11-19 16:25:32
Also in: intel-gfx, linux-acpi, linux-btrfs, linux-scsi, lkml, netdev, virtualization

On Fri, Nov 19, 2021 at 5:12 PM Alejandro Colomar (man-pages)
[off-list ref] wrote:
On 11/19/21 16:57, Arnd Bergmann wrote:
quoted
From what I can tell, linux/stddef.h is tiny, I don't think it's really
worth optimizing this part. I have spent some time last year
trying to untangle some of the more interesting headers, but ended
up not completing this as there are some really hard problems
once you start getting to the interesting bits.
In this case it was not about being worth it or not,
but that the fact that adding memberof() would break,
unless I use 0 instead of NULL for the implementation of memberof(),
which I'm against, or I split stddef.

If I don't do either of those,
I'm creating a circular dependency,
and it doesn't compile.
Sorry for missing the background here, but I don't see what that
dependency is. If memberof() is a macro, then including the definition
should not require having the NULL definition first, you just need to
have both at the time you use it.
quoted
The main issue here is that user space code should not
include anything outside of include/uapi/ and arch/*/include/uapi/
Okay.  That's good to know.

So everything can use uapi code,
and uapi code can only use uapi code,
right?
Correct.
quoted
offsetof() is defined in include/linux/stddef.h, so this is by
definition not accessible here. It appears that there is also
an include/uapi/linux/stddef.h that is really strange because
it includes linux/compiler_types.h, which in turn is outside
of uapi/. This should probably be fixed.
I see.
Then,
perhaps it would be better to define offsetof() _only_ inside uapi/,
and use that definition from everywhere else,
and therefore remove the non-uapi version,
right?
No, because the user-space <stddef.h> provided by the compiler
also includes an offsetof() definition. In the uapi/ namespace, the
kernel must only provide definitions that do not clash with anything
in user space.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help