cleanups from Sam: format, spl's, ptrace defs
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 21 Feb 1986 07:58:57 +0000 (23:58 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 21 Feb 1986 07:58:57 +0000 (23:58 -0800)
SCCS-vsn: sys/kern/kern_acct.c 6.9
SCCS-vsn: sys/kern/kern_fork.c 6.8
SCCS-vsn: sys/kern/sys_generic.c 6.14
SCCS-vsn: sys/kern/sys_process.c 6.6
SCCS-vsn: sys/kern/tty_subr.c 6.11

usr/src/sys/kern/kern_acct.c
usr/src/sys/kern/kern_fork.c
usr/src/sys/kern/sys_generic.c
usr/src/sys/kern/sys_process.c
usr/src/sys/kern/tty_subr.c

index afe2b4e..1b8408e 100644 (file)
@@ -3,7 +3,7 @@
  * 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.
  *
- *     @(#)kern_acct.c 6.8 (Berkeley) %G%
+ *     @(#)kern_acct.c 6.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -49,9 +49,9 @@ sysacct()
                ndp->ni_segflg = UIO_USERSPACE;
                ndp->ni_dirp = uap->fname;
                ip = namei(ndp);
                ndp->ni_segflg = UIO_USERSPACE;
                ndp->ni_dirp = uap->fname;
                ip = namei(ndp);
-               if(ip == NULL)
+               if (ip == NULL)
                        return;
                        return;
-               if((ip->i_mode & IFMT) != IFREG) {
+               if ((ip->i_mode&IFMT) != IFREG) {
                        u.u_error = EACCES;
                        iput(ip);
                        return;
                        u.u_error = EACCES;
                        iput(ip);
                        return;
@@ -122,7 +122,7 @@ acct()
        else
                ap->ac_mem = 0;
        ap->ac_mem >>= CLSIZELOG2;
        else
                ap->ac_mem = 0;
        ap->ac_mem >>= CLSIZELOG2;
-       ap->ac_io = compress(ru->ru_inblock + ru->ru_oublock, 0);
+       ap->ac_io = compress(ru->ru_inblock + ru->ru_oublock, (long)0);
        if (u.u_ttyp)
                ap->ac_tty = u.u_ttyd;
        else
        if (u.u_ttyp)
                ap->ac_tty = u.u_ttyd;
        else
index 8878cad..efe13ba 100644 (file)
@@ -3,7 +3,7 @@
  * 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.
  *
- *     @(#)kern_fork.c 6.7 (Berkeley) %G%
+ *     @(#)kern_fork.c 6.8 (Berkeley) %G%
  */
 
 #include "../machine/reg.h"
  */
 
 #include "../machine/reg.h"
@@ -237,7 +237,7 @@ again:
        /*
         * Make child runnable and add to run queue.
         */
        /*
         * Make child runnable and add to run queue.
         */
-       (void) spl6();
+       (void) splclock();
        rpp->p_stat = SRUN;
        setrq(rpp);
        (void) spl0();
        rpp->p_stat = SRUN;
        setrq(rpp);
        (void) spl0();
index 4ad5a5a..7069aa8 100644 (file)
@@ -3,7 +3,7 @@
  * 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.
  *
- *     @(#)sys_generic.c       6.13 (Berkeley) %G%
+ *     @(#)sys_generic.c       6.14 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -266,8 +266,8 @@ select()
        int s, ncoll, ni;
        label_t lqsave;
 
        int s, ncoll, ni;
        label_t lqsave;
 
-       bzero(ibits, sizeof(ibits));
-       bzero(obits, sizeof(obits));
+       bzero((caddr_t)ibits, sizeof(ibits));
+       bzero((caddr_t)obits, sizeof(obits));
        if (uap->nd > NOFILE)
                uap->nd = NOFILE;       /* forgiving, if slightly wrong */
        ni = howmany(uap->nd, NFDBITS);
        if (uap->nd > NOFILE)
                uap->nd = NOFILE;       /* forgiving, if slightly wrong */
        ni = howmany(uap->nd, NFDBITS);
@@ -275,7 +275,7 @@ select()
 #define        getbits(name, x) \
        if (uap->name) { \
                u.u_error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
 #define        getbits(name, x) \
        if (uap->name) { \
                u.u_error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \
-                   ni * sizeof(fd_mask)); \
+                   (unsigned)(ni * sizeof(fd_mask))); \
                if (u.u_error) \
                        goto done; \
        }
                if (u.u_error) \
                        goto done; \
        }
@@ -335,7 +335,7 @@ done:
 #define        putbits(name, x) \
        if (uap->name) { \
                int error = copyout((caddr_t)&obits[x], (caddr_t)uap->name, \
 #define        putbits(name, x) \
        if (uap->name) { \
                int error = copyout((caddr_t)&obits[x], (caddr_t)uap->name, \
-                   ni * sizeof(fd_mask)); \
+                   (unsigned)(ni * sizeof(fd_mask))); \
                if (error) \
                        u.u_error = error; \
        }
                if (error) \
                        u.u_error = error; \
        }
index f5f1e74..0913d72 100644 (file)
@@ -3,7 +3,7 @@
  * 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.
  *
- *     @(#)sys_process.c       6.5 (Berkeley) %G%
+ *     @(#)sys_process.c       6.6 (Berkeley) %G%
  */
 
 #include "../machine/reg.h"
  */
 
 #include "../machine/reg.h"
@@ -21,6 +21,7 @@
 #include "vm.h"
 #include "buf.h"
 #include "acct.h"
 #include "vm.h"
 #include "buf.h"
 #include "acct.h"
+#include "ptrace.h"
 
 /*
  * Priority for tracing
 
 /*
  * Priority for tracing
@@ -85,7 +86,7 @@ ptrace()
        wakeup((caddr_t)&ipc);
 }
 
        wakeup((caddr_t)&ipc);
 }
 
-#ifdef vax
+#if defined(vax)
 #define        NIPCREG 16
 int ipcreg[NIPCREG] =
        {R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,AP,FP,SP,PC};
 #define        NIPCREG 16
 int ipcreg[NIPCREG] =
        {R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,AP,FP,SP,PC};
@@ -112,31 +113,26 @@ procxmt()
        ipc.ip_req = 0;
        switch (i) {
 
        ipc.ip_req = 0;
        switch (i) {
 
-       /* read user I */
-       case 1:
+       case PT_READ_I:                 /* read the child's text space */
                if (!useracc((caddr_t)ipc.ip_addr, 4, B_READ))
                        goto error;
                ipc.ip_data = fuiword((caddr_t)ipc.ip_addr);
                break;
 
                if (!useracc((caddr_t)ipc.ip_addr, 4, B_READ))
                        goto error;
                ipc.ip_data = fuiword((caddr_t)ipc.ip_addr);
                break;
 
-       /* read user D */
-       case 2:
+       case PT_READ_D:                 /* read the child's data space */
                if (!useracc((caddr_t)ipc.ip_addr, 4, B_READ))
                        goto error;
                ipc.ip_data = fuword((caddr_t)ipc.ip_addr);
                break;
 
                if (!useracc((caddr_t)ipc.ip_addr, 4, B_READ))
                        goto error;
                ipc.ip_data = fuword((caddr_t)ipc.ip_addr);
                break;
 
-       /* read u */
-       case 3:
+       case PT_READ_U:                 /* read the child's u. */
                i = (int)ipc.ip_addr;
                if (i<0 || i >= ctob(UPAGES))
                        goto error;
                ipc.ip_data = *(int *)PHYSOFF(&u, i);
                break;
 
                i = (int)ipc.ip_addr;
                if (i<0 || i >= ctob(UPAGES))
                        goto error;
                ipc.ip_data = *(int *)PHYSOFF(&u, i);
                break;
 
-       /* write user I */
-       /* Must set up to allow writing */
-       case 4:
+       case PT_WRITE_I:                /* write the child's text space */
                /*
                 * If text, must assure exclusive use
                 */
                /*
                 * If text, must assure exclusive use
                 */
@@ -159,15 +155,13 @@ procxmt()
                        xp->x_flag |= XWRIT;
                break;
 
                        xp->x_flag |= XWRIT;
                break;
 
-       /* write user D */
-       case 5:
+       case PT_WRITE_D:                /* write the child's data space */
                if (suword((caddr_t)ipc.ip_addr, 0) < 0)
                        goto error;
                (void) suword((caddr_t)ipc.ip_addr, ipc.ip_data);
                break;
 
                if (suword((caddr_t)ipc.ip_addr, 0) < 0)
                        goto error;
                (void) suword((caddr_t)ipc.ip_addr, ipc.ip_data);
                break;
 
-       /* write u */
-       case 6:
+       case PT_WRITE_U:                /* write the child's u. */
                i = (int)ipc.ip_addr;
                p = (int *)PHYSOFF(&u, i);
                for (i=0; i<NIPCREG; i++)
                i = (int)ipc.ip_addr;
                p = (int *)PHYSOFF(&u, i);
                for (i=0; i<NIPCREG; i++)
@@ -184,22 +178,19 @@ procxmt()
                *p = ipc.ip_data;
                break;
 
                *p = ipc.ip_data;
                break;
 
-       /* set signal and continue */
-       /* one version causes a trace-trap */
-       case 9:
-       case 7:
+       case PT_STEP:                   /* single step the child */
+       case PT_CONTINUE:               /* continue the child */
                if ((int)ipc.ip_addr != 1)
                        u.u_ar0[PC] = (int)ipc.ip_addr;
                if ((unsigned)ipc.ip_data > NSIG)
                        goto error;
                u.u_procp->p_cursig = ipc.ip_data;      /* see issig */
                if ((int)ipc.ip_addr != 1)
                        u.u_ar0[PC] = (int)ipc.ip_addr;
                if ((unsigned)ipc.ip_data > NSIG)
                        goto error;
                u.u_procp->p_cursig = ipc.ip_data;      /* see issig */
-               if (i == 9
+               if (i == PT_STEP
                        u.u_ar0[PS] |= PSL_T;
                wakeup((caddr_t)&ipc);
                return (1);
 
                        u.u_ar0[PS] |= PSL_T;
                wakeup((caddr_t)&ipc);
                return (1);
 
-       /* force exit */
-       case 8:
+       case PT_KILL:                   /* kill the child process */
                wakeup((caddr_t)&ipc);
                exit(u.u_procp->p_cursig);
 
                wakeup((caddr_t)&ipc);
                exit(u.u_procp->p_cursig);
 
index db4a2fb..5189da9 100644 (file)
@@ -3,7 +3,7 @@
  * 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  6.11 (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,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;
 
@@ -418,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;
@@ -466,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) {
@@ -490,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);