Re: Header files and the kernel ABI

H. Peter Anvin
2002-07-25T07:04:30Z

Andreas Dilger wrote:
>
> I had thought on this briefly in the past, and my take would be for these
> ABI definition files to live directly in /usr/include/linux for user space
> (just as glibc puts its own sanitized copy of the kernel headers there)
> and the appropriate ABI headers are included as needed from the kernel.
>

Given no legacy, I would agree with this, but I think it would imply bad
legacy both on the kernel and the libc (it's not just glibc, either) side.

> The kernel side would be something like <linux/scsi.h> includes
> <linux/abi/scsi.h> or whatever, but in the future this can be included
> directly as needed throughout the kernel. The existing kernel
> <linux/*.h> headers would also have extra kernel-specific data in them.
>
> The same could be done with the user-space headers, but I think that
> is missing the point that the linux/abi/*.h headers should define _all_
> of the abi, so we may as well just use that directly.

Except now the paths are gratuitously different between kernel
programming and non-kernel programming, and we create a much harder
migration problem. I'd rather leave the linux/* namespace to the
user-space libc to do whatever backwards compatibility cruft they may
consider necessary, for example, <linux/io.h> might #include <sys/io.h>
since some user space apps bogusly included the former name. Leaving
that namespace available for backwards compatibility hacks avoids those
kinds of problems.

> Essentially "all" this would mean is that we take the existing headers,
> remove everything which is inside #ifdef __KERNEL__ (and all of the
> other kernel-specific non-abi headers that are included) and we are
> done. The kernel header now holds only things that were inside the
> #ifdef __KERNEL__ (or should have been), and #include <linux/abi/foo.h>.

Exactly.

-hpa