From 751bb35071ec3ab072f67992889399bbeb5d7793 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 12 May 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-05-12 --- pc/trap.c | 14 ++++++++++++-- pc/vgaclgd542x.c | 34 +++++++++++++++++++++++++++++++++- port/alarm.c | 2 +- port/alloc.c | 10 +++++----- port/auth.c | 4 ++-- port/cache.c | 6 +++--- port/chan.c | 26 +++++++++++++------------- port/dev.c | 4 ++-- port/devaudio.c | 2 +- port/devcons.c | 2 +- port/devenv.c | 4 ++-- port/devmnt.c | 26 +++++++++++++------------- port/devns16552.c | 14 +++++++------- port/devpipe.c | 2 +- port/devproc.c | 4 ++-- port/devroot.c | 18 +++++++++--------- port/devsd.c | 2 +- port/devssl.c | 4 ++-- port/fault.c | 26 +++++++++++++------------- port/page.c | 22 +++++++++++----------- port/pgrp.c | 4 ++-- port/portdat.h | 2 +- port/print.c | 2 +- port/proc.c | 16 ++++++++-------- port/segment.c | 20 ++++++++++---------- port/swap.c | 10 +++++----- port/sysfile.c | 6 +++--- port/sysproc.c | 18 +++++++++--------- 28 files changed, 173 insertions(+), 131 deletions(-) diff --git a/pc/trap.c b/pc/trap.c index 2df2d0a34ba8681c0b019bc800f953400f172bf3..48835905e74128c2bbd6f0bd29c31c413de83ab2 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -140,6 +140,14 @@ trap(Ureg* ureg) up->dbgreg = ureg; } +{ +ulong x, y; + +x = (ulong)&(m->stack[512]); +y = (ulong)&mach; +if(y < x) panic("trap: kstack %lux %lux", m->stack, y); +} + v = ureg->trap; if(ctl = irqctl[v]){ if(ctl->isintr){ @@ -158,8 +166,10 @@ trap(Ureg* ureg) /* preemptive scheduling */ if(ctl->isintr && v != VectorTIMER && v != VectorCLOCK) - if(up && up->state == Running && anyhigher()) - sched(); + if(up && up->state == Running) + if(anyhigher()) + if(!active.exiting) + sched(); } else if(v <= 16 && user){ spllo(); diff --git a/pc/vgaclgd542x.c b/pc/vgaclgd542x.c index db25ae8409b24b2d153a492a318cb6453a57f27e..7b9143c196006fe19f1f403b18d3c30095794ec4 100644 --- a/pc/vgaclgd542x.c +++ b/pc/vgaclgd542x.c @@ -40,6 +40,38 @@ clgd542xpage(VGAscr* scr, int page) unlock(&scr->devlock); } +static ulong +clgd542xlinear(VGAscr* scr, int* size, int* align) +{ + ulong aperture, oaperture; + int oapsize, wasupamem; + Pcidev *p; + + oaperture = scr->aperture; + oapsize = scr->apsize; + wasupamem = scr->isupamem; + if(wasupamem) + upafree(oaperture, oapsize); + scr->isupamem = 0; + + if(p = pcimatch(nil, 0x1013, 0)){ + aperture = p->mem[0].bar & ~0x0F; + *size = p->mem[0].size; + } + else + aperture = 0; + + aperture = upamalloc(aperture, *size, *align); + if(aperture == 0){ + if(wasupamem && upamalloc(oaperture, oapsize, 0)) + scr->isupamem = 1; + } + else + scr->isupamem = 1; + + return aperture; +} + static void clgd542xdisable(VGAscr*) { @@ -244,7 +276,7 @@ VGAdev vgaclgd542xdev = { 0, 0, clgd542xpage, - 0, + clgd542xlinear, }; VGAcur vgaclgd542xcur = { diff --git a/port/alarm.c b/port/alarm.c index a854c3f8f2c5fd2df89c2f4ca980e7501048f3c8..ed5a82e1134c0e8e1fb71334dbc199b3b3b073ec 100644 --- a/port/alarm.c +++ b/port/alarm.c @@ -120,5 +120,5 @@ done: up->alarm = when; qunlock(&alarms); - return old; + return old; } diff --git a/port/alloc.c b/port/alloc.c index fb0bbad566f8ff8e4c4c310c863a0fe60afaf419..d66f02fe1bfda568e2dae3ec8bee16e293ae543a 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -65,7 +65,7 @@ pooldel(Pool *p, Bhdr *t) t->fwd->prev = t->prev; return; } - + if(t->fwd != t) { f = t->fwd; s = t->parent; @@ -78,7 +78,7 @@ pooldel(Pool *p, Bhdr *t) else s->right = f; } - + rp = t->left; f->left = rp; if(rp != nil) @@ -87,7 +87,7 @@ pooldel(Pool *p, Bhdr *t) f->right = rp; if(rp != nil) rp->parent = f; - + t->prev->fwd = t->fwd; t->fwd->prev = t->prev; return; @@ -96,7 +96,7 @@ pooldel(Pool *p, Bhdr *t) if(t->left == nil) rp = t->right; else { - if(t->right == nil) + if(t->right == nil) rp = t->left; else { f = t; @@ -230,7 +230,7 @@ poolalloc(Pool *p, int size) t = B2NB(q); t->size = ns; B2T(t)->hdr = t; - pooladd(p, t); + pooladd(p, t); p->cursize += q->size; if(p->cursize > p->hw) p->hw = p->cursize; diff --git a/port/auth.c b/port/auth.c index bf89ede6460c193e2c83ab4d0e4a95f6007a10d3..51b33cd8634076b7a2c0769fa8d18664528007f6 100644 --- a/port/auth.c +++ b/port/auth.c @@ -170,7 +170,7 @@ sysfsession(ulong *arg) } unlock(&s->send); - /* + /* * If server requires no ticket, or user is "none", or a ticket * is already cached, zero the request type */ @@ -349,7 +349,7 @@ authreply(Session *s, ulong id, Fcall *f) if(memcmp(cp->a.chal, s->cchal, sizeof(cp->a.chal))){ print("bad returned challenge\n"); error("server lies"); - } + } if(cp->a.id != id){ print("bad returned id\n"); error("server lies"); diff --git a/port/cache.c b/port/cache.c index 117a6e512e3784d756e0fbe1e763365c6431423f..3cd0894689135dac915137c0a0144a3c31dd92a1 100644 --- a/port/cache.c +++ b/port/cache.c @@ -56,7 +56,7 @@ cinit(void) cache.head = xalloc(sizeof(Mntcache)*NFILE); m = cache.head; - + for(i = 0; i < NFILE-1; i++) { m->next = m+1; m->prev = m-1; @@ -129,7 +129,7 @@ void ctail(Mntcache *m) { /* Unlink and send to the tail */ - if(m->prev) + if(m->prev) m->prev->next = m->next; else cache.head = m->next; @@ -534,7 +534,7 @@ cwrite(Chan* c, uchar *buf, int len, vlong off) for(f = m->list; f; f = f->next) { if(f->start >= offset) break; - p = f; + p = f; } if(0 && f != 0 && offset < f->start+f->len) { diff --git a/port/chan.c b/port/chan.c index 879b958743ae777398b2c3ce3074f4148c5ab2e0..6fb005bf6f123aea79d324af627ae778414114a1 100644 --- a/port/chan.c +++ b/port/chan.c @@ -32,7 +32,7 @@ decref(Ref *r) lock(r); x = --r->ref; unlock(r); - if(x < 0) + if(x < 0) panic("decref"); return x; @@ -120,12 +120,12 @@ chanfree(Chan *c) */ if(c->path) { if (c->path->ref <= 0) { - char buf[100]; - ptpath(c->path, buf, sizeof(buf)); - print("decref %s\n", buf); - } + char buf[100]; + ptpath(c->path, buf, sizeof(buf)); + print("decref %s\n", buf); + } decref(c->path); - } + } lock(&chanalloc); c->next = chanalloc.free; @@ -214,7 +214,7 @@ cmount(Chan *new, Chan *old, int flag, char *spec) * if this is a union mount, add the old * node to the mount chain. */ - if(order != MREPL) + if(order != MREPL) m->mount = newmount(m, old, 0, 0); } @@ -342,8 +342,8 @@ domount(Chan *c) nc->xmnt = nc->mnt; nc->mountid = m->mount->mountid; cclose(c); - c = nc; - break; + c = nc; + break; } poperror(); @@ -412,7 +412,7 @@ walk(Chan **cp, char *name, int domnt) return 0; } - if(ac->mnt == nil) + if(ac->mnt == nil) return -1; c = nil; @@ -453,7 +453,7 @@ walk(Chan **cp, char *name, int domnt) } cclose(ac); *cp = c; - return 0; + return 0; } /* @@ -659,7 +659,7 @@ namec(char *name, int amode, int omode, ulong perm) if(omode == OEXEC) c->flag &= ~CCACHE; - + c = devtab[c->type]->open(c, omode); if(omode & OCEXEC) @@ -671,7 +671,7 @@ namec(char *name, int amode, int omode, ulong perm) case Amount: /* * When mounting on an already mounted upon directory, - * one wants subsequent mounts to be attached to the + * one wants subsequent mounts to be attached to the * original directory, not the replacement. */ if(walk(&c, elem, 0) < 0) diff --git a/port/dev.c b/port/dev.c index 5b8252a90d3dda18271d1c82cd130c0b09afc260..28588b4bc83bf178e93882074c8624a3ac333740 100644 --- a/port/dev.c +++ b/port/dev.c @@ -235,7 +235,7 @@ Return: return c; } -void +void devcreate(Chan*, char*, int, ulong) { error(Eperm); @@ -266,7 +266,7 @@ devbwrite(Chan *c, Block *bp, ulong offset) n = devtab[c->type]->write(c, bp->rp, BLEN(bp), offset); freeb(bp); - return n; + return n; } void diff --git a/port/devaudio.c b/port/devaudio.c index 76ffdc504c97e6cd12b5327da0f8e136deb16563..cf38aee22d230a866bbcc317bbe2fa25dea91b88 100644 --- a/port/devaudio.c +++ b/port/devaudio.c @@ -781,7 +781,7 @@ audioinit(void) } audio.major = 4; } - + /* * initialize the mixer */ diff --git a/port/devcons.c b/port/devcons.c index 2e3f921f6c4184e3a82412c8a29885d73b93de45..f9e43cf9c871b1effcec858eed19f98c1e15d75f 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -101,7 +101,7 @@ putstrn0(char *str, int n, int usewrite) } else { if(usewrite) qwrite(printq, str, n); - else + else qiwrite(printq, str, n); break; } diff --git a/port/devenv.c b/port/devenv.c index adad27703b557ac87c04a48e4f13e7245ababc88..4e4695e217d752b6b8282dbecf72a10c0637f0f6 100644 --- a/port/devenv.c +++ b/port/devenv.c @@ -56,7 +56,7 @@ envopen(Chan *c, int omode) { Egrp *eg; Evalue *e; - + eg = up->egrp; if(c->qid.path & CHDIR) { if(omode != OREAD) @@ -115,7 +115,7 @@ envcreate(Chan *c, char *name, int omode, ulong) e->link = eg->entries; eg->entries = e; c->qid = (Qid){e->path, 0}; - + qunlock(eg); poperror(); diff --git a/port/devmnt.c b/port/devmnt.c index c5987a5567c5dcf6cf27d964759032e98df43d46..a62ba5c7f3436a65a1669e60ff40cb31f8ce1868 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -106,13 +106,13 @@ mntattach(char *muxattach) c->flag |= CCACHE; return c; } - unlock(m); + unlock(m); } } m = mntalloc.mntfree; if(m != 0) - mntalloc.mntfree = m->list; + mntalloc.mntfree = m->list; else { m = malloc(sizeof(Mnt)); if(m == 0) { @@ -269,7 +269,7 @@ mntclone(Chan *c, Chan *nc) return nc; } -static int +static int mntwalk(Chan *c, char *name) { Mnt *m; @@ -298,7 +298,7 @@ mntwalk(Chan *c, char *name) return 1; } -static void +static void mntstat(Chan *c, char *dp) { Mnt *m; @@ -350,7 +350,7 @@ mntopen(Chan *c, int omode) return c; } -static void +static void mntcreate(Chan *c, char *name, int omode, ulong perm) { Mnt *m; @@ -379,12 +379,12 @@ mntcreate(Chan *c, char *name, int omode, ulong perm) copen(c); } -static void +static void mntclunk(Chan *c, int t) { Mnt *m; Mntrpc *r; - + m = mntchk(c); r = mntralloc(c); if(waserror()){ @@ -448,7 +448,7 @@ mntclose(Chan *c) mntclunk(c, Tclunk); } -static void +static void mntremove(Chan *c) { mntclunk(c, Tremove); @@ -474,13 +474,13 @@ mntwstat(Chan *c, char *dp) mntfree(r); } -long +long mntread9p(Chan *c, void *buf, long n, vlong off) { return mnt9prdwr(Tread, c, buf, n, off); } -static long +static long mntread(Chan *c, void *buf, long n, vlong off) { uchar *p, *e; @@ -517,13 +517,13 @@ mntread(Chan *c, void *buf, long n, vlong off) return n; } -long +long mntwrite9p(Chan *c, void *buf, long n, vlong off) { return mnt9prdwr(Twrite, c, buf, n, off); } -static long +static long mntwrite(Chan *c, void *buf, long n, vlong off) { return mntrdwr(Twrite, c, buf, n, off); @@ -641,7 +641,7 @@ mountrpc(Mnt *m, Mntrpc *r) break; print("mnt: proc %s %d: mismatch rep 0x%lux T%d R%d rq %d fls %d rp %d\n", up->text, up->pid, - r, r->request.type, r->reply.type, r->request.tag, + r, r->request.type, r->reply.type, r->request.tag, r->flushtag, r->reply.tag); error(Emountrpc); } diff --git a/port/devns16552.c b/port/devns16552.c index cc683d27b8f4d4ec05bd8e6f2adcc95c98bc1ab1..9cf223b3a2c03425317779ec4e58d99bb0c09e82 100644 --- a/port/devns16552.c +++ b/port/devns16552.c @@ -253,7 +253,7 @@ ns16552fifoon(Uart *p) if(uartrdreg(p, Data)) ; } - + /* turn on fifo */ p->fifoon = 1; uartwrreg(p, Fifoctl, Fena|Ftrig); @@ -262,7 +262,7 @@ ns16552fifoon(Uart *p) /* didn't work, must be an earlier chip type */ p->nofifo = 1; } - + splx(x); } @@ -555,7 +555,7 @@ ns16552intr(int dev) if(l & Oerror) p->overrun++; break; - + case 4: /* received data available */ case 12: ch = uartrdreg(p, Data) & 0xff; @@ -579,11 +579,11 @@ ns16552intr(int dev) iunlock(&p->rlock); } break; - + case 2: /* transmitter not full */ ns16552kick(p); break; - + case 0: /* modem status */ ch = uartrdreg(p, Mstat); if(ch & Ctsc){ @@ -595,7 +595,7 @@ ns16552intr(int dev) iunlock(&p->tlock); } break; - + default: if(s&1) return; @@ -844,7 +844,7 @@ ns16552ctl(Uart *p, char *cmd) ns16552break(p, 0); return; } - + n = atoi(cmd+1); switch(*cmd){ diff --git a/port/devpipe.c b/port/devpipe.c index 41a344761e19139b5f3bbbd4b8c9bc58b9ae08f2..74f593968e3b02ee2054b8c72f2b4622c00f2204 100644 --- a/port/devpipe.c +++ b/port/devpipe.c @@ -220,7 +220,7 @@ pipeclose(Chan *c) } } - + /* * if both sides are closed, they are reusable */ diff --git a/port/devproc.c b/port/devproc.c index 0e4a0960907c6ba2fdc2845b6507a80003d88ea9..8ef0bdfe973ecdfe8140b4668032c39cdd3f0a44 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -926,10 +926,10 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read) poperror(); pte = s->map[soff/PTEMAPMEM]; if(pte == 0) - panic("procctlmemio"); + panic("procctlmemio"); pg = pte->pages[(soff&(PTEMAPMEM-1))/BY2PG]; if(pagedout(pg)) - panic("procctlmemio1"); + panic("procctlmemio1"); l = BY2PG - (offset&(BY2PG-1)); if(n > l) diff --git a/port/devroot.c b/port/devroot.c index d3b5eb373f33938e74a0ac90df09203ccf247b3a..f6f04c1d7a21eae487c03ec901e65a3679c75f30 100644 --- a/port/devroot.c +++ b/port/devroot.c @@ -16,7 +16,7 @@ enum{ Qrecover, Qboot, /* readable files */ - Nfiles=13, /* max root files */ + Nfiles=13, /* max root files */ }; extern ulong bootlen; @@ -44,7 +44,7 @@ struct Recover Recover *next; }; -struct +struct { Lock; QLock; @@ -59,7 +59,7 @@ void addrootfile(char *name, uchar *contents, ulong len) { Dirtab *d; - + if(nroot >= Nfiles) panic("too many root files"); @@ -84,7 +84,7 @@ rootattach(char *spec) return devattach('/', spec); } -static int +static int rootwalk(Chan *c, char *name) { if(strcmp(name, "..") == 0) { @@ -96,7 +96,7 @@ rootwalk(Chan *c, char *name) return devwalk(c, name, rootdir, nroot, devgen); } -static void +static void rootstat(Chan *c, char *dp) { devstat(c, dp, rootdir, nroot, devgen); @@ -110,7 +110,7 @@ rootopen(Chan *c, int omode) break; case Qrecover: if(recovbusy) - error(Einuse); + error(Einuse); if(strcmp(up->user, eve) != 0) error(Eperm); recovbusy = 1; @@ -123,7 +123,7 @@ rootopen(Chan *c, int omode) /* * sysremove() knows this is a nop */ -static void +static void rootclose(Chan *c) { switch(c->qid.path) { @@ -142,7 +142,7 @@ rdrdy(void*) return reclist.q != 0; } -static long +static long rootread(Chan *c, void *buf, long n, vlong off) { ulong t; @@ -193,7 +193,7 @@ rootread(Chan *c, void *buf, long n, vlong off) return n; } -static long +static long rootwrite(Chan *c, void *buf, long n, vlong) { char tmp[256]; diff --git a/port/devsd.c b/port/devsd.c index c58665b34b05806711f3fb4a0ab851ac5a005e91..945208e30da062fc779a08b1bf43fe326ee85c23 100644 --- a/port/devsd.c +++ b/port/devsd.c @@ -189,7 +189,7 @@ sdattach(char *spec) sdrdpart(&disk[i]); qunlock(&disk[i]); } - + return devattach('w', spec); } diff --git a/port/devssl.c b/port/devssl.c index 9f1eda95e0d06cec7368ee9d46461149c1f6dfca..e5cc8dbf531e794deb2273f88704e604a23a19bc 100644 --- a/port/devssl.c +++ b/port/devssl.c @@ -827,7 +827,7 @@ sslwrite(Chan *c, void *a, long n, vlong off) m = e - p; if(m > s.s->max) m = s.s->max; - + b.b = allocb(m); if(waserror()){ freeb(b.b); @@ -836,7 +836,7 @@ sslwrite(Chan *c, void *a, long n, vlong off) memmove(b.b->wp, p, m); poperror(); b.b->wp += m; - + sslbwrite(c, b.b, offset); p += m; diff --git a/port/fault.c b/port/fault.c index c99decfc29eb3197d470464337ac0d519a96159d..99d4dcb88ed1796895ce9a4a0790fe002dd03b38 100644 --- a/port/fault.c +++ b/port/fault.c @@ -61,7 +61,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) addr &= ~(BY2PG-1); soff = addr-s->base; p = &s->map[soff/PTEMAPMEM]; - if(*p == 0) + if(*p == 0) *p = ptealloc(); etp = *p; @@ -81,7 +81,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) case SG_TEXT: /* Demand load */ if(pagedout(*pg)) pio(s, addr, soff, pg); - + mmuphys = PPN((*pg)->pa) | PTERONLY|PTEVALID; (*pg)->modref = PG_REF; break; @@ -92,15 +92,15 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) lkp = *pg; lock(lkp); - if(lkp->image) - duppage(lkp); + if(lkp->image) + duppage(lkp); unlock(lkp); goto done; case SG_BSS: case SG_SHARED: /* Zero fill on demand */ case SG_STACK: - case SG_MAP: + case SG_MAP: if(*pg == 0) { if(type == SG_MAP) { sprint(buf, "map 0x%lux %c", va, read ? 'r' : 'w'); @@ -142,9 +142,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu) /* put a duplicate of a text page back onto * the free list */ - if(lkp->image) - duppage(lkp); - + if(lkp->image) + duppage(lkp); + unlock(lkp); } done: @@ -211,7 +211,7 @@ pio(Segment *s, ulong addr, ulong soff, Page **p) new = newpage(0, 0, addr); k = kmap(new); kaddr = (char*)VA(k); - + if(loadrec == 0) { /* This is demand load */ c = s->image->c; while(waserror()) { @@ -240,7 +240,7 @@ pio(Segment *s, ulong addr, ulong soff, Page **p) cachepage(new, s->image); *p = new; } - else + else putpage(new); } else { /* This is paged out */ @@ -301,14 +301,14 @@ okaddr(ulong addr, ulong len, int write) pprint("suicide: invalid address 0x%lux in sys call pc=0x%lux\n", addr, userpc()); return 0; } - + void validaddr(ulong addr, ulong len, int write) { if(!okaddr(addr, len, write)) pexit("Suicide", 0); } - + /* * &s[0] is known to be a valid address. */ @@ -348,7 +348,7 @@ seg(Proc *p, ulong addr, int dolock) if(addr >= n->base && addr < n->top) { if(dolock == 0) return n; - + qlock(&n->lk); if(addr >= n->base && addr < n->top) return n; diff --git a/port/page.c b/port/page.c index a036a158c553dcf14bae50c4cdbd4a2f4fae25ef..099467ee3646901d18ba7e5957873c0c7fc27b6c 100644 --- a/port/page.c +++ b/port/page.c @@ -103,8 +103,8 @@ retry: /* * If called from fault and we lost the segment from - * underneath don't waste time allocating and freeing - * a page. Fault will call newpage again when it has + * underneath don't waste time allocating and freeing + * a page. Fault will call newpage again when it has * reacquired the segment locks */ if(dontalloc) @@ -125,7 +125,7 @@ retry: ct = PG_NEWCOL; } - if(p->prev) + if(p->prev) p->prev->next = p->next; else palloc.head = p->next; @@ -259,7 +259,7 @@ duppage(Page *p) /* Always call with p locked */ /* No freelist cache when memory is very low */ if(palloc.freecount < swapalloc.highwater) { unlock(&palloc); - uncachepage(p); + uncachepage(p); return; } @@ -271,11 +271,11 @@ duppage(Page *p) /* Always call with p locked */ /* No page of the correct color */ if(np == 0) { unlock(&palloc); - uncachepage(p); + uncachepage(p); return; } - if(np->prev) + if(np->prev) np->prev->next = np->next; else palloc.head = np->next; @@ -305,7 +305,7 @@ duppage(Page *p) /* Always call with p locked */ unlock(np); return; } - + uncachepage(np); np->va = p->va; np->daddr = p->daddr; @@ -407,7 +407,7 @@ lookpage(Image *i, ulong daddr) lock(&palloc); if(++f->ref == 1) { - if(f->prev) + if(f->prev) f->prev->next = f->next; else palloc.head = f->next; @@ -422,7 +422,7 @@ lookpage(Image *i, ulong daddr) unlock(&palloc); unlock(f); - return f; + return f; } } unlock(&palloc.hashlock); @@ -451,7 +451,7 @@ ptecpy(Pte *old) *dst = *src; } - return new; + return new; } Pte* @@ -487,7 +487,7 @@ freepte(Segment *s, Pte *p) } for(pg = p->pages; pg < ptop; pg++) { pt = *pg; - if(pt == 0) + if(pt == 0) continue; lock(pt); ref = --pt->ref; diff --git a/port/pgrp.c b/port/pgrp.c index cd9c5c7e17415dea4cc53dbdcaebfa65d53b2c9d..6e13c5028aac2bb364c522734c86e10b31632160 100644 --- a/port/pgrp.c +++ b/port/pgrp.c @@ -71,7 +71,7 @@ void closepgrp(Pgrp *p) { Mhead **h, **e, *f, *next; - + if(decref(p) != 0) return; @@ -145,7 +145,7 @@ pgrpcpy(Pgrp *to, Pgrp *from) m->copy = n; pgrpinsert(&order, m); *link = n; - link = &n->next; + link = &n->next; } } } diff --git a/port/portdat.h b/port/portdat.h index eb19bab07c9160f4f8b85cf312b92850ad720e25..faffcd3ce94f65ebdf2f165641131fbf1ca1e66b 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -575,7 +575,7 @@ struct Proc ulong alarm; /* Time of call */ int newtlb; /* Pager has changed my pte's, I must flush */ - ulong rendtag; /* Tag for rendezvous */ + ulong rendtag; /* Tag for rendezvous */ ulong rendval; /* Value for rendezvous */ Proc *rendhash; /* Hash list for tag values */ diff --git a/port/print.c b/port/print.c index 62b04b34905ad0c62c5f2b80913949ff69042914..c48b244db9f2e8efa59837ca5b6f834163f1fadf 100644 --- a/port/print.c +++ b/port/print.c @@ -121,7 +121,7 @@ loop: case 0: *local.out = 0; return local.out; - + default: printcol++; goto common; diff --git a/port/proc.c b/port/proc.c index 71287bef430ac2c2cb9355df32528ae7d09c234d..46ad2e7d1e5bed29b34af0a69efb6d6cb67f52a4 100644 --- a/port/proc.c +++ b/port/proc.c @@ -63,7 +63,7 @@ schedinit(void) /* never returns */ break; case Moribund: up->state = Dead; - /* + /* * Holding locks from pexit: * procalloc */ @@ -244,7 +244,7 @@ found: /* * p->mach==0 only when process state is saved */ - if(p == 0 || p->mach){ + if(p == 0 || p->mach){ unlock(runq); goto loop; } @@ -507,7 +507,7 @@ wakeup(Rendez *r) if(r->p == p && p->r == r){ r->p = 0; - if(p->state != Wakeme) + if(p->state != Wakeme) panic("wakeup: state"); p->r = 0; ready(p); @@ -551,7 +551,7 @@ postnote(Proc *p, int dolock, char *n, int flag) r = p->r; if(r){ if(r->p != p || p->r != r || p->state != Wakeme) - panic("postnote: state"); + panic("postnote: state %d %d %d", r->p != p, p->r != r, p->state); r->p = 0; p->r = 0; ready(p); @@ -682,7 +682,7 @@ pexit(char *exitstr, int freemem) while(waserror()) ; - + wq = smalloc(sizeof(Waitq)); poperror(); @@ -711,15 +711,15 @@ pexit(char *exitstr, int freemem) * written daemon processes from accumulating lots of wait * records. */ - if(p->pid == up->parentpid && p->state != Broken && p->nwait < 128) { + if(p->pid == up->parentpid && p->state != Broken && p->nwait < 128) { p->nchild--; p->time[TCUser] += utime; p->time[TCSys] += stime; - + wq->next = p->waitq; p->waitq = wq; p->nwait++; - + wakeup(&p->waitr); unlock(&p->exl); } diff --git a/port/segment.c b/port/segment.c index e236463956b579dd3a90580395bd6d87f3f55e9f..fe1cbf4a6f0ffb0ef3188d076a9e0e1d3cba15b2 100644 --- a/port/segment.c +++ b/port/segment.c @@ -180,7 +180,7 @@ dupseg(Segment **seg, int segno, int share) n->flushme = s->flushme; qunlock(&s->lk); - return n; + return n; } void @@ -218,8 +218,8 @@ attachimage(int type, Chan *c, ulong base, ulong len) lock(&imagealloc); /* - * Search the image cache for remains of the text from a previous - * or currently running incarnation + * Search the image cache for remains of the text from a previous + * or currently running incarnation */ for(i = ihash(c->qid.path); i; i = i->hash) { if(c->qid.path == i->qid.path) { @@ -234,7 +234,7 @@ attachimage(int type, Chan *c, ulong base, ulong len) unlock(i); } } - + /* * imagereclaim dumps pages from the free list which are cached by image * structures. This should free some image structures. @@ -335,10 +335,10 @@ putimage(Image *i) lock(i); if(--i->ref == 0) { l = &ihash(i->qid.path); - i->qid = (Qid){~0, ~0}; + i->qid = (Qid){~0, ~0}; unlock(i); c = i->c; - + lock(&imagealloc); for(f = *l; f; f = f->hash) { if(f == i) { @@ -393,7 +393,7 @@ ibrk(ulong addr, int seg) } addr = s->base; } - + newtop = PGROUND(addr); newsize = (newtop-s->base)/BY2PG; if(newtop < s->top) { @@ -435,7 +435,7 @@ mfreeseg(Segment *s, ulong start, int pages) j = (soff&(PTEMAPMEM-1))/BY2PG; for(i = soff/PTEMAPMEM; i < SEGMAPSIZE; i++) { - if(pages <= 0) + if(pages <= 0) break; if(s->map[i] == 0) { pages -= PTEPERTAB-j; @@ -446,7 +446,7 @@ mfreeseg(Segment *s, ulong start, int pages) pg = s->map[i]->pages[j]; if(pg) { putpage(pg); - s->map[i]->pages[j] = 0; + s->map[i]->pages[j] = 0; } if(--pages == 0) return; @@ -467,7 +467,7 @@ isoverlap(Proc *p, ulong va, int len) for(i = 0; i < NSEG; i++) { ns = p->seg[i]; if(ns == 0) - continue; + continue; if((newtop > ns->base && newtop <= ns->top) || (va >= ns->base && va < ns->top)) return 1; diff --git a/port/swap.c b/port/swap.c index edb7ab3444215fa42555779aed080347122843f5..d4453d4fcbacdb9eda7a743be86ea6a291c3ed9e 100644 --- a/port/swap.c +++ b/port/swap.c @@ -49,12 +49,12 @@ newswap(void) look = memchr(swapalloc.last, 0, swapalloc.top-swapalloc.last); if(look == 0) panic("inconsistent swap"); - + *look = 1; swapalloc.last = look; swapalloc.free--; unlock(&swapalloc); - return (look-swapalloc.swmap) * BY2PG; + return (look-swapalloc.swmap) * BY2PG; } void @@ -100,7 +100,7 @@ pager(void *junk) Segment *s; Proc *p, *ep; - if(waserror()) + if(waserror()) panic("pager: os error\n"); p = proctab(0); @@ -160,7 +160,7 @@ loop: goto loop; } -static void +static void pageout(Proc *p, Segment *s) { int type, i; @@ -244,7 +244,7 @@ canflush(Proc *p, Segment *s) } p++; } - return 1; + return 1; } static void diff --git a/port/sysfile.c b/port/sysfile.c index 09685df6cbb1bf4aed0bf12c1567e6a7ba447e84..f8d5458074fa732894ce080ff0f098e54e203148 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -302,7 +302,7 @@ unionread(Chan *c, void *va, long n) } /* Error causes component of union to be skipped */ - if(waserror()) { + if(waserror()) { cclose(nc); goto next; } @@ -311,7 +311,7 @@ unionread(Chan *c, void *va, long n) nc->offset = c->offset; nr = devtab[nc->type]->read(nc, va, n, nc->offset); /* devdirread e.g. changes it */ - c->offset = nc->offset; + c->offset = nc->offset; poperror(); cclose(nc); @@ -708,7 +708,7 @@ sysunmount(ulong *arg) cclose(cmount); if(cmounted) cclose(cmounted); - poperror(); + poperror(); return 0; } diff --git a/port/sysproc.c b/port/sysproc.c index c143c034e18a002497ddee7a4b34f0ec2bbbb8bc..3bb5ae7ac6abdc1482a0ae3e3f4dab4c091962e3 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -80,7 +80,7 @@ sysrfork(ulong *arg) p->nerrlab = 0; p->slash = up->slash; p->dot = up->dot; - incref(p->dot); + incref(p->dot); memmove(p->note, up->note, sizeof(p->note)); p->nnote = up->nnote; @@ -109,7 +109,7 @@ sysrfork(ulong *arg) } /* Process groups */ - if(flag & (RFNAMEG|RFCNAMEG)) { + if(flag & (RFNAMEG|RFCNAMEG)) { p->pgrp = newpgrp(); if(flag & RFNAMEG) pgrpcpy(p->pgrp, up->pgrp); @@ -144,7 +144,7 @@ sysrfork(ulong *arg) * the scheduler in user mode with the return register zero */ forkchild(p, up->dbgreg); - + p->parent = up; p->parentpid = up->pid; if(flag&RFNOWAIT) @@ -217,7 +217,7 @@ sysexec(ulong *arg) } if(!indir) strcpy(elem, up->elem); - + n = devtab[tc->type]->read(tc, &exec, sizeof(Exec), 0); if(n < 2) error(Ebadexec); @@ -231,7 +231,7 @@ sysexec(ulong *arg) error(Ebadexec); break; /* for binary */ } - + /* * Process #! /bin/sh args ... */ @@ -461,7 +461,7 @@ syssleep(ulong *arg) up->priority = 0; sched(); return 0; - } + } if(n < TK2MS(1)) n = TK2MS(1); tsleep(&up->sleep, return0, 0, n); @@ -471,7 +471,7 @@ syssleep(ulong *arg) long sysalarm(ulong *arg) { - return procalarm(arg[0]); + return procalarm(arg[0]); } long @@ -592,7 +592,7 @@ syssegdetach(ulong *arg) for(i = 0; i < NSEG; i++) if(s = up->seg[i]) { qlock(&s->lk); - if((addr >= s->base && addr < s->top) || + if((addr >= s->base && addr < s->top) || (s->top == s->base && addr == s->base)) goto found; qunlock(&s->lk); @@ -668,7 +668,7 @@ sysrendezvous(ulong *arg) ; ready(p); unlock(up->rgrp); - return val; + return val; } l = &p->rendhash; }