typo
[unix-history] / usr / src / sys / kern / tty_subr.c
index db4a2fb..44d708a 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)tty_subr.c  6.10 (Berkeley) %G%
+ *     @(#)tty_subr.c  7.3 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -33,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;
@@ -57,7 +57,7 @@ getc(p)
                }
        }
        splx(s);
                }
        }
        splx(s);
-       return(c);
+       return (c);
 }
 
 /*
 }
 
 /*
@@ -74,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);
@@ -120,7 +120,7 @@ q_to_b(q, cp, cc)
                }
        }
        splx(s);
                }
        }
        splx(s);
-       return(cp-acp);
+       return (cp-acp);
 }
 
 /*
 }
 
 /*
@@ -160,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.
  */
@@ -177,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)) {
@@ -234,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;
@@ -244,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;
@@ -256,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.
@@ -276,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) {
@@ -290,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;
@@ -299,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;
@@ -403,8 +398,7 @@ catq(from, to)
 
 #ifdef unneeded
 /*
 
 #ifdef unneeded
 /*
- * Integer (short) get/put
- * using clists
+ * Integer (short) get/put using clists.
  */
 typedef        u_short word_t;
 
  */
 typedef        u_short word_t;
 
@@ -418,15 +412,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 BYTE_ORDER == LITTLE_ENDIAN
+               return (c | (getc(p)<<8));
+#else
+               return (getc(p) | (c<<8));
+#endif
        }
        s = spltty();
        }
        s = spltty();
-       c = *((word_t *)p->c_cf);
-       p->c_cf += sizeof(word_t);
-       p->c_cc -= sizeof(word_t);
+#if BYTE_ORDER == LITTLE_ENDIAN
+       c = (((u_char *)p->c_cf)[0] << 8) | ((u_char *)p->c_cf)[1];
+#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;
@@ -466,8 +468,13 @@ putw(c, p)
                return(-1);
        }
        if (p->c_cc & 01) {
                return(-1);
        }
        if (p->c_cc & 01) {
+#if BYTE_ORDER == LITTLE_ENDIAN
                (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) {
@@ -490,9 +497,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);