[comp.sources.bugs] screen: Sun load averages patch

whb@antique.UUCP (Wilson H. Bent) (05/09/88)

Here is a patch to 'screen' to allow display of load averages on a
Sun system (tested under Sun-3 UNIX Release 3.3 and Sun-4 SunOS 3.2).
Unlike most (all?) other BSD-type systems, Sun keeps the load average
in /vmunix as 3 scaled integers, not 3 doubles-precision floats.  The
conversion is simple and standard.

(Betcha this .signature appears twice!)

Wilson H. Bent, Jr.		... ihnp4!hoh-2!whb (whb@hoh-2.ATT.COM)
AT&T - Bell Laboratories	(201) 949-1277
Disclaimer: My company has not authorized me to issue a disclaimer.

*** screen.c.orig	Fri Aug 14 10:15:53 1987
--- screen.c	Thu May  5 11:17:13 1988
***************
*** 85,90 ****
--- 85,93 ----
  static mflag, nflag, fflag;
  static char HostName[MAXSTR];
  #ifdef LOADAV
+ #ifdef sun
+ #include <sys/param.h>
+ #endif
      static char KmemName[] = "/dev/kmem";
      static char UnixName[] = "/vmunix";
      static char AvenrunSym[] = "_avenrun";
***************
*** 852,859 ****
--- 855,866 ----
      struct tm *tp;
      time_t now;
  #ifdef LOADAV
+ #ifdef sun
+     long av[3];
+ #else
      double av[3];
  #endif
+ #endif
  
      time (&now);
      tp = localtime (&now);
***************
*** 862,868 ****
--- 869,880 ----
  #ifdef LOADAV
      if (avenrun && GetAvenrun (av)) {
  	p = buf + strlen (buf);
+ #ifdef sun
+ 	sprintf (p, " %2.2f %2.2f %2.2f",
+ 	    (double)av[0]/FSCALE, (double)av[1]/FSCALE, (double)av[2]/FSCALE);
+ #else
  	sprintf (p, " %2.2f %2.2f %2.2f", av[0], av[1], av[2]);
+ #endif
      }
  #endif
      p = buf + strlen (buf);
-- 
Wilson H. Bent, Jr.		... ihnp4!hoh-2!whb
AT&T - Bell Laboratories	(201) 949-1277
Disclaimer: My company has not authorized me to issue a disclaimer.