Date: Fri, 9 Oct 1998 14:00:37 +1000 From: Bruce Evans <bde@zeta.org.au> To: cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, jkh@FreeBSD.ORG Subject: Re: cvs commit: src/lib/libutil libutil.h Message-ID: <199810090400.OAA13981@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
> remove stdio.h include; I forgot Bruce's cardinal rule that header files > shouldn't include other ones (which, unfortunately, is also a hellish > rule since he broke interfaces like sysctl this way by requiring undocumented > header files to be included just in order to be able to use them now - SIGH!). Actually, he broke nothing, and documented the historical prerequisite headers for most of the functions in section 2 and 3 man pages. In particular, for sysctl(3), this just involved adding the not-so-historical prerequisite <sys/types.h> to src/lib/libc/gen/sysctl.3. <sys/sysctl.h> was "broken" by phk in rev.1.26. Before that, it included <sys/types.h> as a side effect of including other pollution (<sys/time.h>, etc.). phk's reorganization of sysctl removed the need for the other pollution, and he apparently removed it without checking for its side effects. The full rule is that headers visible to applications should be self- sufficent. I use the following script for checking for certain regressions in headers. (Disgustingly long) lists of prerequisites can be read off from it. It is not up to date for CAM or HARP. Bruce #!/bin/sh # XXX fix <machine/cons.h>, <machine/mpapic.h> and <pccard/slot.h> to not # refer to the i386 hierarchy. # bus_private.h only depends on bus.h and KERNEL being defined, but bus.h # depends on generated headers if KERNEL is defined. # segments.h uses an unifdefed gcc attribute so it and everything that # includes it break for for non-gcc. # syscall-hide.h uses undefined macros. # sysproto.h conflicts with user lseek() etc. CRUD="(bus_private|cons|mpapic|slot|syscall-hide|sysproto)\.h" NEEDS_ANSI="in_cksum\.h" # Comment out the next line for non-ANSI. NEEDS_ANSI="^/nonesuch$" NEEDS_GCC="(cpu|pcb_ext|segments)\.h" # Comment out the next line for non-gcc. NEEDS_GCC="^/nonesuch$" NEEDS_PROTO="(sys/aio|alias|bios|bus|calendar|dialog|elf|fetch|ftpio|interrupt|libdisk|linker|md2|md4|md5|module|ncurses|pcap-int|pcap-namedb|pcap|posix4|spigot|soundcard|specialreg|strhash|\./timepps|unctrl|vgl)\.h" # Comment out the next line for pure K&R (not for gcc -tradtional). NEEDS_PROTO="^/nonesuch$" for i in `(cd /usr/include; find . -name '*.h' -follow | sort | egrep -v "\./(g\+\+|netns|objc)/" | egrep -v "$CRUD" | egrep -v "$NEEDS_ANSI" | egrep -v "$NEEDS_GCC" | egrep -v "$NEEDS_PROTO")` do echo >z.c if echo $i | egrep -q "\./(isofs|machine|msdosfs|net|netatalk|netinet|netipx|netkey|nfs|pccard|sys|ufs|vm)/"; then echo "#include <sys/types.h>" >>z.c; fi test $i != ./alias.h || echo "#include <sys/types.h> #include <netinet/in.h>" >>z.c test $i != ./arpa/inet.h || echo "#include <sys/types.h> #include <netinet/in.h>" >>z.c test $i != ./dirent.h || echo "#include <sys/types.h>" >>z.c test $i != ./fts.h || echo "#include <sys/types.h>" >>z.c test $i != ./gnuregex.h || echo "#include <sys/types.h>" >>z.c test $i != ./grp.h || echo "#include <sys/types.h>" >>z.c test $i != ./isofs/cd9660/cd9660_mount.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./isofs/cd9660/cd9660_node.h || echo "#include <sys/lock.h> #include <sys/time.h>" >>z.c test $i != ./isofs/cd9660/cd9660_rrip.h || echo "#include <isofs/cd9660/iso.h>" >>z.c test $i != ./libdisk.h || echo "#include <sys/types.h>" >>z.c test $i != ./link.h || echo "#include <sys/types.h> #include <nlist.h>" >>z.c test $i != ./login_cap.h || echo "#include <sys/types.h>" >>z.c test $i != ./md4.h || echo "#include <sys/types.h>" >>z.c test $i != ./md5.h || echo "#include <sys/types.h>" >>z.c test $i != ./mpool.h || echo "#include <db.h>" >>z.c test $i != ./machine/in_cksum.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h>" >>z.c test $i != ./machine/globaldata.h || echo "#include <sys/time.h> #include <machine/tss.h>" >>z.c test $i != ./machine/pmap.h || echo "#include <vm/vm.h> #include <vm/pmap.h>" >>z.c test $i != ./machine/si.h || echo "#include <termios.h> #include <sys/tty.h>" >>z.c test $i != ./machine/specialreg.h || echo "#include <machine/cpufunc.h>" >>z.c test $i != ./mqueue.h || echo "#include <sys/types.h>" >>z.c test $i != ./msdosfs/denode.h || echo "#include <sys/lock.h>" >>z.c test $i != ./msdosfs/msdosfsmount.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./net/bpf.h || echo "#include <sys/time.h>" >>z.c test $i != ./net/hostcache.h || echo "#include <sys/time.h>" >>z.c test $i != ./net/if.h || echo "#include <sys/socket.h> #include <sys/time.h>" >>z.c test $i != ./net/if_arp.h || echo "#include <sys/socket.h>" >>z.c test $i != ./net/if_atm.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h>" >>z.c test $i != ./net/if_mib.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h>" >>z.c test $i != ./net/if_ppp.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h>" >>z.c test $i != ./net/if_pppvar.h || echo "#define NPPP 1 #include <sys/callout.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <net/ppp_defs.h>" >>z.c test $i != ./net/if_slvar.h || echo "#include <sys/param.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <net/slcompress.h>" >>z.c test $i != ./net/if_sppp.h || echo "#include <sys/callout.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h>" >>z.c test $i != ./net/if_tunvar.h || echo "#include <sys/select.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h>" >>z.c test $i != ./net/if_var.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h>" >>z.c test $i != ./net/if_vlan_var.h || echo "#include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/ethernet.h>" >>z.c test $i != ./net/raw_cb.h || echo "#include <sys/socket.h>" >>z.c test $i != ./net/route.h || echo "#include <sys/socket.h>" >>z.c test $i != ./net/slcompress.h || echo "#include <sys/param.h> #include <sys/mbuf.h> #include <sys/time.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h>" >>z.c test $i != ./netatalk/aarp.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/if_ether.h> #include <netatalk/at.h>" >>z.c test $i != ./netatalk/at_var.h || echo "#include <sys/callout.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <netatalk/at.h>" >>z.c test $i != ./netatalk/ddp_var.h || echo "#include <sys/callout.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <net/route.h> #include <netatalk/at.h> #include <netatalk/at_var.h>" >>z.c test $i != ./netinet/icmp_var.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <netinet/ip_icmp.h>" >>z.c test $i != ./netinet/if_ether.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/igmp.h || echo "#include <netinet/in.h>" >>z.c test $i != ./netinet/in_hostcache.h || echo "#include <sys/time.h> #include <net/hostcache.h>" >>z.c test $i != ./netinet/in_pcb.h || echo "#include <sys/socket.h> #include <net/route.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/in_var.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/ip.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h>" >>z.c test $i != ./netinet/ip_auth.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h>" >>z.c test $i != ./netinet/ip_fil.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h>" >>z.c test $i != ./netinet/ip_flow.h || echo "#include <sys/socket.h> #include <net/if.h> #include <net/route.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/ip_frag.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h> #include <netinet/ip_nat.h>" >>z.c test $i != ./netinet/ip_fw.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/ip_icmp.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h>" >>z.c test $i != ./netinet/ip_mroute.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/route.h> #include <netinet/in.h>" >>z.c test $i != ./netinet/ip_nat.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h>" >>z.c test $i != ./netinet/ip_proxy.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h> #include <netinet/tcp.h>" >>z.c test $i != ./netinet/ip_state.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h>" >>z.c test $i != ./netinet/ip_statee.h || echo "#include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip_compat.h> #include <netinet/ip_fil.h> #include <netinet/tcp.h>" >>z.c test $i != ./netinet/ip_var.h || echo "#include <netinet/in.h>" >>z.c test $i != ./netinet/tcp_debug.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip_var.h> #include <netinet/tcp.h> #include <netinet/tcpip.h> #include <netinet/tcp_timer.h> #include <netinet/tcp_var.h>" >>z.c test $i != ./netinet/tcp_var.h || echo "#include <netinet/in.h> #include <netinet/ip_var.h> #include <netinet/tcp.h> #include <netinet/tcpip.h> #include <netinet/tcp_timer.h>" >>z.c test $i != ./netinet/tcpip.h || echo "#include <netinet/in.h> #include <netinet/ip_var.h> #include <netinet/tcp.h> #include <netinet/tcpip.h>" >>z.c test $i != ./netinet/udp_var.h || echo "#include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <netinet/ip_var.h> #include <netinet/udp.h>" >>z.c test $i != ./netipx/ipx_if.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_var.h> #include <netipx/ipx.h>" >>z.c test $i != ./netipx/ipx_ip.h || echo "#include <sys/socket.h> #include <sys/time.h> #include <net/route.h> #include <net/if.h> #include <net/if_var.h> #include <netinet/in.h>" >>z.c test $i != ./netipx/ipx_pcb.h || echo "#include <sys/socket.h> #include <net/route.h> #include <netipx/ipx.h>" >>z.c test $i != ./netipx/spx.h || echo "#include <netipx/ipx.h>" >>z.c test $i != ./netipx/spx_debug.h || echo "#include <netipx/ipx.h> #include <netipx/spx.h>" >>z.c test $i != ./nfs/nfs.h || echo "#include <sys/param.h> #include <sys/time.h> #include <sys/ucred.h> #include <nfs/rpcv2.h>" >>z.c test $i != ./nfs/nfsdiskless.h || echo "#include <sys/param.h> #include <sys/mount.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/ucred.h> #include <net/if.h> #include <netinet/in.h> #include <nfs/nfsproto.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h>" >>z.c test $i != ./nfs/nfsmount.h || echo "#include <sys/param.h> #include <sys/mount.h> #include <sys/time.h> #include <sys/ucred.h> #include <nfs/nfsproto.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h>" >>z.c test $i != ./nfs/nfsnode.h || echo "#include <sys/param.h> #include <sys/mount.h> #include <sys/time.h> #include <sys/ucred.h> #include <sys/vnode.h> #include <nfs/nfsproto.h> #include <nfs/rpcv2.h>" >>z.c test $i != ./nfs/nfsproto.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./nfs/nfsrtt.h || echo "#include <sys/param.h> #include <sys/time.h> #include <sys/mount.h>" >>z.c test $i != ./nfs/nfsrvcache.h || echo "#include <sys/param.h> #include <sys/time.h> #include <sys/ucred.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h>" >>z.c test $i != ./nfs/nqnfs.h || echo "#include <sys/param.h> #include <sys/mount.h> #include <sys/time.h> #include <sys/ucred.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h>" >>z.c test $i != ./nfs/nfsv2.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./pcap-namedb.h || echo "#include <pcap.h>" >>z.c test $i != ./posix4/aio.h || echo "#include <sys/types.h>" >>z.c test $i != ./posix4/mqueue.h || echo "#include <sys/types.h>" >>z.c test $i != ./protocols/dumprestore.h || echo "#include <sys/types.h> #include <ufs/ufs/dinode.h>" >>z.c test $i != ./protocols/routed.h || echo "#include <sys/types.h> #include <sys/socket.h>" >>z.c test $i != ./protocols/talkd.h || echo "#include <sys/types.h> #include <sys/socket.h>" >>z.c test $i != ./protocols/timed.h || echo "#include <sys/param.h> #include <sys/time.h>" >>z.c test $i != ./pthread_np.h || echo "#include <sys/types.h> #include <pthread.h>" >>z.c test $i != ./readline/readline.h || echo "#include <stdio.h>" >>z.c test $i != ./regex.h || echo "#include <sys/types.h>" >>z.c test $i != ./resolv.h || echo "#include <sys/types.h> #include <netinet/in.h>" >>z.c if echo $i | grep -q "\./rpc/"; then echo "#include <rpc/types.h>" >>z.c; fi test $i != ./rpc/auth.h || echo "#include <rpc/xdr.h>" >>z.c test $i != ./rpc/auth_des.h || echo "#include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpc/auth_unix.h || echo "#include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpc/clnt.h || echo "#include <sys/types.h> #include <netinet/in.h> #include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpc/pmap_clnt.h || echo "#include <sys/types.h> #include <netinet/in.h> #include <rpc/xdr.h> #include <rpc/auth.h> #include <rpc/clnt.h>" >>z.c test $i != ./rpc/pmap_prot.h || echo "#include <rpc/xdr.h>" >>z.c test $i != ./rpc/pmap_rmt.h || echo "#include <rpc/xdr.h>" >>z.c test $i != ./rpc/rpc_msg.h || echo "#include <sys/types.h> #include <netinet/in.h> #include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpc/svc.h || echo "#include <sys/types.h> #include <netinet/in.h> #include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpc/svc_auth.h || echo "#include <rpc/xdr.h> #include <rpc/auth.h>" >>z.c test $i != ./rpcsvc/nislib.h || echo "#include <rpcsvc/nis.h>" >>z.c test $i != ./rpcsvc/yp_prot.h || echo "#include <sys/types.h> #include <netinet/in.h> #include <rpc/types.h> #include <rpc/xdr.h> #include <rpc/auth.h> #include <rpc/clnt.h>" >>z.c test $i != ./skey.h ||echo "#include <stdio.h>" >>z.c test $i != ./sys/buf.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/ccdvar.h || echo "#include <sys/device.h> #include <sys/disklabel.h> #include <sys/disk.h>" >>z.c test $i != ./sys/clist.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/disk.h || echo "#include <sys/device.h> #include <sys/disklabel.h>" >>z.c test $i != ./sys/ktrace.h || echo "#include <sys/param.h> #include <sys/time.h> #include <sys/uio.h>" >>z.c test $i != ./sys/linker.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/mbuf.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/mount.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/proc.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/resource.h || echo "#include <sys/time.h>" >>z.c test $i != ./sys/resourcevar.h || echo "#include <sys/time.h>" >>z.c test $i != ./sys/timex.h || echo "#include <sys/time.h>" >>z.c test $i != ./sys/ucred.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/user.h || echo "#include <sys/param.h>" >>z.c test $i != ./sys/vnode.h || echo "#include <sys/time.h>" >>z.c test $i != ./ufs/ffs/ffs_extern.h || echo "#include <sys/param.h> #include <sys/time.h> #include <sys/vnode.h> #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h>" >>z.c test $i != ./ufs/ffs/fs.h || echo "#include <sys/param.h>" >>z.c test $i != ./ufs/lfs/lfs.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./ufs/mfs/mfsnode.h || echo "#include <sys/param.h> #include <sys/buf.h>" >>z.c test $i != ./ufs/ufs/inode.h || echo "#include <ufs/ufs/quota.h>" >>z.c test $i != ./ufs/ufs/ufs_extern.h || echo "#include <sys/time.h> #include <sys/vnode.h> #include <ufs/ufs/dir.h>" >>z.c test $i != ./ufs/ufs/ufsmount.h || echo "#include <sys/param.h> #include <sys/mount.h>" >>z.c test $i != ./utime.h || echo "#include <sys/types.h>" >>z.c test $i != ./utmp.h || echo "#include <sys/types.h>" >>z.c if echo $i | egrep -q "\./vm/"; then echo "#include <vm/vm.h>" >>z.c; fi test $i != ./vm/vm_map.h || echo "#include <sys/lock.h> #include <vm/pmap.h>" >>z.c echo "#include <$i>" >>z.c echo "int dummy;" >>z.c sed 's/^[ ]*//' <z.c >z1.c gccw -S z1.c # cc -Dconst= -Dvolatile= -traditional -S z1.c # bcc -Dconst= -Dvolatile= -D__inline= -D__i386__ -S z1.c done
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810090400.OAA13981>