Subject: Re: _KERNEL cpp symbol in kernel source
To: Allen Briggs <briggs@ninthwonder.com>
From: None <nigel@ind.tansu.com.au>
List: port-mac68k
Date: 07/21/1999 15:09:43
> As (several) someone else(s) pointed out, this is not good practice.
> I'd like to fix any of these that you locate, Nigel.

	Cool. Note that I haven't tried to compile any kernels under
NetBSD with these changes, so they may break something. Here are the
ones I (or rather, CodeWarrior) have found so far:



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.



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)

   * 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 :-)


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

   * 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




	That's all for now!

-- 
| Nigel Pearson, nigel@ind.tansu.com.au | "reality  is  that  which  |
|  Telstra IN&IND, Sydney, Australia.   |  doesn't go away when you  |
| Office: 9206 3468    Fax:  9212 6329  |  stop  believing  in  it." |
| Mobile: 0408 664435  Home: 9579 3293  |       Philip K. Dick       |