eliminate floating point from the kernel (from forys@cs.utah.edu)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 30 May 1989 09:31:58 +0000 (01:31 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 30 May 1989 09:31:58 +0000 (01:31 -0800)
SCCS-vsn: usr.bin/systat/systat.h 5.3
SCCS-vsn: usr.sbin/iostat/iostat.c 4.17
SCCS-vsn: old/pcc/lint/llibs/llib-lc 1.45
SCCS-vsn: usr.sbin/sendmail/src/conf.c 5.20
SCCS-vsn: games/dm/dm.c 5.12
SCCS-vsn: old/rogue/machdep.c 5.3

usr/src/games/dm/dm.c
usr/src/old/pcc/lint/llibs/llib-lc
usr/src/old/rogue/machdep.c
usr/src/usr.bin/systat/systat.h
usr/src/usr.sbin/iostat/iostat.c
usr/src/usr.sbin/sendmail/src/conf.c

index 2c4e712..0ac623b 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)dm.c       5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)dm.c       5.12 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -216,12 +216,6 @@ c_game(s_game, s_load, s_users, s_priority)
                priority = atoi(s_priority);
 }
 
                priority = atoi(s_priority);
 }
 
-static struct nlist nl[] = {
-       { "_avenrun" },
-#define        X_AVENRUN       0
-       { "" },
-};
-
 /*
  * load --
  *     return 15 minute load average
 /*
  * load --
  *     return 15 minute load average
@@ -230,19 +224,11 @@ static double
 load()
 {
        double avenrun[3];
 load()
 {
        double avenrun[3];
-       int kmem;
-       long lseek();
 
 
-       if (nlist("/vmunix", nl)) {
-               fputs("dm: nlist of /vmunix failed.\n", stderr);
-               exit(1);
-       }
-       if ((kmem = open("/dev/kmem", O_RDONLY, 0)) < 0) {
-               perror("dm: /dev/kmem");
+       if (getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0])) < 0) {
+               fputs("dm: getloadavg() failed.\n", stderr);
                exit(1);
        }
                exit(1);
        }
-       (void)lseek(kmem, (long)nl[X_AVENRUN].n_value, L_SET);
-       (void)read(kmem, (char *)avenrun, sizeof(avenrun));
        return(avenrun[2]);
 }
 
        return(avenrun[2]);
 }
 
index c1c50c2..c7b3b90 100644 (file)
@@ -1,4 +1,4 @@
-/*     @(#)llib-lc     1.44 (Berkeley) %G%     */
+/*     @(#)llib-lc     1.45 (Berkeley) %G%     */
 
 /* LINTLIBRARY */
 
 
 /* LINTLIBRARY */
 
@@ -242,6 +242,7 @@ struct group *      getgrnam( n ) char *n; { return (struct group *)NULL; }
 struct hostent *       gethostbyaddr(addr, len, type) char *addr; { return (struct hostent *) 0; }
 struct hostent *       gethostbyname(name) char *name; { return (struct hostent *) 0; }
 struct hostent *       gethostent() { return (struct hostent *) 0; }
 struct hostent *       gethostbyaddr(addr, len, type) char *addr; { return (struct hostent *) 0; }
 struct hostent *       gethostbyname(name) char *name; { return (struct hostent *) 0; }
 struct hostent *       gethostent() { return (struct hostent *) 0; }
+int    getloadavg( v, l ) double v[]; int l; { return 0; }
 char * getlogin(){ return " "; }
 struct netent *        getnetbyaddr(net, type) { return (struct netent *) 0; }
 struct netent *        getnetbyname(name) char *name; { return (struct netent *) 0; }
 char * getlogin(){ return " "; }
 struct netent *        getnetbyaddr(net, type) { return (struct netent *) 0; }
 struct netent *        getnetbyname(name) char *name; { return (struct netent *) 0; }
index 6bb8f69..dbfab0f 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)machdep.c  5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)machdep.c  5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -56,6 +56,8 @@ static char sccsid[] = "@(#)machdep.c 5.2 (Berkeley) %G%";
 # include      <sys/stat.h>
 # include      <sys/file.h>
 
 # include      <sys/stat.h>
 # include      <sys/file.h>
 
+# undef LOADAV         /* use getloadavg() by default */
+
 # ifdef        SCOREFILE
 
 static char    *Lockfile = "/tmp/.fredlock";
 # ifdef        SCOREFILE
 
 static char    *Lockfile = "/tmp/.fredlock";
@@ -224,7 +226,12 @@ too_much()
 # endif        MAXUSERS
 
 # ifdef MAXLOAD
 # endif        MAXUSERS
 
 # ifdef MAXLOAD
+# ifdef LOADAV
        loadav(avec);
        loadav(avec);
+# else
+       if (getloadavg(avec, sizeof(avec)/sizeof(avec[0])) < 0)
+               avec[0] = avec[1] = avec[2] = 0.0;
+# endif
        if (avec[1] > MAXLOAD)
                return TRUE;
 # endif        MAXLOAD
        if (avec[1] > MAXLOAD)
                return TRUE;
 # endif        MAXLOAD
index a274db9..f4caf11 100644 (file)
@@ -3,15 +3,17 @@
  * 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.
  *
- *     @(#)systat.h    5.2 (Berkeley) %G%
+ *     @(#)systat.h    5.3 (Berkeley) %G%
  */
 
 #include <netdb.h>
 #include <nlist.h>
 #include <signal.h>
 #include <curses.h>
  */
 
 #include <netdb.h>
 #include <nlist.h>
 #include <signal.h>
 #include <curses.h>
+#include <math.h>
 
 #include <sys/param.h>
 
 #include <sys/param.h>
+#include <sys/types.h>
 #include <sys/file.h>
 #include <sys/dkstat.h>
 
 #include <sys/file.h>
 #include <sys/dkstat.h>
 
@@ -65,6 +67,7 @@ int     naptime, col;
 long   ntext, textp;
 struct text *xtext;
 
 long   ntext, textp;
 struct text *xtext;
 
+int    fscale;
 double  lccpu;
 double avenrun[3];
 
 double  lccpu;
 double avenrun[3];
 
index 2d2bbd4..98d655f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)iostat.c    4.16 (Berkeley) 89/05/11";
+static char *sccsid = "@(#)iostat.c    4.17 (Berkeley) 89/05/29";
 #endif
 
 /*
 #endif
 
 /*
@@ -32,8 +32,8 @@ struct nlist nl[] = {
 #define        X_DK_SEEK       6
        { "_cp_time" },
 #define        X_CP_TIME       7
 #define        X_DK_SEEK       6
        { "_cp_time" },
 #define        X_CP_TIME       7
-       { "_dk_mspw" },
-#define        X_DK_MSPW       8
+       { "_dk_wpms" },
+#define        X_DK_WPMS       8
        { "_hz" },
 #define        X_HZ            9
        { "_phz" },
        { "_hz" },
 #define        X_HZ            9
        { "_phz" },
@@ -55,7 +55,7 @@ struct nlist nl[] = {
 
 char   **dr_name;
 int    *dr_select;
 
 char   **dr_name;
 int    *dr_select;
-float  *dk_mspw;
+long   *dk_wpms;
 int    dk_ndrive;
 int    ndrives = 0;
 #ifdef vax
 int    dk_ndrive;
 int    ndrives = 0;
 #ifdef vax
@@ -118,7 +118,7 @@ main(argc, argv)
        }
        dr_select = (int *)calloc(dk_ndrive, sizeof (int));
        dr_name = (char **)calloc(dk_ndrive, sizeof (char *));
        }
        dr_select = (int *)calloc(dk_ndrive, sizeof (int));
        dr_name = (char **)calloc(dk_ndrive, sizeof (char *));
-       dk_mspw = (float *)calloc(dk_ndrive, sizeof (float));
+       dk_wpms = (long *)calloc(dk_ndrive, sizeof (long));
 #define        allocate(e, t) \
     s./**/e = (t *)calloc(dk_ndrive, sizeof (t)); \
     s1./**/e = (t *)calloc(dk_ndrive, sizeof (t));
 #define        allocate(e, t) \
     s./**/e = (t *)calloc(dk_ndrive, sizeof (t)); \
     s1./**/e = (t *)calloc(dk_ndrive, sizeof (t));
@@ -138,8 +138,8 @@ main(argc, argv)
        read(mf, &phz, sizeof phz);
        if (phz)
                hz = phz;
        read(mf, &phz, sizeof phz);
        if (phz)
                hz = phz;
-       lseek(mf, (long)nl[X_DK_MSPW].n_value, L_SET);
-       read(mf, dk_mspw, dk_ndrive*sizeof (dk_mspw));
+       lseek(mf, (long)nl[X_DK_WPMS].n_value, L_SET);
+       read(mf, dk_wpms, dk_ndrive*sizeof (dk_wpms));
        /*
         * Choose drives to be displayed.  Priority
         * goes to (in order) drives supplied as arguments,
        /*
         * Choose drives to be displayed.  Priority
         * goes to (in order) drives supplied as arguments,
@@ -158,7 +158,7 @@ main(argc, argv)
                argc--, argv++;
        }
        for (i = 0; i < dk_ndrive && ndrives < 4; i++) {
                argc--, argv++;
        }
        for (i = 0; i < dk_ndrive && ndrives < 4; i++) {
-               if (dr_select[i] || dk_mspw[i] == 0.0)
+               if (dr_select[i] || dk_wpms[i] == 0)
                        continue;
                for (cp = defdrives; *cp; cp++)
                        if (strcmp(dr_name[i], *cp) == 0) {
                        continue;
                for (cp = defdrives; *cp; cp++)
                        if (strcmp(dr_name[i], *cp) == 0) {
@@ -248,14 +248,14 @@ stats(dn)
        register i;
        double atime, words, xtime, itime;
 
        register i;
        double atime, words, xtime, itime;
 
-       if (dk_mspw[dn] == 0.0) {
+       if (dk_wpms[dn] == 0) {
                printf("%4.0f%4.0f%5.1f ", 0.0, 0.0, 0.0);
                return;
        }
        atime = s.dk_time[dn];
        atime /= (float) hz;
        words = s.dk_wds[dn]*32.0;      /* number of words transferred */
                printf("%4.0f%4.0f%5.1f ", 0.0, 0.0, 0.0);
                return;
        }
        atime = s.dk_time[dn];
        atime /= (float) hz;
        words = s.dk_wds[dn]*32.0;      /* number of words transferred */
-       xtime = dk_mspw[dn]*words;      /* transfer time */
+       xtime = words/dk_wpms[dn];      /* transfer time */
        itime = atime - xtime;          /* time not transferring */
        if (xtime < 0)
                itime += xtime, xtime = 0;
        itime = atime - xtime;          /* time not transferring */
        if (xtime < 0)
                itime += xtime, xtime = 0;
index f9fca2f..f1dae4f 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     5.20 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/ioctl.h>
 #endif /* not lint */
 
 # include <sys/ioctl.h>
@@ -388,7 +388,18 @@ rlsesigs()
 **             none.
 */
 
 **             none.
 */
 
-#ifdef VMUNIX
+#ifndef sun
+
+getla()
+{
+       double avenrun[3];
+
+       if (getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0])) < 0)
+               return (0);
+       return ((int) (avenrun[0] + 0.5));
+}
+
+#else /* sun */
 
 #include <nlist.h>
 
 
 #include <nlist.h>
 
@@ -402,11 +413,7 @@ struct     nlist Nl[] =
 getla()
 {
        static int kmem = -1;
 getla()
 {
        static int kmem = -1;
-# ifdef sun
        long avenrun[3];
        long avenrun[3];
-# else
-       double avenrun[3];
-# endif
        extern off_t lseek();
 
        if (kmem < 0)
        extern off_t lseek();
 
        if (kmem < 0)
@@ -425,21 +432,10 @@ getla()
                /* thank you Ian */
                return (-1);
        }
                /* thank you Ian */
                return (-1);
        }
-# ifdef sun
        return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT);
        return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT);
-# else
-       return ((int) (avenrun[0] + 0.5));
-# endif
-}
-
-#else VMUNIX
-
-getla()
-{
-       return (0);
 }
 
 }
 
-#endif VMUNIX
+#endif /* sun */
 \f/*
 **  SHOULDQUEUE -- should this message be queued or sent?
 **
 \f/*
 **  SHOULDQUEUE -- should this message be queued or sent?
 **