svn commit: r327447 - head/sys/sys

Gleb Smirnoff glebius at FreeBSD.org
Wed Jan 17 23:14:39 UTC 2018


On Tue, Jan 02, 2018 at 09:56:09AM -0800, John Baldwin wrote:
J> > this is a recurring issue. Program that want to look into the 
J> > internals of files such as mount.h
J> > and define _KERNEL to allow themselves to do so.  It eventualy leads 
J> > to all sorts of confusion and pollution.
J> > Maybe we should make a policy on how to do this. At $JOB I had to hack 
J> > it to define a
J> > #ifdef _NOTREALLYKERNEL to split out parts we really wanted, but it 
J> > would be better to have specific ones for
J> > various specific 'rule breakers'..
J> > e.g.
J> > #if defined( _KERNEL ) || defined (WANT_TO_LOOK_AT_something)
J> > 
J> > kdump seems ot do the right thing with:
J> > 
J> > kdump/kdump.c:#define _WANT_KERNEL_ERRNO
J> > errno.h:#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO)
J> 
J> The past few years we have been using _WANT_FOO when new things need to be
J> exposed and that is our current pattern.  However, that doesn't fix existing
J> code for old things.

As one who added a lot of _WANT_FOOs, I must admit that I don't consider
that a final and clean solution. But this seems to be a lesser evil when
dealing with old code that has multiple dependencies.

New code needs to be written in a fashion that clearly separates kernel
structures from user visible structures, so that no tricks with preprocessor
are needed.

-- 
Gleb Smirnoff


More information about the svn-src-all mailing list