2007-04-12 11:55:08 +02:00
|
|
|
$NetBSD: patch-ab,v 1.2 2007/04/12 09:55:17 martti Exp $
|
2007-01-19 17:28:15 +01:00
|
|
|
|
2007-04-12 11:55:08 +02:00
|
|
|
--- panel-plugin/cpu.c.orig 2007-01-17 18:01:09.000000000 +0000
|
|
|
|
+++ panel-plugin/cpu.c 2007-01-23 21:46:41.000000000 +0000
|
|
|
|
@@ -78,6 +78,31 @@
|
2007-01-19 17:28:15 +01:00
|
|
|
return cpu_used;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#elif defined(__DragonFly__)
|
|
|
|
+#include <kinfo.h>
|
|
|
|
+
|
|
|
|
+static struct kinfo_cputime old_cp_time;
|
|
|
|
+
|
|
|
|
+gulong read_cpuload()
|
|
|
|
+{
|
|
|
|
+ gulong used, total;
|
|
|
|
+ struct kinfo_cputime cp_time;
|
|
|
|
+
|
|
|
|
+ if (kinfo_get_sched_cputime(&cp_time) < 0) {
|
|
|
|
+ g_warning("kinfo_get_sched_cputime failed");
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ used = cp_time.cp_user + cp_time.cp_nice + cp_time.cp_sys;
|
|
|
|
+ used -= old_cp_time.cp_user + old_cp_time.cp_nice + old_cp_time.cp_sys;
|
|
|
|
+ total = used + cp_time.cp_idle - old_cp_time.cp_idle;
|
|
|
|
+ old_cp_time = cp_time;
|
|
|
|
+
|
|
|
|
+ if (total)
|
|
|
|
+ return 100 * (used + used / 2) / total;
|
|
|
|
+ else
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
|
|
|
|
#include <osreldate.h>
|