|
|
1.1 ! root 1: #define QUEUE_C ! 2: #include <queue.h> ! 3: #include <setup.h> ! 4: ! 5: /* ! 6: * These macros are for speed, not size. ! 7: */ ! 8: #define pswmax() asm(" PUSHW %psw ");\ ! 9: asm(" ORW2 &0x1e000,%psw ");\ ! 10: asm(" TSTW %r0 ") ! 11: ! 12: #define pswback() asm(" POPW %psw ");\ ! 13: asm(" TSTW %r0 ") ! 14: qinit(){ ! 15: register struct cbuf *p, *q; ! 16: ! 17: q=0; ! 18: for(p=cbufs; p<&cbufs[NCHARS]; p++){ ! 19: p->next=q; ! 20: q=p; ! 21: } ! 22: freelist=q; ! 23: } ! 24: qputc(q, w) ! 25: register struct clist *q; ! 26: register w; ! 27: { ! 28: register cc; ! 29: register struct cbuf *p; ! 30: pswmax(); ! 31: p=freelist; ! 32: if(p==0){ ! 33: pswback(); ! 34: if(!VALDWNLDFLAG ) ! 35: ringbell(); /* send a warning to the user */ ! 36: return(0); ! 37: } ! 38: freelist=p->next; ! 39: p->next=0; ! 40: p->word=w; ! 41: if(q->c_cc==0) ! 42: q->c_head=q->c_tail=p; ! 43: else{ ! 44: q->c_tail->next=p; ! 45: q->c_tail=p; ! 46: } ! 47: cc= ++q->c_cc; ! 48: pswback(); ! 49: return(cc); ! 50: } ! 51: qputstr(q, str) ! 52: register struct clist *q; ! 53: register char *str; ! 54: { ! 55: register retval; ! 56: do; while(*str && ((retval=qputc(q, *str++))>=0)); ! 57: return retval; ! 58: } ! 59: qgetc(q) ! 60: register struct clist *q; ! 61: { ! 62: register struct cbuf *p; ! 63: register x; ! 64: pswmax(); ! 65: if((p=q->c_head)==0){ ! 66: pswback(); ! 67: return(-1); ! 68: } ! 69: if(--q->c_cc==0) ! 70: q->c_head=q->c_tail=0; ! 71: else ! 72: q->c_head=p->next; ! 73: p->next=freelist; ! 74: x=p->word; ! 75: freelist=p; ! 76: pswback(); ! 77: return(x); ! 78: } ! 79: qclear(q) ! 80: register struct clist *q; ! 81: { ! 82: pswmax(); ! 83: if(q->c_cc == 0){ ! 84: pswback(); ! 85: return; ! 86: } ! 87: q->c_cc=0; ! 88: q->c_tail->next=freelist; ! 89: freelist=q->c_head; ! 90: q->c_head=0; ! 91: q->c_tail=0; ! 92: pswback(); ! 93: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.