lkml.org 
[lkml]   [2004]   [Nov]   [29]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
From(H. Peter Anvin)
SubjectRe: [RFC] Splitting kernel headers and deprecating __KERNEL__
DateMon, 29 Nov 2004 20:01:39 +0000 (UTC)
Followup to:  <19865.1101395592@redhat.com>
By author:    David Howells <dhowells@redhat.com>
In newsgroup: linux.dev.kernel
> 
> 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.
> 

I'm not sure if user is a good choice, and user-* is even worse.  Most
people seem to have suggested include/linux-abi for this; I would
personally prefer include/linux-abi/arch for the second.

>  (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.

I'm not sure you can do such a 1:1 mapping.  In fact, there are cases
where you definitely don't want to, because the current structure
doesn't make much sense.

> 
>      (b) Make kernel file #include the user file. So:
> 
> 		[include/asm-i386/unistd.h]
> 		...
> 		#include <user-i386/unistd.h>
> 		...

Good...

>      (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>
> 		...

Good...

>      (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;
> 		};

Good, except your "struct winsize" is bad; you're stepping on
namespace which belongs to userspace.  Since we can't use typedefs on
struct tags, I suggest:

struct __kstruct_winsize {
       /* ... */
};
.. and userspace can do:

#define __kstruct_winsize winsize

>      (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 */

Good...

>  (3) Remove all #if(n)def __KERNEL__ clauses.
> 
>  (4) Remove the -D__KERNEL__ from the master kernel Makefile.

Bad!  There is code in the kernel which can compile in userspace for
testing.  This is highly valuable and should be kept.

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

\
 
 \ /
  Last update: 2005-03-22 14:08    [from the cache]
©2003-2008