Annotation of lucent/sys/src/boot/pc/queue.c, revision 1.1.1.1

1.1       root        1: #include       "u.h"
                      2: #include       "lib.h"
                      3: #include       "mem.h"
                      4: #include       "dat.h"
                      5: #include       "fns.h"
                      6: #include       "io.h"
                      7: 
                      8: int
                      9: qgetc(IOQ *q)
                     10: {
                     11:        int c;
                     12: 
                     13:        if(q->in == q->out)
                     14:                return -1;
                     15:        c = *q->out;
                     16:        if(q->out == q->buf+sizeof(q->buf)-1)
                     17:                q->out = q->buf;
                     18:        else
                     19:                q->out++;
                     20:        return c;
                     21: }
                     22: 
                     23: static int
                     24: qputc(IOQ *q, int c)
                     25: {
                     26:        uchar *nextin;
                     27:        if(q->in >= &q->buf[sizeof(q->buf)-1])
                     28:                nextin = q->buf;
                     29:        else
                     30:                nextin = q->in+1;
                     31:        if(nextin == q->out)
                     32:                return -1;
                     33:        *q->in = c;
                     34:        q->in = nextin;
                     35:        return 0;
                     36: }
                     37: 
                     38: void
                     39: qinit(IOQ *q)
                     40: {
                     41:        q->in = q->out = q->buf;
                     42:        q->getc = qgetc;
                     43:        q->putc = qputc;
                     44: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.