$NetBSD: patch-ad,v 1.5 2000/08/18 22:43:53 christos Exp $ --- bsd/kernel.cc.orig Tue Feb 16 09:09:21 1999 +++ bsd/kernel.cc Fri Aug 18 18:36:14 2000 @@ -30,6 +30,10 @@ #include #include /* For CPUSTATES, which tells us how many cpu states there are. */ +#if defined(XOSVIEW_NETBSD) && !defined(CPUSTATES) +#include +#endif + #ifndef XOSVIEW_FREEBSD #include /* For disk statistics. */ #endif @@ -60,14 +64,22 @@ #include #include #include +#if defined(__NetBSD_Version__) && __NetBSD_Version__ > 105010000 /* > 1.5A */ +#include +#else #include /* XXX Is this needed? */ +#endif #else #include /* For struct vmmeter. */ #endif #ifdef HAVE_SWAPCTL #include /* For swapctl proto. */ -#include /* For swapent, SWAP_*. */ +#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104000000 +#include /* For swapent, SWAP_*. */ +#else +#include +#endif #include /* For malloc(), free(). */ #endif @@ -85,7 +97,11 @@ // This struct has the list of all the symbols we want from the kernel. static struct nlist nlst[] = { +#if defined(__NetBSD_Version__) && __NetBSD_Version__ > 104260000 /* > 1.4Z */ +{ "_ifnet" }, /* XXX: LZ! Don't renumber */ +#else { "_cp_time" }, +#endif #define CP_TIME_SYM_INDEX 0 { "_ifnet" }, #define IFNET_SYM_INDEX 1 @@ -293,7 +309,21 @@ if (!timeArray) errx (-1, "BSDGetCPUTimes(): passed pointer was null!\n"); if (CPUSTATES != 5) errx (-1, "Error: xosview for *BSD expects 5 cpu states!\n"); +#if defined(__NetBSD_Version__) && __NetBSD_Version__ > 104260000 /* > 1.4Z */ + int mib[2]; + struct schedstate_percpu ssp; + size_t size = sizeof(ssp.spc_cp_time); + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + if (sysctl(mib, 2, ssp.spc_cp_time, &size, NULL, 0) < 0) { + printf("can't get schedstate_percpu: %s\n", strerror(errno)); + memset(&ssp, 0, sizeof(ssp)); + } + for (size = 0; size < CPUSTATES; size++) + timeArray[size] = (long) ssp.spc_cp_time[size]; +#else safe_kvm_read_symbol (CP_TIME_SYM_INDEX, timeArray, sizeof (long) * CPUSTATES); +#endif }