summaryrefslogtreecommitdiff
path: root/net/upclient/patches/patch-ac
diff options
context:
space:
mode:
Diffstat (limited to 'net/upclient/patches/patch-ac')
-rw-r--r--net/upclient/patches/patch-ac56
1 files changed, 53 insertions, 3 deletions
diff --git a/net/upclient/patches/patch-ac b/net/upclient/patches/patch-ac
index 918dc8550eb..a2de2c3e4cc 100644
--- a/net/upclient/patches/patch-ac
+++ b/net/upclient/patches/patch-ac
@@ -1,9 +1,16 @@
-$NetBSD: patch-ac,v 1.6 2002/05/09 13:50:06 enami Exp $
+$NetBSD: patch-ac,v 1.7 2006/01/25 17:00:25 joerg Exp $
---- src/stats-bsd.c.orig Sun Jun 17 04:12:53 2001
+--- src/stats-bsd.c.orig 2001-06-16 19:12:53.000000000 +0000
+++ src/stats-bsd.c
-@@ -21,6 +21,9 @@
+@@ -18,9 +18,16 @@
+ #include <syslog.h>
+ #include <sys/time.h>
+ #include <sys/param.h>
++#if defined(__DragonFly__)
++#include <kinfo.h>
++#else
#include <sys/dkstat.h>
++#endif
#include <sys/sysctl.h>
#include <sys/utsname.h>
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 104000000
@@ -12,3 +19,46 @@ $NetBSD: patch-ac,v 1.6 2002/05/09 13:50:06 enami Exp $
/**
* @desc Get statistics
+@@ -75,6 +82,35 @@ void getstats(unsigned long *puptime, do
+ }
+
+ if(cfg_sendidle) {
++#if defined(__DragonFly__)
++ static int first_time = 1;
++ static struct kinfo_cputime scp;
++ struct kinfo_cputime cp;
++
++ if (first_time) {
++ first_time = 0;
++ if (kinfo_get_sched_cputime(&scp))
++ warn("kinfo_get_sched_cputime");
++ else
++ sleep(1); /* to avoid the initial 0 idle value */
++ }
++ if (kinfo_get_sched_cputime(&cp))
++ warn("kinfo_get_sched_cputime");
++ else {
++ double time = 0.0;
++ time += cp.cp_user - scp.cp_user;
++ time += cp.cp_nice - scp.cp_nice;
++ time += cp.cp_sys - scp.cp_sys;
++ time += cp.cp_intr - scp.cp_intr;
++ time += cp.cp_idle - scp.cp_idle;
++
++ if (time == 0.0)
++ time = 1.0;
++
++ *pidle = (cp.cp_idle - scp.cp_idle) * 100.0 / time;
++ scp = cp;
++ }
++#else
+ static kvm_t *kp;
+ static int initialized = 0;
+ static struct nlist namelist [] = {
+@@ -131,5 +167,6 @@ void getstats(unsigned long *puptime, do
+ } else {
+ cfg_sendidle = 0;
+ }
++#endif
+ }
+ }