tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/arch/powerpc/oea



On Mon, Nov 15, 2010 at 10:41:55PM +0000, David Laight wrote:
 > > Indeed. Properly speaking though, headers that are exported to
 > > userland should define only the precise symbols that userland needs;
 > > kernel-only material should be kept elsewhere.
 > 
 > One start would be to add a sys/proc_internal.h so that sys/proc
 > can be reduced to only stuff that userspace and some kernel parts
 > are really expected to use.

The right way (TM) is to create src/sys/include and put kernel-only
headers in there, to be included as e.g. <proc.h>.

In the long term the user-visible parts would go in
src/sys/include/kern/proc.h, which would be included as <kern/proc.h>.

(It has to be kern/ and not sys/ because a couple decades of standards
creep and poor API maintenance has led to half of sys/*.h properly
belonging to libc. In order to avoid repeating this problem in the
future, all APIs should be defined without direct reference to any
kern/*.h files; those should only be included from other libc or
kernel headers. So libc would grow its own <sys/proc.h> because that's
part of the libkvm API.)

When done completely the entire kern/ subtree is the same for both
userland and the kernel, including MD headers, no other random kernel
headers need to be installed, and there's no longer any need for
#ifdef _KERNEL.

As much as this probably sounds obvious, the first couple of times I
set out to do it myself I got it wrong. (And it's wrong in Linux too.)

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index