69 lines
1.7 KiB
Text
69 lines
1.7 KiB
Text
$NetBSD: patch-ae,v 1.2 2010/10/31 23:38:32 wiz Exp $
|
|
|
|
--- freebsd.c.orig 2004-08-25 18:24:24 +0200
|
|
+++ freebsd.c 2010-10-31 18:52:50 +0100
|
|
@@ -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>
|
|
@@ -229,11 +233,15 @@ void update_running_processes() {
|
|
if (kd != NULL) {
|
|
p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
|
|
for (i = 0; i<n_processes; i++) {
|
|
+#ifdef __DragonFly__
|
|
+ if (p[i].kp_stat == LSRUN)
|
|
+#else
|
|
#if __FreeBSD__ < 5
|
|
if (p[i].kp_proc.p_stat == SRUN)
|
|
#else
|
|
if (p[i].ki_stat == SRUN)
|
|
#endif
|
|
+#endif /* __DragonFly__ */
|
|
cnt++;
|
|
}
|
|
} else
|
|
@@ -251,6 +259,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[1] = cp_time.cp_nice;
|
|
+ fresh.load[2] = cp_time.cp_sys;
|
|
+ fresh.load[3] = cp_time.cp_idle;
|
|
+ fresh.load[4] = cp_time.cp_idle;
|
|
+#else
|
|
long cp_time[CPUSTATES];
|
|
size_t len = sizeof(cp_time);
|
|
|
|
@@ -263,6 +284,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 +367,8 @@ char* get_acpi_ac_adapter(void)
|
|
char* get_acpi_fan() {
|
|
return "";
|
|
}
|
|
+
|
|
+char * get_freq()
|
|
+{
|
|
+ return "";
|
|
+}
|