projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make forward progress for large packets (from Keith Muller)
[unix-history]
/
usr
/
src
/
sys
/
kern
/
tty_subr.c
diff --git
a/usr/src/sys/kern/tty_subr.c
b/usr/src/sys/kern/tty_subr.c
index
fc3913e
..
5189da9
100644
(file)
--- a/
usr/src/sys/kern/tty_subr.c
+++ b/
usr/src/sys/kern/tty_subr.c
@@
-1,8
+1,13
@@
-/* tty_subr.c 6.8 84/12/21 */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tty_subr.c 6.11 (Berkeley) %G%
+ */
#include "param.h"
#include "systm.h"
#include "param.h"
#include "systm.h"
-#include "conf.h"
#include "buf.h"
#include "ioctl.h"
#include "tty.h"
#include "buf.h"
#include "ioctl.h"
#include "tty.h"
@@
-28,7
+33,7
@@
getc(p)
c = *p->c_cf++ & 0377;
if (--p->c_cc<=0) {
bp = (struct cblock *)(p->c_cf-1);
c = *p->c_cf++ & 0377;
if (--p->c_cc<=0) {
bp = (struct cblock *)(p->c_cf-1);
- bp = (struct cblock *)
((int)bp & ~CROUND);
+ bp = (struct cblock *)((int)bp & ~CROUND);
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
@@
-52,7
+57,7
@@
getc(p)
}
}
splx(s);
}
}
splx(s);
- return(c);
+ return
(c);
}
/*
}
/*
@@
-69,18
+74,18
@@
q_to_b(q, cp, cc)
char *acp;
if (cc <= 0)
char *acp;
if (cc <= 0)
- return(0);
+ return
(0);
s = spltty();
if (q->c_cc <= 0) {
q->c_cc = 0;
q->c_cf = q->c_cl = NULL;
splx(s);
s = spltty();
if (q->c_cc <= 0) {
q->c_cc = 0;
q->c_cf = q->c_cl = NULL;
splx(s);
- return(0);
+ return
(0);
}
acp = cp;
while (cc) {
}
acp = cp;
while (cc) {
- nc = sizeof(struct cblock) - ((int)q->c_cf & CROUND);
+ 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);
nc = MIN(nc, cc);
nc = MIN(nc, q->c_cc);
(void) bcopy(q->c_cf, cp, (unsigned)nc);
@@
-115,7
+120,7
@@
q_to_b(q, cp, cc)
}
}
splx(s);
}
}
splx(s);
- return(cp-acp);
+ return
(cp-acp);
}
/*
}
/*
@@
-155,11
+160,9
@@
ndqb(q, flag)
}
out:
splx(s);
}
out:
splx(s);
- return(cc);
+ return
(cc);
}
}
-
-
/*
* Flush cc bytes from q.
*/
/*
* Flush cc bytes from q.
*/
@@
-172,9
+175,8
@@
ndflush(q, cc)
int rem, s;
s = spltty();
int rem, s;
s = spltty();
- if (q->c_cc <= 0)
{
+ if (q->c_cc <= 0)
goto out;
goto out;
- }
while (cc>0 && q->c_cc) {
bp = (struct cblock *)((int)q->c_cf & ~CROUND);
if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) {
while (cc>0 && q->c_cc) {
bp = (struct cblock *)((int)q->c_cf & ~CROUND);
if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) {
@@
-229,7
+231,7
@@
putc(c, p)
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
splx(s);
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
splx(s);
- return(-1);
+ return
(-1);
}
cfreelist = bp->c_next;
cfreecount -= CBSIZE;
}
cfreelist = bp->c_next;
cfreecount -= CBSIZE;
@@
-239,7
+241,7
@@
putc(c, p)
bp = (struct cblock *)cp - 1;
if ((bp->c_next = cfreelist) == NULL) {
splx(s);
bp = (struct cblock *)cp - 1;
if ((bp->c_next = cfreelist) == NULL) {
splx(s);
- return(-1);
+ return
(-1);
}
bp = bp->c_next;
cfreelist = bp->c_next;
}
bp = bp->c_next;
cfreelist = bp->c_next;
@@
-251,11
+253,9
@@
putc(c, p)
p->c_cc++;
p->c_cl = cp;
splx(s);
p->c_cc++;
p->c_cl = cp;
splx(s);
- return(0);
+ return
(0);
}
}
-
-
/*
* copy buffer to clist.
* return number of bytes not transfered.
/*
* copy buffer to clist.
* return number of bytes not transfered.
@@
-271,7
+271,7
@@
b_to_q(cp, cc, q)
int acc;
if (cc <= 0)
int acc;
if (cc <= 0)
- return(0);
+ return
(0);
acc = cc;
s = spltty();
if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
acc = cc;
s = spltty();
if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
@@
-285,7
+285,7
@@
b_to_q(cp, cc, q)
while (cc) {
if (((int)cq & CROUND) == 0) {
while (cc) {
if (((int)cq & CROUND) == 0) {
- bp = (struct cblock *)
cq - 1;
+ bp = (struct cblock *)cq - 1;
if ((bp->c_next = cfreelist) == NULL)
goto out;
bp = bp->c_next;
if ((bp->c_next = cfreelist) == NULL)
goto out;
bp = bp->c_next;
@@
-294,7
+294,7
@@
b_to_q(cp, cc, q)
bp->c_next = NULL;
cq = bp->c_info;
}
bp->c_next = NULL;
cq = bp->c_info;
}
- nc = MIN(cc, sizeof(struct cblock) - ((int)cq & CROUND));
+ nc = MIN(cc, sizeof
(struct cblock) - ((int)cq & CROUND));
(void) bcopy(cp, cq, (unsigned)nc);
cp += nc;
cq += nc;
(void) bcopy(cp, cq, (unsigned)nc);
cp += nc;
cq += nc;
@@
-398,8
+398,8
@@
catq(from, to)
#ifdef unneeded
/*
#ifdef unneeded
/*
- * Integer (short) get/put
- *
using clists
+ * Integer (short) get/put
using clists.
+ *
Note dependency on byte order.
*/
typedef u_short word_t;
*/
typedef u_short word_t;
@@
-413,15
+413,23
@@
getw(p)
return(-1);
if (p->c_cc & 01) {
c = getc(p);
return(-1);
if (p->c_cc & 01) {
c = getc(p);
- return(c | (getc(p)<<8));
+#if defined(vax)
+ return (c | (getc(p)<<8));
+#else
+ return (getc(p) | (c<<8));
+#endif
}
s = spltty();
}
s = spltty();
+#if defined(vax)
c = *((word_t *)p->c_cf);
c = *((word_t *)p->c_cf);
- p->c_cf += sizeof(word_t);
- p->c_cc -= sizeof(word_t);
+#else
+ c = (((u_char *)p->c_cf)[1] << 8) | ((u_char *)p->c_cf)[0];
+#endif
+ p->c_cf += sizeof (word_t);
+ p->c_cc -= sizeof (word_t);
if (p->c_cc <= 0) {
bp = (struct cblock *)(p->c_cf-1);
if (p->c_cc <= 0) {
bp = (struct cblock *)(p->c_cf-1);
- bp = (struct cblock *)
((int)bp & ~CROUND);
+ bp = (struct cblock *)((int)bp & ~CROUND);
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
p->c_cf = NULL;
p->c_cl = NULL;
bp->c_next = cfreelist;
@@
-461,8
+469,13
@@
putw(c, p)
return(-1);
}
if (p->c_cc & 01) {
return(-1);
}
if (p->c_cc & 01) {
+#if defined(vax)
(void) putc(c, p);
(void) putc(c>>8, p);
(void) putc(c, p);
(void) putc(c>>8, p);
+#else
+ (void) putc(c>>8, p);
+ (void) putc(c, p);
+#endif
} else {
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
} else {
if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
if ((bp = cfreelist) == NULL) {
@@
-485,9
+498,14
@@
putw(c, p)
bp->c_next = NULL;
cp = bp->c_info;
}
bp->c_next = NULL;
cp = bp->c_info;
}
+#if defined(vax)
*(word_t *)cp = c;
*(word_t *)cp = c;
- p->c_cl = cp + sizeof(word_t);
- p->c_cc += sizeof(word_t);
+#else
+ ((u_char *)cp)[0] = c>>8;
+ ((u_char *)cp)[1] = c;
+#endif
+ p->c_cl = cp + sizeof (word_t);
+ p->c_cc += sizeof (word_t);
}
splx(s);
return (0);
}
splx(s);
return (0);