summaryrefslogtreecommitdiff
path: root/sysutils/xfce4-cpugraph-plugin/patches/patch-ab
blob: da599560fa781afd25fbe5085b7488775bb586da (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
$NetBSD: patch-ab,v 1.2 2007/01/20 12:33:37 joerg Exp $

--- panel-plugin/os.c.orig	2004-06-07 01:16:30.000000000 +0000
+++ panel-plugin/os.c
@@ -63,6 +63,26 @@ long GetCPUUsage (int *oldusage, int *ol
 	
 	return usage;
 }
+#elif defined(__DragonFly__)
+long GetCPUUsage (int *oldusage, int *oldtotal)
+{
+	long used, total, usage;
+	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;
+	total = used + cp_time.cp_idle;
+	if (total != *oldtotal)
+		usage = 100 * (used - *oldusage + used / 2 - *oldusage / 2) / (total - *oldtotal);
+	else
+		usage = 0;
+	*oldusage = used;
+	*oldtotal = total;
+	return usage;
+}
 #elif defined (__NetBSD__)
 long GetCPUUsage (int *oldusage, int *oldtotal)
 {