summaryrefslogtreecommitdiff
path: root/sysutils/xfce4-systemload-plugin/patches/patch-aa
blob: c0ce249532bf5afa17611ee3becda7d5a8692285 (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
$NetBSD: patch-aa,v 1.2 2005/09/27 12:49:08 martti Exp $

--- panel-plugin/memswap.c.orig	2003-11-06 02:39:52.000000000 +0200
+++ panel-plugin/memswap.c	2005-09-27 12:39:16.000000000 +0300
@@ -284,7 +284,24 @@
 
 #define ARRLEN(X) (sizeof(X)/sizeof(X[0]))
     {
-        static int mib[]={ CTL_HW, HW_PHYSMEM };
+        static int mib[2];
+
+#ifdef HW_PHYSMEM64
+        /* 64-bit datatype */
+        if (sizeof(size_t) == 8) {
+                mib[0] = CTL_HW;
+                mib[1] = HW_PHYSMEM64;
+        }
+        /* assume 32-bit datatype */
+        else {
+                mib[0] = CTL_HW;
+                mib[1] = HW_PHYSMEM;
+        }
+#else
+        mib[0] = CTL_HW;
+        mib[1] = HW_PHYSMEM;
+#endif
+
         len = sizeof(MTotal);
         sysctl(mib, ARRLEN(mib), &MTotal, &len, NULL, 0);
         MTotal >>= 10;
@@ -395,7 +412,24 @@
 
 #define ARRLEN(X) (sizeof(X)/sizeof(X[0]))
     {
-        static int mib[]={ CTL_HW, HW_PHYSMEM };
+        static int mib[2];
+
+#ifdef HW_PHYSMEM64
+        /* 64-bit datatype */
+        if (sizeof(size_t) == 8) {
+                mib[0] = CTL_HW;
+                mib[1] = HW_PHYSMEM64;
+        }
+        /* assume 32-bit datatype */
+        else {
+                mib[0] = CTL_HW;
+                mib[1] = HW_PHYSMEM;
+        }
+#else
+        mib[0] = CTL_HW;
+        mib[1] = HW_PHYSMEM;
+#endif
+
         len = sizeof(MTotal);
         sysctl(mib, ARRLEN(mib), &MTotal, &len, NULL, 0);
         MTotal >>= 10;