## diffname port/queue.c 1990/1227
## diff -e /dev/null /n/bootesdump/1990/1227/sys/src/9/port/queue.c
0a
#include "u.h"
#include "lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "errno.h"
void
initq(IOQ *q)
{
q->in = q->out = q->buf;
q->puts = puts;
q->putc = putc;
}
int
putc(IOQ *q, int c)
{
uchar *nextin;
if(q->in >= &q->buf[sizeof(q->buf)-1])
nextin = q->buf;
else
nextin = q->in+1;
if(nextin == q->out)
return -1;
*q->in = c;
q->in = nextin;
return 0;
}
int
getc(IOQ *q)
{
int c;
if(q->in == q->out)
return -1;
c = *q->out++;
if(q->out == q->buf+sizeof(q->buf))
q->out = q->buf;
return c;
}
void
puts(IOQ *q, char *s, int n)
{
int m;
while(n){
if(q->out > q->in)
m = q->out - q->in - 1;
else
m = &q->buf[NQ] - q->in;
if(m > n)
m = n;
memcpy(q->in, s, m);
n -= m;
q->in += m;
if(q->in >= &q->buf[NQ])
q->in = q->buf;
}
}
int
cangetc(void *arg)
{
IOQ *q = (IOQ *)arg;
int n = q->in - q->out;
if (n < 0)
n += sizeof(q->buf);
return n;
}
int
canputc(void *arg)
{
IOQ *q = (IOQ *)arg;
return sizeof(q->buf)-cangetc(q)-1;
}
.
## diffname port/queue.c 1990/1231
## diff -e /n/bootesdump/1990/1227/sys/src/9/port/queue.c /n/bootesdump/1990/1231/sys/src/9/port/queue.c
79c
uchar *next;
next = q->in+1;
if(next >= &q->buf[sizeof(q->buf)])
next = q->buf;
return next != q->out;
.
69,72c
return q->in != q->out;
.
41a
else
q->out++;
.
39,40c
c = *q->out;
if(q->out == q->buf+sizeof(q->buf)-1)
.
## diffname port/queue.c 1991/0318
## diff -e /n/bootesdump/1990/1231/sys/src/9/port/queue.c /n/bootesdump/1991/0318/sys/src/9/port/queue.c
59c
memmove(q->in, s, m);
.
## diffname port/queue.c 1991/0511
## diff -e /n/bootesdump/1991/0318/sys/src/9/port/queue.c /n/bootesdump/1991/0511/sys/src/9/port/queue.c
78,83c
return sizeof(q->buf)-cangetc(q)-1;
.
71c
int n = q->in - q->out;
if (n < 0)
n += sizeof(q->buf);
return n;
.
67a
gets(IOQ *q, void *buf, int n)
{
int m, k = 0; uchar *nextout;
uchar *s = buf;
while(n){
m = q->in - q->out;
if(m < 0)
m = &q->buf[NQ] - q->out;
if(m == 0)
return k;
if(m > n)
m = n;
memmove(s, q->out, m);
s += m;
k += m;
n -= m;
nextout = q->out + m;
if(nextout >= &q->buf[NQ])
q->out = q->buf;
else
q->out = nextout;
}
return k;
}
int
.
63a
else
q->in = nextin;
.
61,62c
s += m;
nextin = q->in + m;
if(nextin >= &q->buf[NQ])
.
56a
if(m == 0)
break;
.
53,55c
m = q->out - q->in - 1;
if(m < 0)
.
50c
int m; uchar *nextin;
uchar *s = buf;
.
48c
puts(IOQ *q, void *buf, int n)
.
## diffname port/queue.c 1991/0604
## diff -e /n/bootesdump/1991/0511/sys/src/9/port/queue.c /n/bootesdump/1991/0604/sys/src/9/port/queue.c
14a
unlock(q);
.
11a
lock(q);
.
## diffname port/queue.c 1991/0606
## diff -e /n/bootesdump/1991/0604/sys/src/9/port/queue.c /n/bootesdump/1991/0606/sys/src/9/port/queue.c
16d
12a
unlock(q);
.
## diffname port/queue.c 1991/0703
## diff -e /n/bootesdump/1991/0606/sys/src/9/port/queue.c /n/bootesdump/1991/0703/sys/src/9/port/queue.c
7d
## diffname port/queue.c 1991/0705
## diff -e /n/bootesdump/1991/0703/sys/src/9/port/queue.c /n/bootesdump/1991/0705/sys/src/9/port/queue.c
6a
#include "errno.h"
.
## diffname port/queue.c 1991/0706
## diff -e /n/bootesdump/1991/0705/sys/src/9/port/queue.c /n/bootesdump/1991/0706/sys/src/9/port/queue.c
7d
## diffname port/queue.c 1991/0808
## diff -e /n/bootesdump/1991/0706/sys/src/9/port/queue.c /n/bootesdump/1991/0808/sys/src/9/port/queue.c
113,114c
IOQ *q;
int n;
q = (IOQ *)arg;
n = q->out - q->in - 1;
if (n < 0)
n += sizeof(q->buf);
return n;
.
103,104c
IOQ *q;
int n;
q = (IOQ *)arg;
n = q->in - q->out;
.
97c
return p - (uchar*)buf;
.
95c
q->out++;
.
79,92c
for(; n && q->out != q->in; n--){
*p++ = *q->out;
if(q->out == &q->buf[NQ-1])
.
76,77c
uchar *p = buf;
.
69c
next = q->in + 1;
if(next == q->out)
break;
*q->in = *p++;
q->in = next;
.
54,67c
for(; n; n--){
if(q->in == &q->buf[NQ-1])
next = q->buf;
.
51,52c
uchar *next;
uchar *p = buf;
.
41c
if(q->out == &q->buf[NQ-1])
.
29c
q->in = next;
.
25,26c
next = q->in+1;
if(next == q->out)
.
21,23c
uchar *next;
if(q->in == &q->buf[NQ-1])
next = q->buf;
.
## diffname port/queue.c 1991/0810
## diff -e /n/bootesdump/1991/0808/sys/src/9/port/queue.c /n/bootesdump/1991/0810/sys/src/9/port/queue.c
98,105c
IOQ *q = (IOQ *)arg;
return sizeof(q->buf)-cangetc(q)-1;
.
85,89c
IOQ *q = (IOQ *)arg;
int n = q->in - q->out;
.
79c
return k;
.
77c
q->out = nextout;
.
72,74c
while(n){
m = q->in - q->out;
if(m < 0)
m = &q->buf[NQ] - q->out;
if(m == 0)
return k;
if(m > n)
m = n;
if(buf)
memmove(s, q->out, m);
s += m;
k += m;
n -= m;
nextout = q->out + m;
if(nextout >= &q->buf[NQ])
.
70c
int m, k = 0; uchar *nextout;
uchar *s = buf;
.
62,63c
if(m > n)
m = n;
memmove(q->in, s, m);
n -= m;
s += m;
nextin = q->in + m;
if(nextin >= &q->buf[NQ])
q->in = q->buf;
else
q->in = nextin;
.
55,60c
while(n){
m = q->out - q->in - 1;
if(m < 0)
m = &q->buf[NQ] - q->in;
if(m == 0)
.
52,53c
int m; uchar *nextin;
uchar *s = buf;
.
42c
if(q->out == q->buf+sizeof(q->buf)-1)
.
30c
q->in = nextin;
.
26,27c
nextin = q->in+1;
if(nextin == q->out)
.
21,24c
uchar *nextin;
if(q->in >= &q->buf[sizeof(q->buf)-1])
nextin = q->buf;
.
15a
q->gets = gets;
q->getc = getc;
.
## diffname port/queue.c 1992/0321
## diff -e /n/bootesdump/1991/0810/sys/src/9/port/queue.c /n/bootesdump/1992/0321/sys/src/9/port/queue.c
2c
#include "../port/lib.h"
.
## diffname port/queue.c 1993/1201 # deleted
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/queue.c /n/fornaxdump/1993/1201/sys/src/brazil/port/queue.c
1,118d
|