summaryrefslogtreecommitdiff
path: root/sysutils/xosview/patches/patch-ad
blob: b3c1f256b1782d70f6c8a3874dbac9424f95e318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$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 <errno.h>
 #include <sys/dkstat.h>         /*  For CPUSTATES, which tells us how
                                       many cpu states there are.  */
+#if defined(XOSVIEW_NETBSD) && !defined(CPUSTATES)
+#include <sys/sched.h>
+#endif
+
 #ifndef XOSVIEW_FREEBSD
 #include <sys/disk.h>		/*  For disk statistics.  */
 #endif
@@ -60,14 +64,22 @@
 #include <sys/malloc.h>
 #include <sys/sysctl.h>
 #include <sys/device.h>
+#if defined(__NetBSD_Version__) && __NetBSD_Version__ > 105010000 /* > 1.5A */
+#include <uvm/uvm.h>
+#else
 #include <vm/vm.h>	/* XXX  Is this needed?  */
+#endif
 #else
 #include <sys/vmmeter.h>	/*  For struct vmmeter.  */
 #endif
 
 #ifdef HAVE_SWAPCTL
 #include <unistd.h>		/*  For swapctl proto.  */
-#include <vm/vm_swap.h>		/*  For swapent, SWAP_*.  */
+#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104000000
+#include <sys/swap.h>		/*  For swapent, SWAP_*.  */
+#else
+#include <vm/vm_swap.h>
+#endif
 #include <stdlib.h>		/*  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
 }