-#include "sys/clist.h"
-
-/*
- * This is just a copy of the virgin q_to_b routine with minor
- * optimizations for HIL use. It is used for two reasons:
- * 1. If we have PAGE mode defined, the normal q_to_b processes
- * chars one at a time and breaks on newlines.
- * 2. We don't have to raise the priority to spltty() for most
- * of the clist manipulations.
- */
-hilq_to_b(q, cp, cc)
- register struct clist *q;
- register char *cp;
-{
- register struct cblock *bp;
- register int nc;
- char *acp;
- int s;
- extern char cwaiting;
-
- if (cc <= 0)
- return (0);
- s = splhil();
- if (q->c_cc <= 0) {
- q->c_cc = 0;
- q->c_cf = q->c_cl = NULL;
- splx(s);
- return (0);
- }
- acp = cp;
-
- while (cc) {
- nc = sizeof (struct cblock) - ((int)q->c_cf & CROUND);
- nc = MIN(nc, cc);
- nc = MIN(nc, q->c_cc);
- (void) bcopy(q->c_cf, cp, (unsigned)nc);
- q->c_cf += nc;
- q->c_cc -= nc;
- cc -= nc;
- cp += nc;
- if (q->c_cc <= 0) {
- bp = (struct cblock *)(q->c_cf - 1);
- bp = (struct cblock *)((int)bp & ~CROUND);
- q->c_cf = q->c_cl = NULL;
- spltty();
- bp->c_next = cfreelist;
- cfreelist = bp;
- cfreecount += CBSIZE;
- if (cwaiting) {
- wakeup(&cwaiting);
- cwaiting = 0;
- }
- break;
- }
- if (((int)q->c_cf & CROUND) == 0) {
- bp = (struct cblock *)(q->c_cf);
- bp--;
- q->c_cf = bp->c_next->c_info;
- spltty();
- bp->c_next = cfreelist;
- cfreelist = bp;
- cfreecount += CBSIZE;
- if (cwaiting) {
- wakeup(&cwaiting);
- cwaiting = 0;
- }
- splhil();
- }
- }
- splx(s);
- return (cp-acp);
-}
-