summaryrefslogtreecommitdiff
path: root/sysutils/torsmo/patches/patch-ae
blob: d7fb46472b55ad1f9744a8dbb5c790f9ea4b24ba (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
$NetBSD: patch-ae,v 1.1 2007/02/19 19:50:48 joerg Exp $

--- freebsd.c.orig	2007-02-19 19:26:16.000000000 +0000
+++ freebsd.c
@@ -13,7 +13,11 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/vmmeter.h>
+#ifdef __DragonFly__
+#include <kinfo.h>
+#else
 #include <sys/dkstat.h>
+#endif
 #include <unistd.h>
 #include <sys/user.h>
 #include <sys/socket.h>
@@ -251,6 +255,19 @@ long cpu_used, oldtotal, oldused;
 
 void update_cpu_usage() {
 	long used, total;
+#ifdef __DragonFly__
+	struct kinfo_cputime cp_time;
+	
+	if (kinfo_get_sched_cputime(&cp_time)) {
+		fprintf(stderr, "kinfo_get_sched_cputime failed");
+		return;
+	}
+	fresh.load[0] = cp_time.cp_user;
+	fresh.load[0] = cp_time.cp_nice;
+	fresh.load[0] = cp_time.cp_sys;
+	fresh.load[0] = cp_time.cp_idle;
+	fresh.load[0] = cp_time.cp_idle;	
+#else
 	long cp_time[CPUSTATES];
 	size_t len = sizeof(cp_time);
 
@@ -263,6 +280,7 @@ void update_cpu_usage() {
 	fresh.load[2] = cp_time[CP_SYS];
 	fresh.load[3] = cp_time[CP_IDLE];
 	fresh.load[4] = cp_time[CP_IDLE];
+#endif
 
 	used = fresh.load[0] + fresh.load[1] + fresh.load[2];
 	total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
@@ -345,3 +363,8 @@ char* get_acpi_ac_adapter(void) 
 char* get_acpi_fan() {
 	return "";
 }
+
+char * get_freq()
+{
+	return "";
+}