[RFC] Splitting kernel headers and deprecating __KERNEL__

From: David Howells
Date: Fri Nov 26 2004 - 18:03:01 EST



We've been discussing splitting the kernel headers into userspace API headers
and kernel internal headers and deprecating the __KERNEL__ macro. This will
permit a cleaner interface between the kernel and userspace; and one that's
easier to keep up to date.

What we've come up with is this:

(1) Create new directories in the linux sources to shadow existing include
directories:

NEW DIRECTORY DIRECTORY SHADOWED
============= ==================
include/user/ include/linux/
include/user-*/ include/asm-*/

Note that this doesn't take account of the other directories under
include/, but I don't think they're relevant.

(2) Take each file from the shadowed directory. If it has any userspace
relevant stuff, then:

(a) Transfer this stuff into a file of the same name in the new
directory. So, for example, the syscall number list from
include/asm-i386/unistd.h will be transferred to
include/user-i386/unistd.h.

(b) Make kernel file #include the user file. So:

[include/asm-i386/unistd.h]
...
#include <user-i386/unistd.h>
...

(c) Where a user header file requires something from another header file
(such as a type), that file should include a suitable user header file
directly:

[include/user-i386/termio.h]
...
#include <user/types.h>
...

(d) stdint types should be used where possible.

[include/user-i386/termios.h]
struct winsize {
uint16_t ws_row;
uint16_t ws_col;
uint16_t ws_xpixel;
uint16_t ws_ypixel;
};

(e) These header files should be bounded with __USER_XXXXX_H conditionals:

[include/user-i386/termios.h]
#ifndef __USER_I386_TERMIOS_H
#define __USER_I386_TERMIOS_H
...
#endif /* __USER_I386_TERMIOS_H */

(3) Remove all #if(n)def __KERNEL__ clauses.

(4) Remove the -D__KERNEL__ from the master kernel Makefile.

(5) For userspace use (such as for glibc), the appropriate include/user*/
directories should be selected and installed in /usr/include/ or wherever,
and symlinks made. For example, on i386 arch boxes, you might find:

SOURCE INSTALLED AS
====================== ============
include/user/ /usr/include/user/
include/user-i386/ /usr/include/user-i386/
/usr/include/linux -> user
/usr/include/asm -> user-i386

(6) On multi-arch archs (such as ppc64 which can also support ppc), you might
find:

SOURCE INSTALLED AS
====================== ============
include/user/ /usr/include/user/
include/user-ppc/ /usr/include/user-ppc/
include/user-ppc64/ /usr/include/user-ppc64/
/usr/include/linux -> user
/usr/include/asm-ppc -> user-ppc
/usr/include/asm-ppc64 -> user-ppc64

And then /usr/include/asm/ might contain files that do arch-size dependent
switching between user-ppc and user-ppc64.


David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/