*BSD News Article 12765


Return to BSD News archive

Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!uunet!emba-news.uvm.edu!sadye.emba.uvm.edu!wollman
From: wollman@sadye.emba.uvm.edu (Garrett Wollman)
Subject: Bad assumption in com driver PLUS new systm.h
Message-ID: <1993Mar15.220556.13648@uvm.edu>
Sender: news@uvm.edu
Organization: University of Vermont, EMBA Computer Facility
Date: Mon, 15 Mar 1993 22:05:56 GMT
Lines: 342

Over the past week or so, I have been working on ANSIfying bits of the
kernel.  My main goal is to get the entire system to compile cleanly
under `gcc -Wall'.  One of the things that this entails is looking for
all those functions that don't return useful values, and make sure
that they are all declared to return `void'.  Perhaps more
significantly, this also means that function pointers which point to
these routines are also properly declared (both with respect to
prototype and to return value).  I found the following interesting
bit in the standard `com.c' async driver:

		if (stat & MSR_DCD)
			(void)(*linesw[tp->t_line].l_modem)(tp, 1);
		else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)

The problem with this code is that the `modem' routines---at least the
ones in the standard line discipline---are ones that don't return any
useful value.  This is the *only* place in all of 386BSD that I have
found which tries to examine this value.  I have replaced this routine
with the following:

		/* XXX - GW: This code seems to think that l_modem
		   returns a useful value.  It does not (at least in
		   the standard TTY driver), so we fudge it and see
		   what happens. */
		else if ((*linesw[tp->t_line].l_modem)(tp, 0), 0 == 0)

Another problem which I noticed was that many routines were not called
with the correct number of parameters, on the basis that those
parameters are not examined anyway.  It should be possible to compile
the entire kernel on a ``caller pops'' convention and not break
anything.

Below you will find a sharchive of the version of `systm.h' that I am
working with.  NOTE WELL: if you install this file, your system will
NOT compile without quite a bit more work.  (This makes me wish I had
enough disk space to put everything under CVS control.)  I have
already done this work, but I am unable to provide diffs to do so.
(However, it's not difficult---most of it is just declaring functions
correctly, and then inserting casts in some calls to timeout() and
untimeout().)  Note that I have defined a typedef for the first
argument of timeout(), `timeout_t', to make this easier.

-GAWollman

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  systm.h
# Wrapped by wollman@tsornin on Mon Mar 15 17:03:30 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'systm.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'systm.h'\"
else
echo shar: Extracting \"'systm.h'\" \(10191 characters\)
sed "s/^X//" >'systm.h' <<'END_OF_FILE'
X/*-
X * Copyright (c) 1982, 1988, 1991 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X *	@(#)systm.h	7.17 (Berkeley) 5/25/91
X *
X * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
X * --------------------         -----   ----------------------
X * CURRENT PATCH LEVEL:         1       00061
X * --------------------         -----   ----------------------
X *
X * 11 Dec 92	Williams Jolitz		Fixed panic:remrq and tty handling
X */
X
Xextern const char *panicstr;	/* panic message */
Xextern char version[];		/* system version */
Xextern char copyright[];	/* system copyright */
X
Xextern int nblkdev;		/* number of entries in bdevsw */
Xextern int nchrdev;		/* number of entries in cdevsw */
Xextern int nswdev;		/* number of swap devices */
Xextern int nswap;		/* size of swap space */
X
Xextern int selwait;		/* select timeout address */
X
Xextern u_char curpri;		/* priority of current process */
X
Xextern int maxmem;		/* max memory per process */
Xextern int physmem;		/* physical memory */
X
Xextern dev_t dumpdev;		/* dump device */
Xextern long dumplo;		/* offset into dumpdev */
X
Xextern dev_t rootdev;		/* root device */
Xextern struct vnode *rootvp;	/* vnode equivalent to above */
X
Xextern dev_t swapdev;		/* swapping device */
Xextern struct vnode *swapdev_vp;/* vnode equivalent to above */
X
Xextern struct sysent {		/* system call table */
X	int	sy_narg;	/* number of arguments */
X	int	(*sy_call)();	/* implementing function */
X} sysent[];
X
Xextern int boothowto;		/* reboot flags, from console subsystem */
X#ifdef	KADB
Xextern char *bootesym;		/* end of symbol info from boot */
X#endif
X
X/* casts to keep lint happy */
X#define	insque(q,p)	_insque((caddr_t)q,(caddr_t)p)
X#define	remque(q)	_remque((caddr_t)q)
X
Xtypedef void (*timeout_t)(caddr_t);
X
X/*
X * General function declarations.
X */
Xint	nullop __P((void));
Xint	enodev __P((void));
Xint	enoioctl __P((void));
Xint	enxio __P((void));
Xint	eopnotsupp __P((void));
Xint	selscan __P((struct proc *p, fd_set *ibits, fd_set *obits,
X		int nfd, int *retval));
Xint	seltrue __P((dev_t dev, int which, struct proc *p));
Xvoid	selwakeup  __P((pid_t pid, int coll));
X
Xvoid	tablefull __P((char *));
Xvoid	addlog __P((const char *, ...));
Xvoid	log __P((int, const char *, ...));
Xvoid	printf __P((const char *, ...));
Xint	sprintf __P((char *buf, const char *, ...));
X
Xvoid	bcopy __P((void *from, void *to, u_int len));
Xvoid	ovbcopy __P((void *from, void *to, u_int len));
Xvoid	bzero __P((void *buf, u_int len));
Xint	bcmp __P((void *str1, void *str2, u_int len));
X
Xint	copystr __P((void *kfaddr, void *kdaddr, u_int len, u_int *done));
Xint	copyinstr __P((void *udaddr, void *kaddr, u_int len, u_int *done));
Xint	copyoutstr __P((void *kaddr, void *udaddr, u_int len, u_int *done));
Xint	copyin __P((void *udaddr, void *kaddr, u_int len));
Xint	copyout __P((void *kaddr, void *udaddr, u_int len));
X
Xint	fubyte __P((void *base));
Xint	fuibyte __P((void *base));
Xint	subyte __P((void *base, int byte));
Xint	suibyte __P((void *base, int byte));
Xint	fuword __P((void *base));
Xint	fuiword __P((void *base));
Xint	suword __P((void *base, int word));
Xint	suiword __P((void *base, int word));
X
Xint	scanc __P((unsigned size, u_char *cp, u_char *table, int mask));
Xint	skpc __P((int mask, int size, char *cp));
Xint	locc __P((int mask, char *cp, unsigned size));
Xint	ffs __P((long value));
X
X/* Added by GW */
Xstruct proc; struct args; struct itimerval; struct timeval; struct file;
Xstruct vnode; struct stat; struct socket; struct cred; struct tty;
Xstruct sigaction; struct uio; struct mbuf; struct sockbuf; struct ringb;
Xstruct termios; struct speedtab;
X
Xvoid	startrtclock __P((void));
Xvoid	consinit __P((void));
Xvoid	vm_mem_init __P((void));
Xvoid	kmeminit __P((void));
Xvoid	cpu_startup __P((void));
Xvoid	rqinit __P((void));
Xvoid	vm_init_limits __P((struct proc *));
Xvoid	vfsinit __P((void));
Xvoid	mbinit __P((void));
Xvoid	shminit __P((void));
Xint	slattach __P((void));
Xint	loattach __P((void));
Xint	splhigh __P((void));
Xint	splimp __P((void));
Xint 	splnet __P((void));
Xint	spltty __P((void));
Xint	splnone __P((void));
Xint	splclock __P((void));
Xint	splsoftclock __P((void));
Xint	splx __P((int));
Xint	spl0 __P((void));
Xvoid	ifinit __P((void));
Xvoid	domaininit __P((void));
Xvoid	roundrobin __P((caddr_t));
Xvoid	schedcpu __P((caddr_t));
Xvoid	enablertclock __P((void));
Xvoid	swapinit __P((void));
Xint	fork __P((struct proc *, void *, int *));
Xvoid	timeout __P((timeout_t, caddr_t, int));
Xvoid	untimeout __P((timeout_t, caddr_t));
Xint	itimerdecr __P((struct itimerval *, int));
Xvoid	psignal __P((struct proc *, int));
Xvoid	setpri __P((struct proc *));
Xvoid	gatherstats();		/* cannot prototype */
Xvoid	softclock();
Xvoid	setsoftclock __P((void));
Xint	hzto __P((struct timeval *));
Xint	munmapfd __P((struct proc *, int));
Xint	closef __P((struct file *, struct proc *));
Xint	vn_stat __P((struct vnode *, struct stat *, struct proc *));
Xint	soo_stat __P((struct socket *, struct stat *));
Xunsigned int	min __P((unsigned int, unsigned int));
Xunsigned int	max __P((unsigned int, unsigned int));
Xvoid	crfree __P((struct ucred *));
Xvoid	fdcloseexec __P((struct proc *));
Xvoid	execsigs __P((struct proc *));
Xvoid	wakeup __P((caddr_t));
Xvoid	setregs __P((struct proc *, caddr_t));
Xvoid	fdfree __P((struct proc *));
Xvoid	shmexit __P((struct proc *));
Xvoid	pgsignal __P((struct pgrp *, int, int));
Xvoid	vgoneall __P((struct vnode *));
Xvoid	vrele __P((struct vnode *));
Xvoid	fixjobc __P((struct proc *, struct pgrp *, int));
Xvoid	ruadd __P((struct rusage *, struct rusage *));
Xvoid	leavepgrp __P((struct proc *));
Xvoid	cpu_wait __P((struct proc *));
Xint	tsleep __P((caddr_t, int, const char *, int));
Xint	fork1 __P((struct proc *, int, int *));
Xvoid	setrq __P((struct proc *));
Xint	suser __P((struct ucred *, u_short *));
Xint	uiomove __P((caddr_t, int, struct uio *));
Xint	uioapply();		/* cannot be prototyped */
Xint	useracc __P((caddr_t, int, int));
Xvoid	vslock __P((caddr_t, unsigned int));
Xvoid	physstrat __P((struct buf *, int (*)(), int));
Xvoid	vsunlock __P((caddr_t, unsigned int, int));
Xvoid	pgdelete __P((struct pgrp *));
Xvoid	enterpgrp __P((struct proc *, int, int));
Xint	inferior __P((struct proc *));
Xint	groupmember __P((gid_t, struct ucred *));
Xstruct 	ucred *crcopy __P((struct ucred *));
Xstruct	ucred *crdup __P((struct ucred *));
Xint	killpg1 __P((struct proc *, int, int, int));
Xvoid	stop __P((struct proc *));
Xvoid	unsleep __P((struct proc *));
Xvoid	setrun __P((struct proc *));
Xint	issig __P((struct proc *));
Xvoid	swtch __P((void));
Xint	procxmt __P((struct proc *));
Xvoid	sigexit __P((struct proc *, int));
Xvoid	remrq __P((struct proc *));
Xvoid	setrq __P((struct proc *));
Xvoid	vmmeter __P((void));
Xvoid	updatepri __P((struct proc *));
Xvoid	sleep __P((caddr_t, int));
Xint	chkvnlock __P((struct vnode *));
Xint	fdopen __P((dev_t, int, int));
Xint	mountedon __P((struct vnode *));
Xvoid	vflushbuf __P((struct vnode *, int));
Xint	vinvalbuf __P((struct vnode *, int));
Xint	logwakeup __P((void));
Xint	itimerfix __P((struct timeval *));
Xvoid	timevaladd __P((struct timeval *, struct timeval *));
Xint	soreceive __P((struct socket *, struct mbuf **, struct uio *,
X		       struct mbuf **, struct mbuf **, int *));
Xint	sosend __P((struct socket *, struct mbuf *, struct uio *,
X		    struct mbuf *, struct mbuf *, int));
Xint	ifioctl __P((struct socket *, int, caddr_t, struct proc *));
Xint	rtioctl __P((int, caddr_t, struct proc *));
Xvoid	sbselqueue __P((struct sockbuf *, struct proc *));
Xint	imin __P((int, int));
Xint	imax __P((int, int));
Xint	soo_close __P((struct file *, struct proc *));
Xint	soclose __P((struct socket *));
Xint	ureadc __P((int, struct uio *));
Xvoid	ttyrubo __P((struct tty *, int));
Xint	nextc __P((char **, struct ringb *));
X
X
X/* routines which never return */
X#ifdef __GNUC__
Xvolatile void	sched __P((void));
Xvolatile void	exit __P((struct proc *, int));
Xvolatile void	cpu_exit __P((struct proc *));
Xvolatile void	panic __P((const char *));
Xvolatile void	boot __P((int));
X#else
Xvoid	panic __P((const char *));
Xvoid	sched __P((void));
Xvoid	exit __P((struct proc *, int));
Xvoid	cpu_exit __P((struct proc *));
Xvoid	boot __P((int));
X#endif
X
X/* string functions */
Xint	strlen __P((const char *));
Xint	strcmp __P((const char *, const char *));
Xchar   *strncpy __P((char *, const char *, int));
Xchar   *strcat __P((char *, const char *));
Xchar   *strcpy __P((char *, const char *));
X
X/* Debugger entry points */
Xint	Debugger __P((void));	/* in DDB only */
Xint	read_symtab_from_file __P((struct proc *,struct vnode *,const char *));
END_OF_FILE
if test 10191 -ne `wc -c <'systm.h'`; then
    echo shar: \"'systm.h'\" unpacked with wrong size!
fi
# end of 'systm.h'
fi
echo shar: End of shell archive.
exit 0


-- 
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@emba.uvm.edu | Shashish is the bonding of hearts in spite of distance.
uvm-gen!wollman      | It is a bond more powerful than absence.  We like people
UVM disagrees.       | who like Shashish.  - Claude McKenzie + Florent Vollant