aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
authortobik <tobik@FreeBSD.org>2019-01-08 23:30:14 +0800
committertobik <tobik@FreeBSD.org>2019-01-08 23:30:14 +0800
commit494d52b290d94f58fb857dc5cbff5b8f0629b14b (patch)
treed34a60fbff7bcda964f39e7ecf21fbccea81223b /sysutils
parent2624b40f61f3ecf429a74c9cc8924960950d8c57 (diff)
downloadfreebsd-ports-gnome-494d52b290d94f58fb857dc5cbff5b8f0629b14b.tar.gz
freebsd-ports-gnome-494d52b290d94f58fb857dc5cbff5b8f0629b14b.tar.zst
freebsd-ports-gnome-494d52b290d94f58fb857dc5cbff5b8f0629b14b.zip
sysutils/htop: Fix memory display in the header
On amd64 it works correctly, but it breaks on powerpc, due to using types with the wrong size when requesting various sysctls. PR: 234357 Submitted by: tobik Approved by: Hung-Yi Chen <gaod@hychen.org> (maintainer timeout, 2 weeks)
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/htop/Makefile1
-rw-r--r--sysutils/htop/files/patch-freebsd_FreeBSDProcessList.c67
2 files changed, 68 insertions, 0 deletions
diff --git a/sysutils/htop/Makefile b/sysutils/htop/Makefile
index 8adb52e4d981..53c216fd9cd6 100644
--- a/sysutils/htop/Makefile
+++ b/sysutils/htop/Makefile
@@ -3,6 +3,7 @@
PORTNAME= htop
DISTVERSION= 2.2.0
+PORTREVISION= 1
CATEGORIES= sysutils
MAINTAINER= gaod@hychen.org
diff --git a/sysutils/htop/files/patch-freebsd_FreeBSDProcessList.c b/sysutils/htop/files/patch-freebsd_FreeBSDProcessList.c
new file mode 100644
index 000000000000..2e98d6517454
--- /dev/null
+++ b/sysutils/htop/files/patch-freebsd_FreeBSDProcessList.c
@@ -0,0 +1,67 @@
+Fix memory display in the header on FreeBSD/powerpc
+
+https://github.com/hishamhm/htop/pull/871
+
+--- freebsd/FreeBSDProcessList.c.orig 2018-04-10 13:42:59 UTC
++++ freebsd/FreeBSDProcessList.c
+@@ -296,31 +296,46 @@ static inline void FreeBSDProcessList_scanMemoryInfo(P
+ //
+ // htop_used = active + (wired - arc)
+ // htop_cache = buffers + cache + arc
+- size_t len = sizeof(pl->totalMem);
++ u_long totalMem;
++ u_int memActive, memWire, cachedMem;
++ long buffersMem;
++ uint64_t memZfsArc;
++ size_t len;
+
+ //disabled for now, as it is always smaller than phycal amount of memory...
+ //...to avoid "where is my memory?" questions
+ //sysctl(MIB_vm_stats_vm_v_page_count, 4, &(pl->totalMem), &len, NULL, 0);
+ //pl->totalMem *= pageSizeKb;
+- sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0);
+- pl->totalMem /= 1024;
++ len = sizeof(totalMem);
++ sysctl(MIB_hw_physmem, 2, &(totalMem), &len, NULL, 0);
++ totalMem /= 1024;
++ pl->totalMem = totalMem;
+
+- sysctl(MIB_vm_stats_vm_v_active_count, 4, &(fpl->memActive), &len, NULL, 0);
+- fpl->memActive *= pageSizeKb;
++ len = sizeof(memActive);
++ sysctl(MIB_vm_stats_vm_v_active_count, 4, &(memActive), &len, NULL, 0);
++ memActive *= pageSizeKb;
++ fpl->memActive = memActive;
+
+- sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(fpl->memWire), &len, NULL, 0);
+- fpl->memWire *= pageSizeKb;
++ len = sizeof(memWire);
++ sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(memWire), &len, NULL, 0);
++ memWire *= pageSizeKb;
++ fpl->memWire = memWire;
+
+- sysctl(MIB_vfs_bufspace, 2, &(pl->buffersMem), &len, NULL, 0);
+- pl->buffersMem /= 1024;
++ len = sizeof(buffersMem);
++ sysctl(MIB_vfs_bufspace, 2, &(buffersMem), &len, NULL, 0);
++ buffersMem /= 1024;
++ pl->buffersMem = buffersMem;
+
+- sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
+- pl->cachedMem *= pageSizeKb;
++ len = sizeof(cachedMem);
++ sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(cachedMem), &len, NULL, 0);
++ cachedMem *= pageSizeKb;
++ pl->cachedMem = cachedMem;
+
+ if (fpl->zfsArcEnabled) {
+- len = sizeof(fpl->memZfsArc);
+- sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(fpl->memZfsArc), &len , NULL, 0);
+- fpl->memZfsArc /= 1024;
++ len = sizeof(memZfsArc);
++ sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(memZfsArc), &len , NULL, 0);
++ memZfsArc /= 1024;
++ fpl->memZfsArc = memZfsArc;
+ fpl->memWire -= fpl->memZfsArc;
+ pl->cachedMem += fpl->memZfsArc;
+ // maybe when we learn how to make custom memory meter