From 80b479c8bf8c53c0207d142b1b5014ce615bf4cd Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 11 Oct 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-10-11 --- gnot/devpipe.c | 13 ++++------- gnot/stream.c | 23 +++++++++++-------- port/devbit.c | 60 ++++++++++++++++++++++++++++++++++++++++++++------ port/devdk.c | 2 +- port/devpipe.c | 13 ++++------- port/stream.c | 23 +++++++++++-------- 6 files changed, 90 insertions(+), 44 deletions(-) diff --git a/gnot/devpipe.c b/gnot/devpipe.c index 2183aae2fb553544d5f09b499932704a585539df..02edfa3a0f7e2e1deba8def2e5b525febfc9385e 100644 --- a/gnot/devpipe.c +++ b/gnot/devpipe.c @@ -201,8 +201,9 @@ pipewstat(Chan *c, char *db) void pipeexit(Pipe *p) { - decref(p); - if(p->ref <= 0){ + if(decref(p) < 0) + panic("pipeexit"); + if(p->ref == 0){ lock(&pipealloc); p->next = pipealloc.free; pipealloc.free = p; @@ -220,18 +221,12 @@ pipeclose(Chan *c) p = &pipealloc.pipe[STREAMID(c->qid)/2]; /* - * take care of assosiated streams + * take care of associated streams */ if(local = c->stream){ remote = (Stream *)c->stream->devq->ptr; - if(waserror()){ - streamexit(remote, 0); - pipeexit(p); - nexterror(); - } streamclose(c); /* close this stream */ streamexit(remote, 0); /* release stream for other half of pipe */ - poperror(); } pipeexit(p); } diff --git a/gnot/stream.c b/gnot/stream.c index a8eaacb96529349a3386d9420723f409e15d0944..6ea84c554e7604539ac3ac50830a4d7aa4125dbf 100644 --- a/gnot/stream.c +++ b/gnot/stream.c @@ -784,15 +784,20 @@ streamclose1(Stream *s) */ lock(s); if(s->opens == 1){ - /* - * descend the stream closing the queues - */ - for(q = s->procq; q; q = q->next){ - if(q->info->close) - (*q->info->close)(q->other); - /* this may be 2 streams joined device end to device end */ - if(q == s->devq->other) - break; + if(!waserror()){ + /* + * descend the stream closing the queues + */ + for(q = s->procq; q; q = q->next){ + if(q->info->close) + (*q->info->close)(q->other); + /* + * this may be 2 streams joined device end to device end + */ + if(q == s->devq->other) + break; + } + poperror(); } /* diff --git a/port/devbit.c b/port/devbit.c index aff714bcb7302c3155288f3f8cefa8284c02a992..65ec464248fe3cab1ab0836f5b430b0ef645807a 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -470,7 +470,7 @@ long bitwrite(Chan *c, void *va, long n) { uchar *p, *q; - long m, v, miny, maxy, t, x, y; + long m, v, miny, maxy, minx, maxx, t, x, y, tw, th; ulong l, nw, ws; int off, isoff, i; Point pt, pt1, pt2; @@ -880,20 +880,66 @@ bitwrite(Chan *c, void *va, long n) src = &bit.map[v]; if(v<0 || v>=conf.nbitmap || src->ldepth<0) error(0, Ebadbitmap); - if(src->r.min.x!=0 || src->r.min.y!=0 || src->r.max.x!=16 || src->r.max.y!=16) - error(0, Ebadblt); v = GSHORT(p+21); - { - int i; + x = src->r.min.x; + y = src->r.min.y; + tw = src->r.max.x - x; + th = src->r.max.y - y; + if(x==0 && y==0 && 16%tw == 0 && 16%th == 0){ GTexture t; - for(i=0; i<16; i++) - t.bits[i] = src->base[i]>>16; + if(tw==16 && th==16) + for(y=0; y<16; y++) + t.bits[y] = src->base[y]>>16; + else + for(y=0; y<16; y++){ + l = src->base[y%(16/th)] >> (32-tw); + for(i=16/tw, ws=l; i > 1; i--) + ws = (ws<r.min.x + * Similarly for y, maxy + */ + if(x > rect.min.x) + x -= ((x-rect.min.x+tw-1)/tw)*tw; + else if(x+tw <= rect.min.x) + x += ((rect.min.x-x)/tw)*tw; + if(y > rect.min.y) + y -= ((y-rect.min.y+th-1)/th)*th; + else if(y+tw <= rect.min.y) + y += ((rect.min.y-y)/th)*th; + maxx = x+tw; + if(maxx < rect.max.x) + maxx += ((rect.max.x-maxx+tw-1)/tw)*tw; + maxy = y+th; + if(maxy < rect.max.y) + maxy += ((rect.max.y-maxy+th-1)/th)*th; + minx = x; + if(off && !isoff){ + cursoroff(1); + isoff = 1; + } + for( ; yr, v); } m -= 23; p += 23; diff --git a/port/devdk.c b/port/devdk.c index a1d628c6f81830bf1cb3298890d062b07a395a2f..61087c15582d3047a71c4a8af87c92d28463ea80 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -421,7 +421,7 @@ dkoput(Queue *q, Block *bp) bp->rptr[1] = line>>8; if(QFULL(dp->wq->next)){ - print("dk wq full\n"); +/* print("dk wq full\n");/**/ freeb(bp); } else PUTNEXT(dp->wq, bp); diff --git a/port/devpipe.c b/port/devpipe.c index 2183aae2fb553544d5f09b499932704a585539df..02edfa3a0f7e2e1deba8def2e5b525febfc9385e 100644 --- a/port/devpipe.c +++ b/port/devpipe.c @@ -201,8 +201,9 @@ pipewstat(Chan *c, char *db) void pipeexit(Pipe *p) { - decref(p); - if(p->ref <= 0){ + if(decref(p) < 0) + panic("pipeexit"); + if(p->ref == 0){ lock(&pipealloc); p->next = pipealloc.free; pipealloc.free = p; @@ -220,18 +221,12 @@ pipeclose(Chan *c) p = &pipealloc.pipe[STREAMID(c->qid)/2]; /* - * take care of assosiated streams + * take care of associated streams */ if(local = c->stream){ remote = (Stream *)c->stream->devq->ptr; - if(waserror()){ - streamexit(remote, 0); - pipeexit(p); - nexterror(); - } streamclose(c); /* close this stream */ streamexit(remote, 0); /* release stream for other half of pipe */ - poperror(); } pipeexit(p); } diff --git a/port/stream.c b/port/stream.c index a8eaacb96529349a3386d9420723f409e15d0944..6ea84c554e7604539ac3ac50830a4d7aa4125dbf 100644 --- a/port/stream.c +++ b/port/stream.c @@ -784,15 +784,20 @@ streamclose1(Stream *s) */ lock(s); if(s->opens == 1){ - /* - * descend the stream closing the queues - */ - for(q = s->procq; q; q = q->next){ - if(q->info->close) - (*q->info->close)(q->other); - /* this may be 2 streams joined device end to device end */ - if(q == s->devq->other) - break; + if(!waserror()){ + /* + * descend the stream closing the queues + */ + for(q = s->procq; q; q = q->next){ + if(q->info->close) + (*q->info->close)(q->other); + /* + * this may be 2 streams joined device end to device end + */ + if(q == s->devq->other) + break; + } + poperror(); } /*