BSD 4_3_Net_2 release
[unix-history] / usr / src / bin / ps / print.c
index 3d26cae..ce4be52 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.9 (Berkeley) 7/1/91";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -142,10 +168,12 @@ state(k, v)
                *cp++ = '<';
        else if (p->p_nice > NZERO)
                *cp++ = 'N';
                *cp++ = '<';
        else if (p->p_nice > NZERO)
                *cp++ = 'N';
+#ifndef NEWVM
        if (flag & SUANOM)
                *cp++ = 'A';
        else if (flag & SSEQL)
                *cp++ = 'S';
        if (flag & SUANOM)
                *cp++ = 'A';
        else if (flag & SSEQL)
                *cp++ = 'S';
+#endif
        if (flag & STRC)
                *cp++ = 'X';
        if (flag & SWEXIT && p->p_stat != SZOMB)
        if (flag & STRC)
                *cp++ = 'X';
        if (flag & SWEXIT && p->p_stat != SZOMB)
@@ -156,7 +184,11 @@ state(k, v)
        if (flag & SVFORK)
 #endif
                *cp++ = 'V';
        if (flag & SVFORK)
 #endif
                *cp++ = 'V';
+#ifdef NEWVM
+       if (flag & (SSYS|SLOCK|SKEEP|SPHYSIO))
+#else
        if (flag & (SSYS|SLOCK|SULOCK|SKEEP|SPHYSIO))
        if (flag & (SSYS|SLOCK|SULOCK|SKEEP|SPHYSIO))
+#endif
                *cp++ = 'L';
        if (k->ki_e->e_flag & EPROC_SLEADER)
                *cp++ = 's';
                *cp++ = 'L';
        if (k->ki_e->e_flag & EPROC_SLEADER)
                *cp++ = 's';
@@ -262,11 +294,11 @@ started(k, v)
        if (!now)
                (void)time(&now);
        if (now - k->ki_u->u_start.tv_sec < 24 * SECSPERHOUR) {
        if (!now)
                (void)time(&now);
        if (now - k->ki_u->u_start.tv_sec < 24 * SECSPERHOUR) {
-               static char *fmt = "%l:@M%p";
+               static char fmt[] = "%l:@M%p";
                fmt[3] = '%';                   /* I *hate* SCCS... */
                (void) strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else if (now - k->ki_u->u_start.tv_sec < 7 * SECSPERDAY) {
                fmt[3] = '%';                   /* I *hate* SCCS... */
                (void) strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else if (now - k->ki_u->u_start.tv_sec < 7 * SECSPERDAY) {
-               static char *fmt = "%a@I%p";
+               static char fmt[] = "%a@I%p";
                fmt[2] = '%';                   /* I *hate* SCCS... */
                (void) strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else
                fmt[2] = '%';                   /* I *hate* SCCS... */
                (void) strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else
@@ -297,7 +329,7 @@ wchan(k, v)
                if (k->ki_p->p_wmesg)
                        (void) printf("%-*.*s", v->width, v->width, k->ki_e->e_wmesg);
                else
                if (k->ki_p->p_wmesg)
                        (void) printf("%-*.*s", v->width, v->width, k->ki_e->e_wmesg);
                else
-                       (void) printf("%*x", v->width,
+                       (void) printf("%-*x", v->width,
                            (int)k->ki_p->p_wchan &~ KERNBASE);
        } else
                (void) printf("%-*s", v->width, "-");
                            (int)k->ki_p->p_wchan &~ KERNBASE);
        } else
                (void) printf("%-*s", v->width, "-");
@@ -414,7 +446,7 @@ double
 getpmem(k)
        KINFO *k;
 {
 getpmem(k)
        KINFO *k;
 {
-       extern int ecmx, nlistread;
+       extern int mempages, nlistread;
        static int failure;
        struct proc *p;
        struct eproc *e;
        static int failure;
        struct proc *p;
        struct eproc *e;
@@ -432,14 +464,14 @@ getpmem(k)
                return (0.0);
 #ifndef NEWVM
        szptudot = UPAGES + clrnd(ctopt(p->p_dsize + p->p_ssize + e->e_xsize));
                return (0.0);
 #ifndef NEWVM
        szptudot = UPAGES + clrnd(ctopt(p->p_dsize + p->p_ssize + e->e_xsize));
-       fracmem = ((float)p->p_rssize + szptudot)/CLSIZE/ecmx;
+       fracmem = ((float)p->p_rssize + szptudot)/CLSIZE/mempages;
        if (p->p_textp && e->e_xccount)
        if (p->p_textp && e->e_xccount)
-               fracmem += ((float)e->e_xrssize)/CLSIZE/e->e_xccount/ecmx;
+               fracmem += ((float)e->e_xrssize)/CLSIZE/e->e_xccount/mempages;
 #else /* NEWVM */
        /* XXX want pmap ptpages, segtab, etc. (per architecture) */
        szptudot = UPAGES;
        /* XXX don't have info about shared */
 #else /* NEWVM */
        /* XXX want pmap ptpages, segtab, etc. (per architecture) */
        szptudot = UPAGES;
        /* XXX don't have info about shared */
-       fracmem = ((float)e->e_vm.vm_rssize + szptudot)/CLSIZE/ecmx;
+       fracmem = ((float)e->e_vm.vm_rssize + szptudot)/CLSIZE/mempages;
 #endif /* NEWVM */
        return (100.0 * fracmem);
 }
 #endif /* NEWVM */
        return (100.0 * fracmem);
 }
@@ -563,6 +595,6 @@ printval(bp, v)
                (void) printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
                break;
        default:
                (void) printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
                break;
        default:
-               error("unknown type %d", v->type);
+               err("unknown type %d", v->type);
        }
 }
        }
 }