From ce33b79eb1c196b89143d1c0c827672e0177efce Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 21 Nov 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-11-21 --- pc/devfloppy.c | 2 +- pc/devi82365.c | 4 ++-- pc/main.c | 4 ++++ port/devcons.c | 2 +- port/portfns.h | 2 +- port/qio.c | 40 +++++++++++++++++++++++++++------------- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/pc/devfloppy.c b/pc/devfloppy.c index edd21aaa65d92a0588301a8c9f0066fe8b81213e..90c0afceee6de99d1fb0130766c90e6eb6a09d45 100644 --- a/pc/devfloppy.c +++ b/pc/devfloppy.c @@ -863,7 +863,7 @@ floppyrecal(Drive *dp) * if the controller or a specific drive is in a confused state, * reset it and get back to a kown state */ -void +static void floppyrevive(void) { Drive *dp; diff --git a/pc/devi82365.c b/pc/devi82365.c index 8c5136b9c161be73e70a6afa5dd4c40a1a27936a..bb8151676349b7d10fc1c2de26bc0a5e571614fd 100644 --- a/pc/devi82365.c +++ b/pc/devi82365.c @@ -1265,7 +1265,7 @@ memspace(Slot *pp, int asize, int lsize, int host) } } -void +static void tentry(Slot *pp, int ttype) { uchar c, i, feature; @@ -1338,7 +1338,7 @@ tentry(Slot *pp, int ttype) pp->configed++; } -void +static void tvers1(Slot *pp, int ttype) { uchar c, major, minor; diff --git a/pc/main.c b/pc/main.c index 07fe67cd1918bdf1e3d8f741f4fc58611b0d4a5b..5559616e4a753d91caac435e9fa22e7ded59f21d 100644 --- a/pc/main.c +++ b/pc/main.c @@ -128,6 +128,10 @@ init0(void) strcat(tstr, " %s"); ksetterm(tstr); ksetenv("cputype", "386"); + if(cpuserver) + ksetenv("service", "cpu"); + else + ksetenv("service", "terminal"); for(i = 0; i < nconf; i++) if(confname[i]) ksetenv(confname[i], confval[i]); diff --git a/port/devcons.c b/port/devcons.c index 10556957c9e7b6160b03fd0c30db06d3c5e4deb3..0e7c0f7527aa95a719422fef5211b4f5af096354 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -931,7 +931,7 @@ genrandom(void*) } } -void +static void randominit(void) { rb.ep = rb.buf + sizeof(rb.buf); diff --git a/port/portfns.h b/port/portfns.h index 154537cd50c597d006722a906109c429f83c47fa..0170884534e66388c2f179fe4fcf5a21c61270d4 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -14,7 +14,6 @@ void authreply(Session*, ulong, Fcall*); ulong authrequest(Session*, Fcall*); long authwrite(Chan*, char*, int); Page* auxpage(void); -Block* bpad(Block*, int); void buzz(int, int); void cachedel(Image*, ulong); void cachepage(Page*, Image*); @@ -163,6 +162,7 @@ int notify(Ureg*); int nrand(int); int okaddr(ulong, ulong, int); int openmode(ulong); +Block* padblock(Block*, int); void pageinit(void); void panic(char*, ...); void pexit(char*, int); diff --git a/port/qio.c b/port/qio.c index e4974e8b62fdf1effe21bab87c2af888f8e288bc..2c3684a841b27a4bb551392002791d571e5fe589 100644 --- a/port/qio.c +++ b/port/qio.c @@ -170,25 +170,39 @@ allocb(int size) ulong bpadoverhead; /* - * pad a block to the front + * pad a block to the front (or the back if size is negative) */ Block* -bpad(Block *bp, int size) +padblock(Block *bp, int size) { int n; Block *nbp; - if(bp->rp - bp->base > size) - return bp; - - n = bp->wp - bp->rp; - bpadoverhead += n; - nbp = allocb(size+n); - nbp->rp += size; - nbp->wp = nbp->rp; - memmove(nbp->wp, bp->rp, n); - nbp->wp += n; - freeb(bp); + if(size >= 0){ + if(bp->rp - bp->base >= size) + return bp; + + n = bp->wp - bp->rp; + bpadoverhead += n; + nbp = allocb(size+n); + nbp->rp += size; + nbp->wp = nbp->rp; + memmove(nbp->wp, bp->rp, n); + nbp->wp += n; + freeb(bp); + } else { + size = -size; + + if(bp->lim - bp->wp >= size) + return bp; + + n = bp->wp - bp->rp; + bpadoverhead += n; + nbp = allocb(size+n); + memmove(nbp->wp, bp->rp, n); + nbp->wp += n; + freeb(bp); + } return nbp; }