while (len--) { int new_head = (inbuf_head + 1) & INBUF_MASK; if (new_head != inbuf_reap) { inbuf[inbuf_head] = *buf++; inbuf_head = new_head; } else { term_out(); if( inbuf_head == inbuf_reap ) len++; else break; } }
while (len--) c_write1(*buf++);
static void c_write (char *buf, int len) {    while (len--) {	int new_head = (inbuf_head + 1) & INBUF_MASK;	if (new_head != inbuf_reap) {	    inbuf[inbuf_head] = *buf++;	    inbuf_head = new_head;	} else {            term_out();            if( inbuf_head == inbuf_reap ) len++; else break;	}    }}