summaryrefslogtreecommitdiff
path: root/x11/kdebase3/patches/patch-dd
blob: 9bac5e5537054c8384c16595e280d8512fabfb69 (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
74
75
$NetBSD: patch-dd,v 1.3 2002/08/25 19:23:45 jlam Exp $

--- ksysguard/ksysguardd/FreeBSD/Memory.c.orig	Fri Sep 14 22:11:20 2001
+++ ksysguard/ksysguardd/FreeBSD/Memory.c	Tue Aug 20 14:20:49 2002
@@ -32,7 +32,12 @@
 #include <sys/types.h>
 #include <sys/vmmeter.h>
 #include <unistd.h>
+/* Everything post 1.5.x uses uvm/uvm_* includes */
+#if __NetBSD_Version__ >= 105010000
+#include <uvm/uvm_param.h>
+#else
 #include <vm/vm_param.h>
+#endif
 
 #include "Command.h"
 #include "Memory.h"
@@ -77,6 +82,49 @@ exitMemory(void)
 int
 updateMemory(void)
 {
+#ifdef __NetBSD__
+#define ARRLEN(X) (sizeof(X)/sizeof(X[0]))
+	long pagesize; /* using a long promotes the arithmetic */
+	size_t len;
+
+	{	static int mib[]={ CTL_HW, HW_PHYSMEM };
+
+	len = sizeof(Total);
+		sysctl(mib, ARRLEN(mib), &Total, &len, NULL, 0);
+		Total >>= 10;
+	}
+
+	{	struct uvmexp x;
+		static int mib[] = { CTL_VM, VM_UVMEXP };
+
+		len = sizeof(x);
+		STotal = SUsed = SFree = -1;
+		pagesize = 1;
+		if (-1 < sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0)) {
+			pagesize = x.pagesize;
+			STotal = (pagesize*x.swpages) >> 10;
+			SUsed = (pagesize*x.swpginuse) >> 10;
+			SFree = STotal - SUsed;
+		}
+	}
+
+	/* can't find NetBSD filesystem buffer info */
+	Buffers = -1;
+
+	/* NetBSD doesn't know about vm.stats */
+	Cached = -1;
+
+	{	static int mib[]={ CTL_VM, VM_METER };
+		struct vmtotal x;
+
+		len = sizeof(x);
+		MFree = Used = -1;
+		if (sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0) > -1) {
+			MFree = (x.t_free * pagesize) >> 10;
+			Used = (x.t_rm * pagesize) >> 10;
+		}
+	}
+#else
 	int mib[2];
 	size_t len;
 	struct vmtotal p;
@@ -119,6 +167,7 @@ updateMemory(void)
 	sysctlbyname("vm.vmmeter", &p, &len, NULL, 0);
         MFree = p.t_free * getpagesize() / 1024;
         Used = p.t_arm * getpagesize() / 1024 + Buffers + Cached;
+#endif
 
 	return 0;
 }