[Xfce4-commits] [apps/xfce4-taskmanager] 01/02: On OpenBSD, prefer the UVM way to the vmmeter one to get memory stats.
noreply at xfce.org
noreply at xfce.org
Sat Nov 29 10:33:53 CET 2014
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository apps/xfce4-taskmanager.
commit 9d85be60168df92b5738006c007a7d6386279d6c
Author: Martin Pieuchot <mpi at openbsd.org>
Date: Sat Nov 29 10:33:10 2014 +0100
On OpenBSD, prefer the UVM way to the vmmeter one to get memory stats.
---
src/task-manager-bsd.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c
index c34e1ad..1a336dd 100644
--- a/src/task-manager-bsd.c
+++ b/src/task-manager-bsd.c
@@ -215,11 +215,26 @@ gboolean get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system
gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 *swap_free)
{
+#ifdef __OpenBSD__
+ int mib[] = {CTL_VM, VM_UVMEXP};
+ struct uvmexp uvmexp;
+#else
int mib[] = {CTL_VM, VM_METER};
struct vmtotal vmtotal;
+#endif
struct swapent *swdev;
int nswap, i;
size_t size;
+#ifdef __OpenBSD__
+ size = sizeof(uvmexp);
+ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
+ errx(1,"failed to get vm.uvmexp");
+ /* cheat : rm = tot used, add free to get total */
+ *memory_total = pagetok(uvmexp.npages);
+ *memory_free = pagetok(uvmexp.free);
+ *memory_cache = 0;
+ *memory_buffers = pagetok(uvmexp.npages - uvmexp.free -uvmexp.active);
+#else
size = sizeof(vmtotal);
if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0)
errx(1,"failed to get vm.meter");
@@ -228,6 +243,7 @@ gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64
*memory_free = pagetok(vmtotal.t_free);
*memory_cache = 0;
*memory_buffers = pagetok(vmtotal.t_rm - vmtotal.t_arm);
+#endif
/* get swap stats */
if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list