v03i101: Xaw/Load.c and related patches, Patch1

Dan Heller argv at island.uu.net
Thu May 4 04:13:17 AEST 1989


Submitted-by: jim at eda.com
Posting-number: Volume 3, Issue 101
Archive-name: xaw.load.patch/patch1

[ I didn't try this -- argv ]

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	README
#	XawLoad.diff
#	xperforig.diff
#	xperfdavy.diff
# This archive created: Wed Apr 26 12:25:33 1989
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
sed 's/^X//' << \SHAR_EOF > 'README'
XThis is just some trivial patches to make the xperfmon and load meter
Xwork on the sun386i. The notes below by Dave Curry concerning adding
Xthe -DSUN4_0 and -lkvm apply only to the xperfmon changes.
X
X	jim at eda.com
X
XEnclosed find:
X        README          - this file
X        XawLoad.diff    - diffs to Xaw/Load.c for the sun386 
X        xperforig.diff  - diffs to contrib/clients/xperfmon/system.c
X                          for the sun386 and sunOS4.0. These include the
X                          patches by Dave Curry <davy at riacs.edu> for sunOS4.0.
X                          This diff is between the distributed code and mine.
X        xperfdavy.diff  - diffs between the system.c with Dave's patches
X		                  already applied, and mine.
X
X############## Original README file from Dave Curry ##################
X
XThe distributed X.V11R3 xperfmon does not run under SunOS 4.0, because
XSun changed things to access the kernel via the -lkvm library.
X
XThe other file in this shell archive, "diffs", contains context diffs
Xfor core/contrib/clients/xperfmon/system.c to make xperfmon run under
XSunOS 4.0.
X
XIn addition to applying the diffs, you'll need to modify the Makefile
X(or Imakefile or whatever) to:
X
X	1. Add "-DSUN4_0" to CFLAGS.
X	2. Add "-lkvm" to the load libraries.
X
XSomebody really needs to rewrite this thing to be truly X11-like; it
Xdoesn't use the resource database or anything else.  Oh well.
X
XDave Curry
XResearch Institute for Advanced Computer Science
XMail Stop 230-5
XNASA Ames Research Center
XMoffett Field, CA 94035
Xdavy at riacs.edu
SHAR_EOF
fi
if test -f 'XawLoad.diff'
then
	echo shar: "will not over-write existing file 'XawLoad.diff'"
else
sed 's/^X//' << \SHAR_EOF > 'XawLoad.diff'
X*** /tmp/,RCSt1a05252	Wed Apr 26 08:25:22 1989
X--- Load.c	Wed Apr 26 08:23:55 1989
X***************
X*** 491,497 ****
X--- 491,501 ----
X  #define KERNEL_FILE "/dynix"
X  #endif /* sequent */
X  #ifdef sun
X+ #ifdef sun386
X+ # define KERNEL_LOAD_VARIABLE "avenrun"
X+ #else
X  # define KERNEL_LOAD_VARIABLE "_avenrun"
X+ #endif /* sun386 */
X  #endif /* sun */
X  /*
X   * provide default for everyone else
X***************
X*** 553,559 ****
X--- 557,567 ----
X  	
X  	if(!init)   {
X  	    nlist( KERNEL_FILE, namelist);
X+ #ifdef sun386
X+ 	    if ((namelist[LOADAV].n_type == 0) && (namelist[LOADAV].n_value == 0)){
X+ #else
X  	    if (namelist[LOADAV].n_type == 0){
X+ #endif
X  		xload_error("cannot get name list from", KERNEL_FILE);
X  		exit(-1);
X  	    }
SHAR_EOF
fi
if test -f 'xperforig.diff'
then
	echo shar: "will not over-write existing file 'xperforig.diff'"
else
sed 's/^X//' << \SHAR_EOF > 'xperforig.diff'
X*** /tmp/,RCSt1a05308	Wed Apr 26 08:35:39 1989
X--- system.c	Wed Apr 26 08:35:22 1989
X***************
X*** 16,21 ****
X--- 16,25 ----
X  #include <sys/socket.h>
X  #include <sys/vm.h>
X  #include <sys/dk.h>
X+ #ifdef SUN4_0
X+ #include <kvm.h>
X+ #include <fcntl.h>
X+ #endif
X  #include <nlist.h>
X  #include <sys/buf.h>
X  #ifdef vax
X***************
X*** 59,66 ****
X--- 63,109 ----
X  int debug = 0;
X  #define max(a,b) (a>b ? a:b)
X  
X+ #ifdef sun386
X  struct nlist nl[] = {
X  #define X_CPTIME	0
X+ 	{ "cp_time" },
X+ #define X_RATE	  1
X+ 	{ "rate" },
X+ #define X_TOTAL	 2
X+ 	{ "total" },
X+ #define X_DEFICIT       3
X+ 	{ "deficit" },
X+ #define X_FORKSTAT      4
X+ 	{ "forkstat" },
X+ #define X_SUM	   5
X+ 	{ "sum" },
X+ #define X_FIRSTFREE     6
X+ 	{ "firstfree" },
X+ #define X_MAXFREE       7
X+ 	{ "maxfree" },
X+ #define X_BOOTTIME      8
X+ 	{ "boottime" },
X+ #define X_DKXFER	9
X+ 	{ "dk_xfer" },
X+ #define X_REC	   10
X+ 	{ "rectime" },
X+ #define X_PGIN	  11
X+ 	{ "pgintime" },
X+ #define X_HZ	    12
X+ 	{ "hz" },
X+ #define X_MBDINIT       13
X+ 	{ "mbdinit" },
X+ #define N_IFNET       14
X+ 	{ "ifnet" },
X+ #define X_UBDINIT	15
X+ 	{ "ubdinit" },
X+ #define X_IOCINIT	16
X+ 	{ "ioccdinit" },
X+ 	{ "" },
X+ };
X+ #else
X+ struct nlist nl[] = {
X+ #define X_CPTIME	0
X  	{ "_cp_time" },
X  #define X_RATE	  1
X  	{ "_rate" },
X***************
X*** 96,101 ****
X--- 139,145 ----
X  	{ "_ioccdinit" },
X  	{ "" },
X  };
X+ #endif
X  
X  char dr_name[DK_NDRIVE][10];
X  char dr_unit[DK_NDRIVE];
X***************
X*** 129,135 ****
X--- 173,184 ----
X  int nintv;
X  long t;
X  
X+ #ifdef SUN4_0
X+ kvm_t *kd;
X+ #define steal(where, var) kvm_read(kd, where, &var, sizeof var);
X+ #else
X  #define steal(where, var) lseek(mf, where, 0); read(mf, &var, sizeof var);
X+ #endif
X  #define pgtok(a) ((a)*NBPG/1024)
X  
X  void set_sys_defaults()
X***************
X*** 223,229 ****
X--- 272,283 ----
X    init_stat(USER_CPU_PERCENTAGE, 0, 100, "User", " CPU");
X    init_stat(SYSTEM_CPU_PERCENTAGE, 0, 100, "System", " CPU");
X    init_stat(IDLE_CPU_PERCENTAGE, 0, 100, "Idle", " CPU");
X+ #ifdef SUN4_0
X+   /* Kludge - maxfree isn't kept on Sun 4.0 (sigh) */
X+   init_stat(FREE_MEM, 0, max(pgtok(maxfree), (2 * pgtok(total.t_free))), "Free", " memory");
X+ #else
X    init_stat(FREE_MEM, 0, pgtok(maxfree), "Free", " memory");
X+ #endif
X    init_stat(DISK_TRANSFERS, 0, 40, "Disk", " transfers");
X    init_stat(INTERRUPTS, 0, 60, "Interrupts", "");
X    init_stat(INPUT_PACKETS, 0, (have_disk ? 20 : 40), "Input", " packets");
X***************
X*** 317,326 ****
X--- 371,385 ----
X  
X  	register int i;
X  
X+ #ifdef SUN4_0
X+ 	kvm_read(kd, (long)nl[X_CPTIME].n_value, s.time, sizeof s.time);
X+ 	kvm_read(kd, (long)nl[X_DKXFER].n_value, s.xfer, sizeof s.xfer);
X+ #else
X  	lseek(mf, (long)nl[X_CPTIME].n_value, 0);
X  	read(mf, s.time, sizeof s.time);
X  	lseek(mf, (long)nl[X_DKXFER].n_value, 0);
X  	read(mf, s.xfer, sizeof s.xfer);
X+ #endif
X  	if (nintv != 1) {
X  		steal((long)nl[X_SUM].n_value, rate);
X  	} 
X***************
X*** 378,383 ****
X--- 437,454 ----
X  	register int i;
X  	int nintv;
X  
X+ #ifdef SUN4_0
X+ 	if ((kd = kvm_open(kernel_name, NULL, NULL, O_RDONLY, "xperfmon")) == NULL)
X+ 		exit(1);
X+ #ifdef sun386
X+ 	if ((kvm_nlist(kd, nl) < 0) || ((nl[0].n_type == 0) && (nl[0].n_value == 0))) {
X+ #else
X+ 	if ((kvm_nlist(kd, nl) < 0) || (nl[0].n_type == 0)) {
X+ #endif
X+ 		fprintf(stderr, "no %s namelist\n", kernel_name);
X+ 		exit(1);
X+ 	}
X+ #else
X  	nlist(kernel_name, nl);
X  	if(nl[0].n_type == 0) {
X  		fprintf(stderr, "no %s namelist\n", kernel_name);
X***************
X*** 388,393 ****
X--- 459,465 ----
X  		fprintf(stderr, "cannot open %s\n", memory_name);
X  		exit(1);
X  	}
X+ #endif
X  	steal((long)nl[X_MAXFREE].n_value, maxfree);
X  	steal((long)nl[X_BOOTTIME].n_value, boottime);
X  	steal((long)nl[X_HZ].n_value, hz);
X***************
X*** 434,440 ****
X  	mp = (struct mba_device *) nl[X_MBDINIT].n_value;
X  	up = (struct uba_device *) nl[X_UBDINIT].n_value;
X  	if (up == 0) {
X! 		fprintf(stderr, "perfmon: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	if(mp) for (;;) {
X--- 506,512 ----
X  	mp = (struct mba_device *) nl[X_MBDINIT].n_value;
X  	up = (struct uba_device *) nl[X_UBDINIT].n_value;
X  	if (up == 0) {
X! 		fprintf(stderr, "xperfmon: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	if(mp) for (;;) {
X***************
X*** 473,479 ****
X  
X  	mp = (struct mb_device *) nl[X_MBDINIT].n_value;
X  	if (mp == 0) {
X! 		fprintf(stderr, "vmstat: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	for (;;) {
X--- 545,551 ----
X  
X  	mp = (struct mb_device *) nl[X_MBDINIT].n_value;
X  	if (mp == 0) {
X! 		fprintf(stderr, "xperfmon: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	for (;;) {
X***************
X*** 501,507 ****
X  
X  	mp = (struct iocc_device *) nl[X_IOCINIT].n_value;
X  	if (mp == 0) {
X! 		fprintf(stderr, "vmstat: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	for (;;) {
X--- 573,579 ----
X  
X  	mp = (struct iocc_device *) nl[X_IOCINIT].n_value;
X  	if (mp == 0) {
X! 		fprintf(stderr, "xperfmon: Disk init info not in namelist\n");
X  		exit(1);
X  	}
X  	for (;;) {
SHAR_EOF
fi
if test -f 'xperfdavy.diff'
then
	echo shar: "will not over-write existing file 'xperfdavy.diff'"
else
sed 's/^X//' << \SHAR_EOF > 'xperfdavy.diff'
X*** /tmp/,RCSt1a05313	Wed Apr 26 08:35:43 1989
X--- system.c	Wed Apr 26 08:35:22 1989
X***************
X*** 63,70 ****
X--- 63,109 ----
X  int debug = 0;
X  #define max(a,b) (a>b ? a:b)
X  
X+ #ifdef sun386
X  struct nlist nl[] = {
X  #define X_CPTIME	0
X+ 	{ "cp_time" },
X+ #define X_RATE	  1
X+ 	{ "rate" },
X+ #define X_TOTAL	 2
X+ 	{ "total" },
X+ #define X_DEFICIT       3
X+ 	{ "deficit" },
X+ #define X_FORKSTAT      4
X+ 	{ "forkstat" },
X+ #define X_SUM	   5
X+ 	{ "sum" },
X+ #define X_FIRSTFREE     6
X+ 	{ "firstfree" },
X+ #define X_MAXFREE       7
X+ 	{ "maxfree" },
X+ #define X_BOOTTIME      8
X+ 	{ "boottime" },
X+ #define X_DKXFER	9
X+ 	{ "dk_xfer" },
X+ #define X_REC	   10
X+ 	{ "rectime" },
X+ #define X_PGIN	  11
X+ 	{ "pgintime" },
X+ #define X_HZ	    12
X+ 	{ "hz" },
X+ #define X_MBDINIT       13
X+ 	{ "mbdinit" },
X+ #define N_IFNET       14
X+ 	{ "ifnet" },
X+ #define X_UBDINIT	15
X+ 	{ "ubdinit" },
X+ #define X_IOCINIT	16
X+ 	{ "ioccdinit" },
X+ 	{ "" },
X+ };
X+ #else
X+ struct nlist nl[] = {
X+ #define X_CPTIME	0
X  	{ "_cp_time" },
X  #define X_RATE	  1
X  	{ "_rate" },
X***************
X*** 100,105 ****
X--- 139,145 ----
X  	{ "_ioccdinit" },
X  	{ "" },
X  };
X+ #endif
X  
X  char dr_name[DK_NDRIVE][10];
X  char dr_unit[DK_NDRIVE];
X***************
X*** 400,406 ****
X--- 440,450 ----
X  #ifdef SUN4_0
X  	if ((kd = kvm_open(kernel_name, NULL, NULL, O_RDONLY, "xperfmon")) == NULL)
X  		exit(1);
X+ #ifdef sun386
X+ 	if ((kvm_nlist(kd, nl) < 0) || ((nl[0].n_type == 0) && (nl[0].n_value == 0))) {
X+ #else
X  	if ((kvm_nlist(kd, nl) < 0) || (nl[0].n_type == 0)) {
X+ #endif
X  		fprintf(stderr, "no %s namelist\n", kernel_name);
X  		exit(1);
X  	}
SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
Jim Budler   address = uucp: ...!{decwrl,uunet}!eda!jim
					 domain: jim at eda.com
			 voice	 = +1 408 986-9585
			 fax	 = +1 408 748-1032



More information about the Comp.sources.x mailing list