head 1.6; access; symbols pkgsrc-2013Q2:1.6.0.10 pkgsrc-2013Q2-base:1.6 pkgsrc-2012Q4:1.6.0.8 pkgsrc-2012Q4-base:1.6 pkgsrc-2011Q4:1.6.0.6 pkgsrc-2011Q4-base:1.6 pkgsrc-2011Q2:1.6.0.4 pkgsrc-2011Q2-base:1.6 pkgsrc-2009Q4:1.6.0.2 pkgsrc-2009Q4-base:1.6 pkgsrc-2009Q3:1.5.0.40 pkgsrc-2009Q3-base:1.5 pkgsrc-2009Q2:1.5.0.38 pkgsrc-2009Q2-base:1.5 pkgsrc-2009Q1:1.5.0.36 pkgsrc-2009Q1-base:1.5 pkgsrc-2008Q4:1.5.0.34 pkgsrc-2008Q4-base:1.5 pkgsrc-2008Q3:1.5.0.32 pkgsrc-2008Q3-base:1.5 cube-native-xorg:1.5.0.30 cube-native-xorg-base:1.5 pkgsrc-2008Q2:1.5.0.28 pkgsrc-2008Q2-base:1.5 cwrapper:1.5.0.26 pkgsrc-2008Q1:1.5.0.24 pkgsrc-2008Q1-base:1.5 pkgsrc-2007Q4:1.5.0.22 pkgsrc-2007Q4-base:1.5 pkgsrc-2007Q3:1.5.0.20 pkgsrc-2007Q3-base:1.5 pkgsrc-2007Q2:1.5.0.18 pkgsrc-2007Q2-base:1.5 pkgsrc-2007Q1:1.5.0.16 pkgsrc-2007Q1-base:1.5 pkgsrc-2006Q4:1.5.0.14 pkgsrc-2006Q4-base:1.5 pkgsrc-2006Q3:1.5.0.12 pkgsrc-2006Q3-base:1.5 pkgsrc-2006Q2:1.5.0.10 pkgsrc-2006Q2-base:1.5 pkgsrc-2006Q1:1.5.0.8 pkgsrc-2006Q1-base:1.5 pkgsrc-2005Q4:1.5.0.6 pkgsrc-2005Q4-base:1.5 pkgsrc-2005Q3:1.5.0.4 pkgsrc-2005Q3-base:1.5 pkgsrc-2005Q2:1.5.0.2 pkgsrc-2005Q2-base:1.5 pkgsrc-2005Q1:1.4.0.12 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.10 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.8 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.6 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.4 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.4.0.2 pkgsrc-2003Q4-base:1.4 netbsd-1-6-1:1.3.0.6 netbsd-1-6-1-base:1.3 netbsd-1-6:1.3.0.8 netbsd-1-6-RELEASE-base:1.3 pkgviews:1.3.0.4 pkgviews-base:1.3 buildlink2:1.3.0.2 buildlink2-base:1.3 netbsd-1-5-PATCH003:1.3 netbsd-1-5-PATCH001:1.3 netbsd-1-5-RELEASE:1.3 netbsd-1-4-PATCH003:1.3 netbsd-1-4-PATCH002:1.1.1.1 comdex-fall-1999:1.1.1.1 netbsd-1-4-PATCH001:1.1.1.1 netbsd-1-4-RELEASE:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.6 date 2009.11.26.17.04.19; author joerg; state dead; branches; next 1.5; 1.5 date 2005.05.29.14.38.33; author wiz; state Exp; branches; next 1.4; 1.4 date 2003.03.31.03.46.30; author jmc; state Exp; branches; next 1.3; 1.3 date 2000.06.16.23.40.17; author wiz; state Exp; branches; next 1.2; 1.2 date 2000.05.27.09.53.37; author wiz; state Exp; branches; next 1.1; 1.1 date 98.10.21.19.59.29; author garbled; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 98.10.21.19.59.29; author garbled; state Exp; branches; next ; desc @@ 1.6 log @Remove parallel/glunix. It fails in the patch phase on NetBSD 4 and later. After fixing that, it fails with C++ errors, so it couldn't have been build at least for 3 years. Assume noone cares. @ text @$NetBSD: patch-aj,v 1.5 2005/05/29 14:38:33 wiz Exp $ --- glunix/src/idle/didle_sysinfo.cc.orig 1997-09-18 21:04:55.000000000 +0200 +++ glunix/src/idle/didle_sysinfo.cc @@@@ -95,14 +95,34 @@@@ #include #include #include + +#ifdef __NetBSD__ +#include +#include +#include +#include +#include +#include +#if __NetBSD_Version__ < 104000200 +#include +#else /* moved to sys in 1.4.2 */ +#include +#endif +#include +#else #include #include #include #include #include +#endif + #include #include + +#ifndef __NetBSD__ #include // Contains defns for swap virtual memory info +#endif #include "clist.h" #include "cidle.h" @@@@ -120,12 +140,51 @@@@ #define LOADDOUBLE(la) ((double)(la) / FSCALE) #define HASH(x) ((x) >> 1) + +#ifdef __NetBSD__ +int getpsize() +{ + FILE *file; + char *buf; + + file = fopen("/kern/pagesize","r"); + fscanf(file,"%s",buf); + fclose(file); + return atoi(buf); +} +#define PAGETOK(size) (size) * getpsize() + +#else #define PAGETOK(size) (size) << 3 // 8K pages +#endif +#ifndef __NetBSD__ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) - +#endif /*****************************************************************************/ +#ifdef __NetBSD__ +static struct nlist nlst[] = { +#define X_CCPU 0 + { "_ccpu" }, /* 0 */ +#define X_CP_TIME 1 + { "_cp_time" }, /* 1 */ +#define X_HZ 2 + { "_hz" }, /* 2 */ +#define X_STATHZ 3 + { "_stathz" }, /* 3 */ +#define X_AVENRUN 4 + { "_averunnable" }, /* 4 */ +#define X_CNT 5 + { "_cnt" }, + + { 0 } +}; + +static ulong cp_time_offset,cnt_offset; + +#else + /* definitions for indices in the nlist array */ #define X_AVENRUN 0 #define X_MPID 1 @@@@ -165,11 +224,11 @@@@ static struct nlist nlst[] = // These are offsets into kmem for the stats we need static ulong avenrunOffset, availrmemOffset, anoninfoOffset, swapfsOffset; - +#endif /*****************************************************************************/ /* These two declarations are no longer necessary */ -#ifdef 0 +#if 0 static int cpuStates[NUM_CPUSTATES]; static int memoryStats[5]; static char *cpuStateNames[] = @@@@ -237,6 +296,45 @@@@ ReadKernelData(unsigned long addr, char * * Side effects: *****************************************************************************/ +#ifdef __NetBSD__ +Bool +Idle_InitializeSysinfo(void) +{ + int notFound; + int i; + + if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) { + kd = NULL; + perror("(dile)Idle_InitializeSysinfo: kvm_open"); + return -1; + } + /* get the list of symbols we want to access in the kernel */ + if ((notFound = kvm_nlist(kd, nlst)) < 0) { + fprintf(stderr, "res: nlist failed\n"); + return False; + } + numCpus=1; + cp_time_offset = nlst[X_CP_TIME].n_value; + cnt_offset = nlst[X_CNT].n_value; + + if (!(procdir = opendir(PROCFS))) { + (void) fprintf(stderr, "Unable to open %s\n", PROCFS); + return False; + } + /* handy for later on when we're reading it */ + if (chdir(PROCFS)) { + (void) fprintf(stderr, "Unable to chdir to %s\n", PROCFS); + return False; + } + + for (i = 0; i < USAGE_TABLE_SIZE; i++) { + procUsageTable[i].pid = -1; + procUsageTable[i].cpuUsage = 0.0; + } + + return True; +} +#else Bool Idle_InitializeSysinfo(void) { @@@@ -301,7 +399,7 @@@@ Idle_InitializeSysinfo(void) return True; } - +#endif /****************************************************************************** * Idle_CleanupSysinfo -- * Description of purpose and function of the procedure @@@@ -333,18 +431,30 @@@@ Idle_CleanupSysinfo(void) * * Side effects: *****************************************************************************/ +#ifdef __NetBSD__ +static ProcUsage * +FindEntry(pid_t pid, double usage) +#else static ProcUsage * FindEntry(struct prpsinfo *targProc, double usage) +#endif { int index, start; ProcUsage *candidate; +#ifdef __NetBSD__ + index = HASH(pid); +#else ASSERT(targProc != NULL); - index = HASH(targProc->pr_pid); +#endif start = index; while (1) { candidate = &(procUsageTable[index]); +#ifdef __NetBSD__ + if (candidate->pid == pid) { +#else if (candidate->pid == targProc->pr_pid) { +#endif /* Has this pid been recycled? Are we hitting a very old process? If so, then reset the entry */ if (usage < candidate->cpuUsage) { @@@@ -353,7 +463,11 @@@@ FindEntry(struct prpsinfo *targProc, dou return candidate; } if (candidate->pid == -1) { +#ifdef __NetBSD__ + candidate->pid = pid; +#else candidate->pid = targProc->pr_pid; +#endif candidate->cpuUsage = 0; return candidate; } @@@@ -379,10 +493,17 @@@@ FindEntry(struct prpsinfo *targProc, dou * * Side effects: *****************************************************************************/ + +#ifdef __NetBSD__ +static void +UpdateEntry(ProcUsage *entry, double usage) +{ +#else static void UpdateEntry(ProcUsage *entry, struct prpsinfo *proc, double usage) { UNUSED_PARAM(proc); +#endif ASSERT(entry != NULL); entry->cpuUsage = usage; } @@@@ -408,12 +529,24 @@@@ UpdateEntry(ProcUsage *entry, struct prp void Idle_GetSysInfo(Idle_Load *total, Idle_Load *seq, List_List *glunixProcs) { + +#ifndef __NetBSD__ struct prpsinfo currproc; /* pointer to current proc structure */ +#else + struct kinfo_proc *procs; + int mib[3],i; + size_t size; +#endif + +#ifndef __NetBSD__ int fd; +#endif int activeMemory[2]; int vmInUse[2]; int cpuUsage[2]; +#ifndef __NetBSD__ struct dirent *direntp; +#endif static struct timeval lastTime = {0, 0}; struct timeval currTime; double alpha, beta; @@@@ -459,6 +592,33 @@@@ Idle_GetSysInfo(Idle_Load *total, Idle_L vmInUse[TOTAL] = 0; vmInUse[SEQUENTIAL] = 0; cpuUsage[TOTAL] = 0; cpuUsage[SEQUENTIAL] = 0; numProcs = 0; + +#ifdef __NetBSD__ + size = 0; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ALL; + + sysctl(mib, 3, NULL, &size, NULL, 0); + procs = (struct kinfo_proc *)malloc(size); + sysctl(mib, 3, procs, &size, NULL, 0); + numProcs = size / sizeof(struct kinfo_proc); + + for (i=0; icpuUsage) / timeDiff; + UpdateEntry(oldProc, currUsage); + cpuUsage[TOTAL] += (int) (percentCpu * 10.0); + if (glunixProcs->KeySearch(procs[i].kp_proc.p_pid) == NULL) { + activeMemory[SEQUENTIAL] += procs[i].kp_eproc.e_xrssize; + vmInUse[SEQUENTIAL] += procs[i].kp_eproc.e_xsize; + cpuUsage[SEQUENTIAL] += (int) (percentCpu * 10.0); + } + } +#else rewinddir(procdir); while ((direntp = readdir(procdir)) != 0) { @@@@ -493,6 +653,7 @@@@ Idle_GetSysInfo(Idle_Load *total, Idle_L (void) close(fd); numProcs++; } +#endif total->mem = activeMemory[TOTAL]; total->cpu = cpuUsage[TOTAL]; seq->mem = activeMemory[SEQUENTIAL]; @@@@ -503,10 +664,21 @@@@ Idle_GetSysInfo(Idle_Load *total, Idle_L void Idle_GetSystemInfo(Idle_SystemLoad *sysLoad) { - struct anoninfo anoninfo; +#ifndef __NetBSD__ + int i; long avenrun[3]; + struct anoninfo anoninfo; int ani_max, ani_resv, availrmem, swapfs_minfree; +#else int i; + double avenrun[3]; + int mib[2]; + struct vmtotal total; + size_t sizeofvmtotal; + struct swapent *sep; + int totalsize, size, totalinuse, inuse, ncounted; + int rnswap, nswap; +#endif if (kd == NULL) { sysLoad->loadAvg[0] = 0; @@@@ -515,7 +687,48 @@@@ Idle_GetSystemInfo(Idle_SystemLoad *sysL sysLoad->memory = 0; return; } +#ifdef __NetBSD__ + getloadavg(avenrun,3); + for (i = 0; i < 3; i++) { + sysLoad->loadAvg[i] = avenrun[i]; + } + + sep = NULL; + do { + nswap = swapctl(SWAP_NSWAP, 0, 0); + if (nswap < 1) + break; + sep = (struct swapent *)malloc(nswap * sizeof(*sep)); + if (sep == NULL) + break; + rnswap = swapctl(SWAP_STATS, (void *)sep, nswap); + if (nswap != rnswap) + break; + + totalsize = totalinuse = ncounted = 0; + for (; rnswap-- > 0; sep++) { + ncounted++; + size = sep->se_nblks; + inuse = sep->se_inuse; + totalsize += size; + totalinuse += inuse; + } + + } while (0); + if (sep) + free(sep); + + sizeofvmtotal = sizeof(total); + mib[0] = CTL_VM; + mib[1] = VM_METER; + if (sysctl(mib, 2, &total, &sizeofvmtotal, NULL, 0) < 0) { + printf("Can't get vmtotals: %s\n", + strerror(errno)); + memset(&total, 0, sizeof(total)); + } + sysLoad->memory = PAGETOK(dbtob(totalsize) - dbtob(totalinuse) + total.t_free); +#else /* get load average array */ ReadKernelData(avenrunOffset, (char *) avenrun, sizeof (avenrun)); // @@@@ -539,6 +752,7 @@@@ Idle_GetSystemInfo(Idle_SystemLoad *sysL sysLoad->memory = PAGETOK(MAX(ani_max - ani_resv, 0) + availrmem - swapfs_minfree); +#endif return; } @ 1.5 log @Make build, install and deinstall on NetBSD-2.0/i386. @ text @d1 1 a1 1 $NetBSD: patch-aj,v 1.4 2003/03/31 03:46:30 jmc Exp $ @ 1.4 log @Lots of fixes (bad code in a lot of places) to make this compile and work @ text @d1 1 a1 1 $NetBSD: patch-aj,v 1.3 2000/06/16 23:40:17 wiz Exp $ d3 2 a4 2 --- glunix/src/idle/didle_sysinfo.cc.orig Thu Sep 18 19:04:55 1997 +++ glunix/src/idle/didle_sysinfo.cc Sun Mar 30 21:52:53 2003 d93 1 a93 1 @@@@ -165,11 +224,11 @@@@ d107 1 a107 1 @@@@ -237,6 +296,45 @@@@ d153 1 a153 1 @@@@ -301,7 +399,7 @@@@ d162 1 a162 1 @@@@ -333,18 +431,30 @@@@ d194 1 a194 1 @@@@ -353,7 +463,11 @@@@ d206 1 a206 1 @@@@ -379,10 +493,17 @@@@ d224 1 a224 1 @@@@ -408,12 +529,24 @@@@ d249 1 a249 1 @@@@ -459,6 +592,33 @@@@ d283 1 a283 1 @@@@ -493,6 +653,7 @@@@ d291 1 a291 1 @@@@ -503,10 +664,21 @@@@ d314 1 a314 1 @@@@ -515,7 +687,48 @@@@ d363 1 a363 1 @@@@ -539,6 +752,7 @@@@ @ 1.3 log @Apply patches provided in pkg/10355 by Gabriel Rosenkoetter . Also fix compilation on -current machines after removal of vm/vm_swap.h, and silence a compile time warning. @ text @d1 1 a1 1 $NetBSD$ d3 3 a5 3 --- glunix/src/idle/didle_sysinfo.cc.orig Thu Sep 18 21:04:55 1997 +++ glunix/src/idle/didle_sysinfo.cc Sat Jun 17 01:07:46 2000 @@@@ -95,14 +95,33 @@@@ d12 1 d40 1 a40 1 @@@@ -120,12 +139,51 @@@@ d93 1 a93 1 @@@@ -165,11 +223,11 @@@@ d107 1 a107 1 @@@@ -237,6 +295,45 @@@@ d153 1 a153 1 @@@@ -301,7 +398,7 @@@@ d162 1 a162 1 @@@@ -333,18 +430,30 @@@@ d194 1 a194 1 @@@@ -353,7 +462,11 @@@@ d206 1 a206 1 @@@@ -379,10 +492,17 @@@@ d224 1 a224 1 @@@@ -408,12 +528,24 @@@@ d249 1 a249 1 @@@@ -459,6 +591,33 @@@@ d283 1 a283 1 @@@@ -493,6 +652,7 @@@@ d291 1 a291 1 @@@@ -503,10 +663,21 @@@@ a300 1 - int i; d302 1 a302 1 + int i; d306 1 a306 1 + int sizeofvmtotal; d314 1 a314 1 @@@@ -515,7 +686,48 @@@@ d363 1 a363 1 @@@@ -539,6 +751,7 @@@@ @ 1.2 log @Use user/group instead of addnerd; while I'm here, make it compile again, and fix binary package. @ text @d4 2 a5 2 +++ glunix/src/idle/didle_sysinfo.cc Fri May 26 14:44:45 2000 @@@@ -95,14 +95,29 @@@@ d16 1 d18 3 d39 1 a39 1 @@@@ -120,12 +135,51 @@@@ d92 1 a92 1 @@@@ -165,11 +219,11 @@@@ d106 1 a106 1 @@@@ -237,6 +291,45 @@@@ d152 1 a152 1 @@@@ -301,7 +394,7 @@@@ d161 1 a161 1 @@@@ -333,18 +426,30 @@@@ d193 1 a193 1 @@@@ -353,7 +458,11 @@@@ d205 1 a205 1 @@@@ -379,10 +488,17 @@@@ d223 1 a223 1 @@@@ -408,12 +524,24 @@@@ d248 1 a248 1 @@@@ -459,6 +587,33 @@@@ d282 1 a282 1 @@@@ -493,6 +648,7 @@@@ d290 1 a290 1 @@@@ -503,10 +659,21 @@@@ d314 1 a314 1 @@@@ -515,7 +682,48 @@@@ d363 1 a363 1 @@@@ -539,6 +747,7 @@@@ @ 1.1 log @Initial revision @ text @d3 5 a7 3 --- glunix/src/idle/didle_sysinfo.cc~ Thu Sep 18 12:04:55 1997 +++ glunix/src/idle/didle_sysinfo.cc Fri Feb 27 06:42:28 1998 @@@@ -97,2 +97,12 @@@@ d20 3 a22 1 @@@@ -102,5 +112,10 @@@@ d33 5 a37 1 @@@@ -122,8 +137,47 @@@@ d86 5 a90 1 @@@@ -167,3 +221,3 @@@@ d95 10 a104 1 @@@@ -239,2 +293,41 @@@@ d146 5 a150 1 @@@@ -303,3 +396,3 @@@@ d155 5 a159 1 @@@@ -335,4 +428,9 @@@@ d169 1 a169 1 @@@@ -340,5 +438,8 @@@@ d179 1 a179 1 @@@@ -346,3 +447,7 @@@@ d187 5 a191 1 @@@@ -355,3 +460,7 @@@@ d199 5 a203 1 @@@@ -381,2 +490,8 @@@@ d212 2 a213 1 @@@@ -385,2 +500,3 @@@@ d217 5 a221 1 @@@@ -410,3 +526,11 @@@@ d232 1 d234 13 a246 1 @@@@ -461,2 +585,29 @@@@ d276 5 a280 1 @@@@ -495,2 +646,3 @@@@ d284 5 a288 1 @@@@ -505,6 +657,15 @@@@ d300 3 a302 1 + struct vmmeter sum; d308 5 a312 1 @@@@ -517,3 +678,37 @@@@ a320 1 + kvm_read(kd, cnt_offset, (int *)(&sum), sizeof(sum)); d346 9 a354 1 + sysLoad->memory = PAGETOK(dbtob(totalsize) - dbtob(totalinuse) + sum.v_free_count); d357 5 a361 1 @@@@ -541,2 +736,3 @@@@ d365 2 @ 1.1.1.1 log @Initial import of glunix-1.0a Thanks to Ross for all the help, and Alistair for fixing some brain damage. A Global Layer Unix for NOW. (Network Of Workstations) @ text @@