Browse Source

De-plan9-extension project

Continue to remove the need for plan 9 extensions.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
4991403e39

+ 4 - 2
sys/src/9/amd64/amd64cpu.json

@@ -1,5 +1,8 @@
 {
 	"cpu": {
+		"Cflags": [
+			"-fplan9-extensions"
+		],
 		"Env": [
 			"CONF=cpu"
 		],
@@ -47,8 +50,7 @@
 					"uart",
 					"ws",
 					"usb",
-					"vga",
-					"zp"
+					"vga"
 				],
 				"Ip": [
 					"tcp",

+ 0 - 1
sys/src/9/amd64/core.json

@@ -4,7 +4,6 @@
 			"-mcmodel=kernel",
 			"-O0",
 			"-static",
-			"-fplan9-extensions",
 			"-mno-red-zone",
 			"-ffreestanding",
 			"-fno-builtin",

+ 15 - 15
sys/src/9/port/devmnt.c

@@ -54,7 +54,7 @@ enum
 
 struct Mntalloc
 {
-	Lock;
+	Lock Lock;
 	Mnt*	list;		/* Mount devices in use */
 	Mnt*	mntfree;	/* Free list */
 	Mntrpc*	rpcfree;
@@ -211,14 +211,14 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen)
 		error("bad 9P version returned from server");
 
 	/* now build Mnt associated with this connection */
-	lock(&mntalloc);
+	lock(&mntalloc.Lock);
 	mnt = mntalloc.mntfree;
 	if(mnt != nil)
 		mntalloc.mntfree = mnt->list;
 	else {
 		mnt = malloc(sizeof(Mnt));
 		if(mnt == nil) {
-			unlock(&mntalloc);
+			unlock(&mntalloc.Lock);
 			exhausted("mount devices");
 		}
 	}
@@ -229,7 +229,7 @@ mntversion(Chan *c, uint32_t msize, char *version, usize returnlen)
 	mnt->id = mntalloc.id++;
 	mnt->q = qopen(10*MAXRPC, 0, nil, nil);
 	mnt->msize = f.msize;
-	unlock(&mntalloc);
+	unlock(&mntalloc.Lock);
 
 	if(returnlen != 0){
 		if(returnlen < k)
@@ -381,9 +381,9 @@ mntchan(void)
 	Chan *c;
 
 	c = devattach('M', 0);
-	lock(&mntalloc);
+	lock(&mntalloc.Lock);
 	c->devno = mntalloc.id++;
-	unlock(&mntalloc);
+	unlock(&mntalloc.Lock);
 
 	if(c->mchan)
 		panic("mntchan non-zero %#p", c->mchan);
@@ -601,7 +601,7 @@ mntpntfree(Mnt *mnt)
 	Mnt *f, **l;
 	Queue *q;
 
-	lock(&mntalloc);
+	lock(&mntalloc.Lock);
 	l = &mntalloc.list;
 	for(f = *l; f; f = f->list) {
 		if(f == mnt) {
@@ -613,7 +613,7 @@ mntpntfree(Mnt *mnt)
 	mnt->list = mntalloc.mntfree;
 	mntalloc.mntfree = mnt;
 	q = mnt->q;
-	unlock(&mntalloc);
+	unlock(&mntalloc.Lock);
 
 	qfree(q);
 }
@@ -1116,12 +1116,12 @@ mntralloc(Chan *c, uint32_t msize)
 {
 	Mntrpc *new;
 
-	lock(&mntalloc);
+	lock(&mntalloc.Lock);
 	new = mntalloc.rpcfree;
 	if(new == nil){
 		new = malloc(sizeof(Mntrpc));
 		if(new == nil) {
-			unlock(&mntalloc);
+			unlock(&mntalloc.Lock);
 			exhausted("mount rpc header");
 		}
 		/*
@@ -1131,7 +1131,7 @@ mntralloc(Chan *c, uint32_t msize)
 		new->rpc = mallocz(msize, 0);
 		if(new->rpc == nil){
 			free(new);
-			unlock(&mntalloc);
+			unlock(&mntalloc.Lock);
 			exhausted("mount rpc buffer");
 		}
 		new->rpclen = msize;
@@ -1146,14 +1146,14 @@ mntralloc(Chan *c, uint32_t msize)
 			if(new->rpc == nil){
 				free(new);
 				mntalloc.nrpcused--;
-				unlock(&mntalloc);
+				unlock(&mntalloc.Lock);
 				exhausted("mount rpc buffer");
 			}
 			new->rpclen = msize;
 		}
 	}
 	mntalloc.nrpcused++;
-	unlock(&mntalloc);
+	unlock(&mntalloc.Lock);
 	new->c = c;
 	new->done = 0;
 	new->flushed = nil;
@@ -1166,7 +1166,7 @@ mntfree(Mntrpc *r)
 {
 	if(r->b != nil)
 		freeblist(r->b);
-	lock(&mntalloc);
+	lock(&mntalloc.Lock);
 	if(mntalloc.nrpcfree >= 10){
 		free(r->rpc);
 		freetag(r->request.tag);
@@ -1178,7 +1178,7 @@ mntfree(Mntrpc *r)
 		mntalloc.nrpcfree++;
 	}
 	mntalloc.nrpcused--;
-	unlock(&mntalloc);
+	unlock(&mntalloc.Lock);
 }
 
 void

+ 11 - 11
sys/src/9/port/devpipe.c

@@ -17,7 +17,7 @@
 typedef struct Pipe	Pipe;
 struct Pipe
 {
-	QLock;
+	QLock QLock;
 	Pipe	*next;
 	int	ref;
 	uint32_t	path;
@@ -27,7 +27,7 @@ struct Pipe
 
 struct
 {
-	Lock;
+	Lock Lock;
 	uint32_t	path;
 } pipealloc;
 
@@ -89,9 +89,9 @@ pipeattach(char *spec)
 		exhausted("memory");
 	}
 
-	lock(&pipealloc);
+	lock(&pipealloc.Lock);
 	p->path = ++pipealloc.path;
-	unlock(&pipealloc);
+	unlock(&pipealloc.Lock);
 
 	mkqid(&c->qid, PIPEQID(2*p->path, Qdir), 0, QTDIR);
 	c->aux = p;
@@ -142,7 +142,7 @@ pipewalk(Chan *c, Chan *nc, char **name, int nname)
 	wq = devwalk(c, nc, name, nname, pipedir, NPIPEDIR, pipegen);
 	if(wq != nil && wq->clone != nil && wq->clone != c){
 		p = c->aux;
-		qlock(p);
+		qlock(&p->QLock);
 		p->ref++;
 		if(c->flag & COPEN){
 			print("channel open in pipewalk\n");
@@ -155,7 +155,7 @@ pipewalk(Chan *c, Chan *nc, char **name, int nname)
 				break;
 			}
 		}
-		qunlock(p);
+		qunlock(&p->QLock);
 	}
 	return wq;
 }
@@ -205,7 +205,7 @@ pipeopen(Chan *c, int omode)
 	}
 
 	p = c->aux;
-	qlock(p);
+	qlock(&p->QLock);
 	switch(PIPETYPE(c->qid.path)){
 	case Qdata0:
 		p->qref[0]++;
@@ -214,7 +214,7 @@ pipeopen(Chan *c, int omode)
 		p->qref[1]++;
 		break;
 	}
-	qunlock(p);
+	qunlock(&p->QLock);
 
 	c->mode = openmode(omode);
 	c->flag |= COPEN;
@@ -229,7 +229,7 @@ pipeclose(Chan *c)
 	Pipe *p;
 
 	p = c->aux;
-	qlock(p);
+	qlock(&p->QLock);
 
 	if(c->flag & COPEN){
 		/*
@@ -267,12 +267,12 @@ pipeclose(Chan *c)
 	 */
 	p->ref--;
 	if(p->ref == 0){
-		qunlock(p);
+		qunlock(&p->QLock);
 		free(p->q[0]);
 		free(p->q[1]);
 		free(p);
 	} else
-		qunlock(p);
+		qunlock(&p->QLock);
 }
 
 static int32_t

+ 12 - 12
sys/src/9/port/image.c

@@ -20,7 +20,7 @@
 
 static struct Imagealloc
 {
-	Lock;
+	Lock Lock;
 	Image	*mru;			/* head of LRU list */
 	Image	*lru;			/* tail of LRU list */
 	Image	*hash[IHASHSIZE];
@@ -145,7 +145,7 @@ imagereclaim(void)
 	DBG("imagereclaim maxt %ulld noluck %d nolock %d\n",
 		irstats.maxt, irstats.noluck, irstats.nolock);
 	ticks0 = fastticks(nil);
-	if(!canlock(&imagealloc)){
+	if(!canlock(&imagealloc.Lock)){
 		/* never happen in the experiments I made */
 		qunlock(&imagealloc.ireclaim);
 		return;
@@ -160,7 +160,7 @@ imagereclaim(void)
 			DBG("imagereclaim: image %p(c%p, r%d)\n", i, i->c, i->r.ref);
 			if(i->r.ref == 1){	/* no pages referring to it, it's ours */
 				unlock(&i->r.l);
-				unlock(&imagealloc);
+				unlock(&imagealloc.Lock);
 				putimage(i);
 				break;
 			}else
@@ -171,7 +171,7 @@ imagereclaim(void)
 
 	if(i == nil){
 		irstats.noluck++;
-		unlock(&imagealloc);
+		unlock(&imagealloc.Lock);
 	}
 	irstats.loops++;
 	ticks = fastticks(nil) - ticks0;
@@ -202,10 +202,10 @@ imagechanreclaim(void)
 	 * one of us thanks to the qlock above.
 	 */
 	while(imagealloc.nfreechan > 0){
-		lock(&imagealloc);
+		lock(&imagealloc.Lock);
 		imagealloc.nfreechan--;
 		c = imagealloc.freechan[imagealloc.nfreechan];
-		unlock(&imagealloc);
+		unlock(&imagealloc.Lock);
 		cclose(c);
 	}
 
@@ -222,7 +222,7 @@ attachimage(int type, Chan *c, int color, uintptr_t base, usize len)
 	if(imagealloc.nfreechan)
 		imagechanreclaim();
 
-	lock(&imagealloc);
+	lock(&imagealloc.Lock);
 
 	/*
 	 * Search the image cache for remains of the text from a previous
@@ -247,10 +247,10 @@ attachimage(int type, Chan *c, int color, uintptr_t base, usize len)
 	 * structures. This should free some image structures.
 	 */
 	while(!(i = lruimage())) {
-		unlock(&imagealloc);
+		unlock(&imagealloc.Lock);
 		imagereclaim();
 		sched();
-		lock(&imagealloc);
+		lock(&imagealloc.Lock);
 	}
 
 	lock(&i->r.l);
@@ -267,7 +267,7 @@ attachimage(int type, Chan *c, int color, uintptr_t base, usize len)
 	*l = i;
 found:
 	imageused(i);
-	unlock(&imagealloc);
+	unlock(&imagealloc.Lock);
 
 	if(i->s == 0) {
 		/* Disaster after commit in exec */
@@ -303,7 +303,7 @@ putimage(Image *i)
 		unlock(&i->r.l);
 		c = i->c;
 
-		lock(&imagealloc);
+		lock(&imagealloc.Lock);
 		for(f = *l; f; f = f->hash) {
 			if(f == i) {
 				*l = i->hash;
@@ -324,7 +324,7 @@ putimage(Image *i)
 		}
 		imagealloc.freechan[imagealloc.nfreechan++] = c;
 		i->c = nil;		/* flag as unused in lru list */
-		unlock(&imagealloc);
+		unlock(&imagealloc.Lock);
 
 		return;
 	}

+ 2 - 2
sys/src/9/port/kexec.h

@@ -24,8 +24,8 @@ struct Kvalue
 
 struct Kexecgrp
 {
-	Ref;
-	RWlock;
+	Ref Ref;
+	RWlock RWlock;
 	Kvalue	**ent;
 	int	nent;
 	int	ment;

+ 0 - 3
sys/src/9/port/port.json

@@ -23,7 +23,6 @@
 			"../port/devdup.c",
 			"../port/devenv.c",
 			"../port/devfdmux.c",
-			"../port/devkexec.c",
 			"../port/devkprof.c",
 			"../port/devkbin.c",
 			"../port/devmnt.c",
@@ -42,7 +41,6 @@
 			"../port/devuart.c",
 			"../port/devwd.c",
 			"../port/devws.c",
-			"../port/devzp.c",
 			"../port/edf.c",
 			"../port/elf64.c",
 			"../port/ethermii.c",
@@ -52,7 +50,6 @@
 			"../port/hexdump.c",
 			"../port/image.c",
 			"../port/kdebug.c",
-			"../port/kexec.c",
 		        "../port/ipchecksum.c",
 			"../port/mul64fract.c",
 			"../port/netif.c",

+ 7 - 7
sys/src/9/port/proc.c

@@ -1174,7 +1174,7 @@ postnote(Proc *p, int dolock, char *n, int flag)
 #define	NBROKEN 4
 struct
 {
-	QLock;
+	QLock QLock;
 	int	n;
 	Proc	*p[NBROKEN];
 }broken;
@@ -1183,14 +1183,14 @@ void
 addbroken(Proc *p)
 {
 	Proc *up = externup();
-	qlock(&broken);
+	qlock(&broken.QLock);
 	if(broken.n == NBROKEN) {
 		ready(broken.p[0]);
 		memmove(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1));
 		--broken.n;
 	}
 	broken.p[broken.n++] = p;
-	qunlock(&broken);
+	qunlock(&broken.QLock);
 
 	stopac();
 	edfstop(up);
@@ -1204,7 +1204,7 @@ unbreak(Proc *p)
 {
 	int b;
 
-	qlock(&broken);
+	qlock(&broken.QLock);
 	for(b=0; b < broken.n; b++)
 		if(broken.p[b] == p) {
 			broken.n--;
@@ -1213,7 +1213,7 @@ unbreak(Proc *p)
 			ready(p);
 			break;
 		}
-	qunlock(&broken);
+	qunlock(&broken.QLock);
 }
 
 int
@@ -1221,14 +1221,14 @@ freebroken(void)
 {
 	int i, n;
 
-	qlock(&broken);
+	qlock(&broken.QLock);
 	n = broken.n;
 	for(i=0; i<n; i++) {
 		ready(broken.p[i]);
 		broken.p[i] = 0;
 	}
 	broken.n = 0;
-	qunlock(&broken);
+	qunlock(&broken.QLock);
 	return n;
 }
 

+ 53 - 53
sys/src/9/port/qio.c

@@ -33,7 +33,7 @@ typedef struct Queue	Queue;
 
 struct Queue
 {
-	Lock;
+	Lock Lock;
 
 	Block*	bfirst;		/* buffer */
 	Block*	blast;
@@ -422,12 +422,12 @@ qget(Queue *q)
 	Block *b;
 
 	/* sync with qwrite */
-	ilock(q);
+	ilock(&q->Lock);
 
 	b = q->bfirst;
 	if(b == nil){
 		q->state |= Qstarve;
-		iunlock(q);
+		iunlock(&q->Lock);
 		return nil;
 	}
 	q->bfirst = b->next;
@@ -443,7 +443,7 @@ qget(Queue *q)
 	} else
 		dowakeup = 0;
 
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->wr);
@@ -460,7 +460,7 @@ qdiscard(Queue *q, int len)
 	Block *b;
 	int dowakeup, n, sofar;
 
-	ilock(q);
+	ilock(&q->Lock);
 	for(sofar = 0; sofar < len; sofar += n){
 		b = q->bfirst;
 		if(b == nil)
@@ -498,7 +498,7 @@ qdiscard(Queue *q, int len)
 	} else
 		dowakeup = 0;
 
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->wr);
@@ -518,13 +518,13 @@ qconsume(Queue *q, void *vp, int len)
 	Block *tofree = nil;
 
 	/* sync with qwrite */
-	ilock(q);
+	ilock(&q->Lock);
 
 	for(;;) {
 		b = q->bfirst;
 		if(b == 0){
 			q->state |= Qstarve;
-			iunlock(q);
+			iunlock(&q->Lock);
 			return -1;
 		}
 		QDEBUG checkb(b, "qconsume 1");
@@ -566,7 +566,7 @@ qconsume(Queue *q, void *vp, int len)
 	} else
 		dowakeup = 0;
 
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->wr);
@@ -584,16 +584,16 @@ qpass(Queue *q, Block *b)
 
 	/* sync with qread */
 	dowakeup = 0;
-	ilock(q);
+	ilock(&q->Lock);
 	if(q->len >= q->limit){
 		freeblist(b);
-		iunlock(q);
+		iunlock(&q->Lock);
 		return -1;
 	}
 	if(q->state & Qclosed){
 		len = BALLOC(b);
 		freeblist(b);
-		iunlock(q);
+		iunlock(&q->Lock);
 		return len;
 	}
 
@@ -622,7 +622,7 @@ qpass(Queue *q, Block *b)
 		q->state &= ~Qstarve;
 		dowakeup = 1;
 	}
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->rr);
@@ -637,12 +637,12 @@ qpassnolim(Queue *q, Block *b)
 
 	/* sync with qread */
 	dowakeup = 0;
-	ilock(q);
+	ilock(&q->Lock);
 
 	if(q->state & Qclosed){
 		len = BALLOC(b);
 		freeblist(b);
-		iunlock(q);
+		iunlock(&q->Lock);
 		return len;
 	}
 
@@ -671,7 +671,7 @@ qpassnolim(Queue *q, Block *b)
 		q->state &= ~Qstarve;
 		dowakeup = 1;
 	}
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->rr);
@@ -713,19 +713,19 @@ qproduce(Queue *q, void *vp, int len)
 
 	/* sync with qread */
 	dowakeup = 0;
-	ilock(q);
+	ilock(&q->Lock);
 
 	/* no waiting receivers, room in buffer? */
 	if(q->len >= q->limit){
 		q->state |= Qflow;
-		iunlock(q);
+		iunlock(&q->Lock);
 		return -1;
 	}
 
 	/* save in buffer */
 	b = iallocb(len);
 	if(b == 0){
-		iunlock(q);
+		iunlock(&q->Lock);
 		return 0;
 	}
 	memmove(b->wp, p, len);
@@ -748,7 +748,7 @@ qproduce(Queue *q, void *vp, int len)
 
 	if(q->len >= q->limit)
 		q->state |= Qflow;
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	if(dowakeup)
 		wakeup(&q->rr);
@@ -769,13 +769,13 @@ qcopy(Queue *q, int len, uint32_t offset)
 
 	nb = allocb(len);
 
-	ilock(q);
+	ilock(&q->Lock);
 
 	/* go to offset */
 	b = q->bfirst;
 	for(sofar = 0; ; sofar += n){
 		if(b == nil){
-			iunlock(q);
+			iunlock(&q->Lock);
 			return nb;
 		}
 		n = BLEN(b);
@@ -802,7 +802,7 @@ qcopy(Queue *q, int len, uint32_t offset)
 		n = BLEN(b);
 		p = b->rp;
 	}
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	return nb;
 }
@@ -878,9 +878,9 @@ qwait(Queue *q)
 		}
 
 		q->state |= Qstarve;	/* flag requesting producer to wake me */
-		iunlock(q);
+		iunlock(&q->Lock);
 		sleep(&q->rr, notempty, q);
-		ilock(q);
+		ilock(&q->Lock);
 	}
 	return 1;
 }
@@ -1017,7 +1017,7 @@ qwakeup_iunlock(Queue *q)
 	else
 		dowakeup = 0;
 
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	/* wakeup flow controlled writers */
 	if(dowakeup){
@@ -1043,17 +1043,17 @@ qbread(Queue *q, int len)
 		nexterror();
 	}
 
-	ilock(q);
+	ilock(&q->Lock);
 	switch(qwait(q)){
 	case 0:
 		/* queue closed */
-		iunlock(q);
+		iunlock(&q->Lock);
 		qunlock(&q->rlock);
 		poperror();
 		return nil;
 	case -1:
 		/* multiple reads on a closed queue */
-		iunlock(q);
+		iunlock(&q->Lock);
 		error(q->err);
 	}
 
@@ -1099,18 +1099,18 @@ qread(Queue *q, void *vp, int len)
 		nexterror();
 	}
 
-	ilock(q);
+	ilock(&q->Lock);
 again:
 	switch(qwait(q)){
 	case 0:
 		/* queue closed */
-		iunlock(q);
+		iunlock(&q->Lock);
 		qunlock(&q->rlock);
 		poperror();
 		return 0;
 	case -1:
 		/* multiple reads on a closed queue */
-		iunlock(q);
+		iunlock(&q->Lock);
 		error(q->err);
 	}
 
@@ -1148,9 +1148,9 @@ again:
 	}
 
 	/* copy to user space outside of the ilock */
-	iunlock(q);
+	iunlock(&q->Lock);
 	b = bl2mem(vp, first, len);
-	ilock(q);
+	ilock(&q->Lock);
 
 	/* take care of any left over partial block */
 	if(b != nil){
@@ -1204,18 +1204,18 @@ qbwrite(Queue *q, Block *b)
 		nexterror();
 	}
 
-	ilock(q);
+	ilock(&q->Lock);
 
 	/* give up if the queue is closed */
 	if(q->state & Qclosed){
-		iunlock(q);
+		iunlock(&q->Lock);
 		error(q->err);
 	}
 
 	/* if nonblocking, don't queue over the limit */
 	if(q->len >= q->limit){
 		if(q->noblock){
-			iunlock(q);
+			iunlock(&q->Lock);
 			freeb(b);
 			noblockcnt += n;
 			qunlock(&q->wlock);
@@ -1241,7 +1241,7 @@ qbwrite(Queue *q, Block *b)
 		q->state &= ~Qstarve;
 		dowakeup = 1;
 	}
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	/*  get output going again */
 	if(q->kick && (dowakeup || (q->state&Qkick)))
@@ -1267,9 +1267,9 @@ qbwrite(Queue *q, Block *b)
 		if(q->noblock || qnotfull(q))
 			break;
 
-		ilock(q);
+		ilock(&q->Lock);
 		q->state |= Qflow;
-		iunlock(q);
+		iunlock(&q->Lock);
 		sleep(&q->wr, qnotfull, q);
 	}
 	USED(b);
@@ -1287,7 +1287,7 @@ int32_t qibwrite(Queue *q, Block *b)
 
 	n = BLEN(b);
 
-	lock(q);
+	lock(&q->Lock);
 
 	if (q->bfirst)
 		q->blast->next = b;
@@ -1302,7 +1302,7 @@ int32_t qibwrite(Queue *q, Block *b)
 		dowakeup = 1;
 	}
 
-	unlock(q);
+	unlock(&q->Lock);
 
 	if (dowakeup) {
 		if (q->kick)
@@ -1379,13 +1379,13 @@ qiwrite(Queue *q, void *vp, int len)
 		memmove(b->wp, p+sofar, n);
 		b->wp += n;
 
-		ilock(q);
+		ilock(&q->Lock);
 
 		/* we use an artificially high limit for kernel prints since anything
 		 * over the limit gets dropped
 		 */
 		if(q->dlen >= 16*1024){
-			iunlock(q);
+			iunlock(&q->Lock);
 			freeb(b);
 			break;
 		}
@@ -1404,7 +1404,7 @@ qiwrite(Queue *q, void *vp, int len)
 			dowakeup = 1;
 		}
 
-		iunlock(q);
+		iunlock(&q->Lock);
 
 		if(dowakeup){
 			if(q->kick)
@@ -1442,7 +1442,7 @@ qclose(Queue *q)
 		return;
 
 	/* mark it */
-	ilock(q);
+	ilock(&q->Lock);
 	q->state |= Qclosed;
 	q->state &= ~(Qflow|Qstarve);
 	strcpy(q->err, Ehungup);
@@ -1451,7 +1451,7 @@ qclose(Queue *q)
 	q->len = 0;
 	q->dlen = 0;
 	q->noblock = 0;
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	/* free queued blocks */
 	freeblist(bfirst);
@@ -1469,13 +1469,13 @@ void
 qhangup(Queue *q, char *msg)
 {
 	/* mark it */
-	ilock(q);
+	ilock(&q->Lock);
 	q->state |= Qclosed;
 	if(msg == 0 || *msg == 0)
 		strcpy(q->err, Ehungup);
 	else
 		strncpy(q->err, msg, ERRMAX-1);
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	/* wake up readers/writers */
 	wakeup(&q->rr);
@@ -1497,12 +1497,12 @@ qisclosed(Queue *q)
 void
 qreopen(Queue *q)
 {
-	ilock(q);
+	ilock(&q->Lock);
 	q->state &= ~Qclosed;
 	q->state |= Qstarve;
 	q->eof = 0;
 	q->limit = q->inilim;
-	iunlock(q);
+	iunlock(&q->Lock);
 }
 
 /*
@@ -1564,12 +1564,12 @@ qflush(Queue *q)
 	Block *bfirst;
 
 	/* mark it */
-	ilock(q);
+	ilock(&q->Lock);
 	bfirst = q->bfirst;
 	q->bfirst = 0;
 	q->len = 0;
 	q->dlen = 0;
-	iunlock(q);
+	iunlock(&q->Lock);
 
 	/* free queued blocks */
 	freeblist(bfirst);

+ 6 - 6
sys/src/9/port/rmap.c

@@ -25,7 +25,7 @@ struct RMap {
         Map*    map;
         Map*    mapend;
 
-        Lock;
+        Lock Lock;
 };
 
 void
@@ -37,7 +37,7 @@ rmapfree(RMap* rmap, uintptr_t addr, uint size)
 	if(size == 0)
 		return;
 
-	lock(rmap);
+	lock(&rmap->Lock);
 	for(mp = rmap->map; mp->addr <= addr && mp->size; mp++)
 		;
 
@@ -70,7 +70,7 @@ rmapfree(RMap* rmap, uintptr_t addr, uint size)
 			}while((size = t) != 0);
 		}
 	}
-	unlock(rmap);
+	unlock(&rmap->Lock);
 }
 
 uintptr_t
@@ -79,7 +79,7 @@ rmapalloc(RMap* rmap, uintptr_t addr, uint size, int align)
 	Map *mp;
 	uint32_t maddr, oaddr;
 
-	lock(rmap);
+	lock(&rmap->Lock);
 	for(mp = rmap->map; mp->size; mp++){
 		maddr = mp->addr;
 
@@ -119,13 +119,13 @@ rmapalloc(RMap* rmap, uintptr_t addr, uint size, int align)
 			}while((mp-1)->size = mp->size);
 		}
 
-		unlock(rmap);
+		unlock(&rmap->Lock);
 		if(oaddr != maddr)
 			rmapfree(rmap, oaddr, maddr-oaddr);
 
 		return maddr;
 	}
-	unlock(rmap);
+	unlock(&rmap->Lock);
 
 	return 0;
 }

+ 8 - 8
sys/src/9/port/syszio.c

@@ -46,7 +46,7 @@ struct Map {
 
 struct ZMap {
 	Map*	map;
-	Lock;
+	Lock Lock;
 };
 
 static int inited;
@@ -585,9 +585,9 @@ zmapfree(ZMap* rmap, uintptr_t addr)
 	Proc *up = externup();
 	Map *mp, *prev, *next;
 
-	lock(rmap);
+	lock(&rmap->Lock);
 	if(waserror()){
-		unlock(rmap);
+		unlock(&rmap->Lock);
 		nexterror();
 	}
 	prev = nil;
@@ -614,7 +614,7 @@ zmapfree(ZMap* rmap, uintptr_t addr)
 		free(next);
 	}
 	poperror();
-	unlock(rmap);
+	unlock(&rmap->Lock);
 	if(DBGFLG > 1){
 		DBG("zmapfree %#ullx:\n", addr);
 		dumpzmap(rmap);
@@ -627,16 +627,16 @@ zmapalloc(ZMap* rmap, usize size)
 	Proc *up = externup();
 	Map *mp, *nmp;
 
-	lock(rmap);
+	lock(&rmap->Lock);
 	if(waserror()){
-		unlock(rmap);
+		unlock(&rmap->Lock);
 		nexterror();
 	}
 	for(mp = rmap->map; mp->free == 0 || mp->size < size; mp = mp->next)
 		;
 	if(mp == nil){
 		poperror();
-		unlock(rmap);
+		unlock(&rmap->Lock);
 		return 0ULL;
 	}
 	if(mp->free == 0)
@@ -652,7 +652,7 @@ zmapalloc(ZMap* rmap, usize size)
 	}
 	mp->free = 0;
 	poperror();
-	unlock(rmap);
+	unlock(&rmap->Lock);
 	if(DBGFLG > 1){
 		DBG("zmapalloc %#ullx:\n", mp->addr);
 		dumpzmap(rmap);

+ 13 - 13
sys/src/9/port/tod.c

@@ -45,7 +45,7 @@
 struct {
 	int	init;		/* true if initialized */
 	uint32_t	cnt;
-	Lock;
+	Lock Lock;
 	uint64_t	multiplier;	/* ns = off + (multiplier*ticks)>>31 */
 	uint64_t	divider;	/* ticks = (divider*(ns-off))>>31 */
 	uint64_t	umultiplier;	/* µs = (µmultiplier*ticks)>>31 */
@@ -66,9 +66,9 @@ todinit(void)
 {
 	if(tod.init)
 		return;
-	ilock(&tod);
+	ilock(&tod.Lock);
 	tod.last = fastticks((uint64_t *)&tod.hz);
-	iunlock(&tod);
+	iunlock(&tod.Lock);
 	todsetfreq(tod.hz);
 	tod.init = 1;
 	addclock0link(todfix, 100);
@@ -80,7 +80,7 @@ todinit(void)
 void
 todsetfreq(int64_t f)
 {
-	ilock(&tod);
+	ilock(&tod.Lock);
 	tod.hz = f;
 
 	/* calculate multiplier for time conversion */
@@ -88,7 +88,7 @@ todsetfreq(int64_t f)
 	tod.divider = mk64fract(f, TODFREQ) + 1;
 	tod.umultiplier = mk64fract(MicroFREQ, f);
 	tod.udivider = mk64fract(f, MicroFREQ) + 1;
-	iunlock(&tod);
+	iunlock(&tod.Lock);
 }
 
 /*
@@ -100,7 +100,7 @@ todset(int64_t t, int64_t delta, int n)
 	if(!tod.init)
 		todinit();
 
-	ilock(&tod);
+	ilock(&tod.Lock);
 	if(t >= 0){
 		tod.off = t;
 		tod.last = fastticks(nil);
@@ -120,7 +120,7 @@ todset(int64_t t, int64_t delta, int n)
 		tod.send = tod.sstart + n;
 		tod.delta = delta;
 	}
-	iunlock(&tod);
+	iunlock(&tod.Lock);
 }
 
 /*
@@ -141,7 +141,7 @@ todget(int64_t *ticksp)
 	 * and grabbing tod.last.  Also none of the int64_ts are atomic so
 	 * we have to look at them inside the lock.
 	 */
-	ilock(&tod);
+	ilock(&tod.Lock);
 	tod.cnt++;
 	ticks = fastticks(nil);
 
@@ -167,7 +167,7 @@ todget(int64_t *ticksp)
 	else
 		tod.lasttime = x;
 
-	iunlock(&tod);
+	iunlock(&tod.Lock);
 
 	if(ticksp != nil)
 		*ticksp = ticks;
@@ -183,10 +183,10 @@ tod2fastticks(int64_t ns)
 {
 	uint64_t x;
 
-	ilock(&tod);
+	ilock(&tod.Lock);
 	mul64fract(&x, ns-tod.off, tod.divider);
 	x += tod.last;
-	iunlock(&tod);
+	iunlock(&tod.Lock);
 	return x;
 }
 
@@ -203,7 +203,7 @@ todfix(void)
 
 	diff = ticks - tod.last;
 	if(diff > tod.hz){
-		ilock(&tod);
+		ilock(&tod.Lock);
 
 		/* convert to epoch */
 		mul64fract(&x, diff, tod.multiplier);
@@ -214,7 +214,7 @@ if(x > 30000000000ULL) print("todfix %llud\n", x);
 		tod.last = ticks;
 		tod.off = x;
 
-		iunlock(&tod);
+		iunlock(&tod.Lock);
 	}
 }