void		accounttime(void);
Block*	allocb(int);
void		adddev(Dev*);
void		addrootdir(char*);
void		addrootfile(char*, uchar*, ulong);
Cname*	addelem(Cname*, char*);
Block*	adjustblock(Block*, int);
void		alarmkproc(void*);
Block*	allocb(int);
Block*	bl2mem(uchar*, Block*, int);
int		blockalloclen(Block*);
int		blocklen(Block*);
char*	c2name(Chan*);
int		canlock(Lock*);
int		canqlock(QLock*);
int		canrlock(RWlock*);
int		canwlock(RWlock*);
Chan*	cclone(Chan*);
void		cclose(Chan*);
void		chandevreset(void);
void		kchanfree(Chan*);
void		checkalarms(void);
void		checkb(Block*, char*);
void		checkerrstack(void);
void		cinit(void);
void		cleancname(Cname*);
void		closeegrp(Egrp*);
void		closefgrp(Fgrp*);
void		closemount(Mount*);
void		closepgrp(Pgrp*);
void		closergrp(Rgrp*);
void		cmderror(Cmdbuf*, char*);
int		cmount(Chan**, Chan*, int, char*);
void		cnameclose(Cname*);
#define	coherence()
Block*	concatblock(Block*);
Block*	concatblock(Block*);
Block*	copyblock(Block*, int);
Block*	copyblock(Block*, int);
long		copyproc(Proc*, int);
void		cunmount(Chan*, Chan*);
int		decref(Ref*);
void		delay(int);
Chan*	devattach(int, char*);
Block*	devbread(Chan*, long, ulong);
long		devbwrite(Chan*, Block*, ulong);
Chan*	devclone(Chan*);
void		devcreate(Chan*, char*, int, ulong);
void		devdir(Chan*, Qid, char*, vlong, char*, long, Dir*);
long		devdirread(Chan*, char*, long, Dirtab*, int, Devgen*);
Devgen	devgen;
void		devinit(void);
int		devno(Rune, int);
Chan*	devopen(Chan*, int, Dirtab*, int, Devgen*);
void		devpermcheck(char*, ulong, int);
void		devremove(Chan*);
void		devreset(void);
int		devstat(Chan*, uchar*, int, Dirtab*, int, Devgen*);
Walkqid*	devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);
int		devwstat(Chan*, uchar*, int);
void		dumpaproc(Proc*);
void		dumpqueues(void);
void		dumpmount(void);
Fgrp*	dupfgrp(Fgrp*);
void		eiacloseport(Eiaport*);
void		eiactl(Eiaport*, char*);
Eiaport*	eiaopenport(int, int);
long		eiardwr(Eiaport*, void*, long, int);
int		emptystr(char*);
void		envcpy(Egrp*, Egrp*);
int		eqchan(Chan*, Chan*, int);
int		eqchantdqid(Chan*, int, int, Qid, int);
int		eqqid(Qid, Qid);
void		error(char*);
void		exhausted(char*);
vlong	fastticks(uvlong*);
void		fdclose(int, int);
Chan*	fdtochan(int, int, int, int);
Proc*	findproc(long);
void		freeb(Block*);
void		freeblist(Block*);
char*	fullpath(char*);
Mach*	getmach(void);
Proc**	getproc(void);
int		haswaitq(void*);
long		hostdomainwrite(char*, int);
long		hostownerwrite(char*, int);
void		idlehands(void);
int		incref(Ref*);
void		isdir(Chan*);
int		iseve(void);
int		islo(void);
int		isrootname(char*);
void		kproc(char*, void(*)(void*), void*);
void		kprocchild(Proc*, void (*)(void*), void*);
void		ksetenv(char*, char*);
void		kstrcpy(char*, char*, int);
void		kstrdup(char**, char*);
long		latin1(Rune*, int);
void		lock(Lock*);
void		lockinit(void);
//void		logopen(Log*);
//void		logclose(Log*);
//char*		logctl(Log*, int, char**, Logflag*);
//void		logn(Log*, int, void*, int);
//long		logread(Log*, void*, ulong, long);
//void		log(Log*, int, char*, ...);
//void		vlog(Log*, int, char*, va_list);
Cmdtab*	lookupcmd(Cmdbuf*, Cmdtab*, int);
Block*	mem2bl(uchar*, int);
void		mkqid(Qid*, uvlong, ulong, uchar);
Chan*	mntauth(Chan*, char*);
void		mntdirfix(uchar*, Chan*);
void		mntdirreadfix(uchar*, int, Chan*);
void		mntdump(void);
long		mntversion(Chan*, char*, int, int);
void		mountfree(Mount*);
void		muxclose(Mnt*);
Chan*	namec(char*, int, int, ulong);
Chan*	newchan(void);
Cname*	newcname(char*);
int		newfd(Chan*);
int		newfdx(Chan*, int);
int		newfd2(int[2], Chan*[2]);
Mount*	newmount(Mhead*, Chan*, int, char*);
Pgrp*	newpgrp(void);
Proc*	newproc(void);
Rgrp*	newrgrp(void);
void		nexterror(void);
void		noidlehands(void);
void		muxclose(Mnt*);
vlong	nsec(void);
int		openmode(ulong);
void		ossched(void);
Block*	packblock(Block*);
Block*	padblock(Block*, int);
void		pm_panic(char*, ...);
Cmdbuf*	parsecmd(char *a, int n);
void		pexit(char*, int);
void		pgrpcpy(Pgrp*, Pgrp*);
void		pgrpnote(ulong, char*, long, int);
Pgrp*	pgrptab(int);
#define	poperror()		up->nerrlab--
int		postnote(Proc*, int, char*, int);
int		pprint(char*, ...);
ulong	procalarm(ulong);
int		proccounter(char *name);
void		procctl(Proc*);
void		procdump(void);
int		procfdprint(Chan*, int, int, char*, int);
int		procindex(ulong);
void		procinit0(void);
Proc*	proctab(int);
void		procwired(Proc*, int);
int		pullblock(Block**, int);
Block*	pullupblock(Block*, int);
Block*	pullupqueue(Queue*, int);
void		putmhead(Mhead*);
ulong	pwait(Waitmsg*);
void		qaddlist(Queue*, Block*);
Block*	qbread(Queue*, int);
long		qbwrite(Queue*, Block*);
int		qcanread(Queue*);
void		qclose(Queue*);
int		qconsume(Queue*, void*, int);
Block*	qcopy(Queue*, int, ulong);
int		qdiscard(Queue*, int);
void		qflush(Queue*);
void		qfree(Queue*);
int		qfull(Queue*);
Block*	qget(Queue*);
void		qhangup(Queue*, char*);
void		qinit(void);
int		qiwrite(Queue*, void*, int);
int		qisclosed(Queue*);
int		qlen(Queue*);
void		qlock(QLock*);
void		qnoblock(Queue*, int);
Queue*	qopen(int, int, void(*)(void*), void*);
int		qpass(Queue*, Block*);
int		qpassnolim(Queue*, Block*);
int		qproduce(Queue*, void*, int);
void		qputback(Queue*, Block*);
long		qread(Queue*, void*, int);
Block*	qremove(Queue*);
void		qreopen(Queue*);
void		qsetlimit(Queue*, int);
int		qstate(Queue*);
void		qunlock(QLock*);
int		qwindow(Queue*);
int		qwrite(Queue*, void*, int);
ulong	randomread(void*, ulong);
int		readnum(ulong, char*, ulong, ulong, int);
int		readstr(ulong, char*, ulong, char*);
void		ready(Proc*);
void		renameuser(char*, char*);
void		rendsleep(Rendez*, int(*)(void*), void*);
void		rendtsleep(Rendez*, int (*)(void*), void*, int);
Proc*	rendwakeup(Rendez*);
void		resrcwait(char*);
int		return0(void*);
void		rlock(RWlock*);
void		runlock(RWlock*);
Proc*	runproc(void);
void		sched(void);
void		scheddump(void);
void		schedinit(void);
void		(*screenputs)(char*, int);
long		seconds(void);
void		setdebug(char*);
char*	skipslash(char*);
void*	smalloc(ulong);
void		splx(int);
int		splhi(void);
int		spllo(void);
char*	srvname(Chan*);
Block*	trimblock(Block*, int, int);
long		unionread(Chan*, void*, long);
void		unlock(Lock*);
void		userinit(void);
long		userwrite(char*, int);
void		validargs(ulong*, void*, void*, char*);
void		validname(char*, int);
void		validstat(uchar*, int);
int		walk(Chan**, char**, int, int, int*);
void		wake(Proc*);
void		wlock(RWlock*);
void		wunlock(RWlock*);

void		hnputv(void*, vlong);
void		hnputl(void*, ulong);
void		hnputs(void*, ushort);
vlong	nhgetv(void*);
ulong	nhgetl(void*);
ushort	nhgets(void*);

#define dwrite			pm_dwrite
#define panic			pm_panic
#define gotolabel(l)		pm_longjmp((l)->jb, 1)
#define setlabel(l)		pm_setjmp((l)->jb)
#define waserror()		setlabel(&up->errlab[up->nerrlab++])
#define MS2TK(ms)		(ms)	/* HZ is 1000 */
#define TK2MS(tk)		(tk)	/* HZ is 1000 */

Syscall	sysr1,
		sysbind,
		syschdir,
		sysclose,
		sysdup,
		sysalarm,
		sysexec,
		sysexits,
		sysfauth,
		sysopen,
		syssleep,
		sysrfork,
		syspipe,
		syscreate,
		sysfd2path,
		sysremove,
		sysnoted,
		sysrendezvous,
		sysunmount,
		sysseek,
		sysfversion,
		syserrstr,
		sysstat,
		sysfstat,
		syswstat,
		sysfwstat,
		sysmount,
		sysawait,
		syspread,
		syspwrite,
		syspassfd,
		syspassdir,
		sysdeath;
