Subject: Re: _KERNEL cpp symbol in kernel source
To: None <nigel@ind.tansu.com.au>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: port-mac68k
Date: 07/21/1999 12:46:09
On Wed, 21 Jul 1999 nigel@ind.tansu.com.au wrote:

> 1) Files that have variables declared locally that should be externs:
> 
>    * arch/mac68k/pmap.h      - line 170 (you already found this)
>    * miscfs/specfs/specdev.h - line 74
>    * sys/buf.h               - lines 154-158
>    * sys/namei.h             - line 176
>    * sys/proc.h              - lines 309,319,320
>    * sys/vmmeter.h           - line 60
>    * sys/vnode.h             - line 357
>    * vm/vm_object.h          - lines 127-129,131-133,136,137
> 
>    * Both vfs_cache.c and ufs_lookup.c define nchstats.

Before zapping these, ask on tech-kern. Because you'll have to include the
static definition somewhere. :-)

> 2) Files that include "opt_blah.h" style files unconditionally:
> 
>    (From my understanding, these should have something like
> 	#ifndef _LKM
> 	#endif
>     or
> 	#if defined(_KERNEL) && !defined(_LKM)
> 	#endif
>     around them)

The current policy is that _headder_ files need the conditionalization.
:-)

>    * arch/m68k/{fpe/fpu_emulate.c,m68k/{db_interface.c,sig_machdep.c}}
> 
>    * arch/mac68k/
> 	dev/{adb.c,adb_direct.c,adbsys.c,adbsysasm.s,aed.c,grf.c,\
>              grf_subr.c,if_mc.c,if_sn.c,ite.c,md_root.c,pm_direct.c,\
>              sbc.c,zs.c}
>    * arch/mac68k/
> 	mac68k/{intr.c,locore.s,machdep.c,macrom.c,macromasms.c,\
> 		pmap_bootstrap.c,pram.c,pramasm.c,trap.c,via.c}
>    * arch/mac68k/nubus/{grf_nubus.c,if_sn_nubus.c}
>    * arch/mac68k/obio/{grf_obio.c,if_mc_obio.c,if_sn_obio.c}
> 
>    * Most of uvm
> 
>    * ufs/{ufs_inode.c,ufs_vfsops.c,ufs_vnops.c}
> 
>    * vfs/{vfs_lookup.c,vfs_subr.c,vfs_syscalls.c}
> 
>    (sorry for the CSH-style syntax :-)

If we need these files, I think we need to fake up opt_ files for them.
For these files, the opt_ files contain personality defines - how the
code's supposed to work.

> 3) Other strange things:
> 
>    * sys/vnode.h defines some structure offset macros
>      (e.g. VOPARG_OFFSET) which kern/vnode_if.c uses.
> 
>      Most C implementations, however, already have a
>      macro for this: offsetof(), from stddef.h

Might be due to the ancestry of the code. ??

>    * I could not find fs_union.h and had to fake it, along with all
>      of the opt_*.h files, by an empty file of the appropriate name

fs_union.h, and fs_lfs.h, fs_mfs.h, fs_nfs.h, fs_coda.h, and fs_kernfs.h
seem to be generated for these fs's.

You only need fs_union.h so that vn_readdir can do the right thing for
union mounts. Touching an empty file should be fine.

Take care,

Bill