Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>

From: Arnd Bergmann
Date: Mon Apr 04 2022 - 04:02:12 EST


On Mon, Apr 4, 2022 at 9:41 AM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>
> On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> > If we can make kernel headers self-contained (that is, none of exported
> > kernel headers includes system headers), we will be able to add the
> > -nostdinc flag, but that is much far from where we stand now.
>
> What is still missing for that?

One case that I don't know how to solve is

include/uapi/sound/asound.h:typedef struct { unsigned char
pad[sizeof(time_t) - sizeof(int)]; } __time_pad;

Here we define a structure layout based on a libc-provided type. There are two
possible variants (32-bit and 64-bit time_t), and the kernel interface
can handle
both versions because they get different ioctl command numbers, but user space
must see the one that matches its normal time_t.

There are a couple of similar cases like this, but I think the other ones don't
need to define architecture specific padding like this.

Arnd