diff options
| author | OBATA Akio <obache@wizdas.com> | 2022-01-11 18:51:50 +0900 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2026-02-18 23:02:53 +0300 |
| commit | 05e4b489d1fd3e2c91138138959b289feaa169ef (patch) | |
| tree | fb8ab182576cc14c887287186154ba9c03b5efe6 /kicker-applets/ktimemon/sample.cpp | |
| parent | acc515eca323e5276aed2cdc06d974a9f40bb6f4 (diff) | |
| download | tdeaddons-05e4b489d1fd3e2c91138138959b289feaa169ef.tar.gz tdeaddons-05e4b489d1fd3e2c91138138959b289feaa169ef.zip | |
kicker-applets: Add NetBSD support for KTimemon
Signed-off-by: OBATA Akio <obache@wizdas.com>
Diffstat (limited to 'kicker-applets/ktimemon/sample.cpp')
| -rw-r--r-- | kicker-applets/ktimemon/sample.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/kicker-applets/ktimemon/sample.cpp b/kicker-applets/ktimemon/sample.cpp index a57a7c6..3ff9dec 100644 --- a/kicker-applets/ktimemon/sample.cpp +++ b/kicker-applets/ktimemon/sample.cpp @@ -31,6 +31,12 @@ #include <sys/swap.h> #endif +#ifdef __NetBSD__ +#include <sys/sysctl.h> +#include <sys/sched.h> +#include <uvm/uvm_extern.h> +#endif + #include <tqwidget.h> #include <tdelocale.h> #include <tdemessagebox.h> @@ -381,6 +387,60 @@ void KSample::readSample() free(stbl); } +#elif defined(__NetBSD__) + int mib[2]; + int ncpu; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(ncpu); + if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) { + fatal(i18n("Unable to get the number of CPUs configured.\n" + "The diagnostics are '%1'.\n" + "Please contact the maintainer at http://bugs.trinitydesktop.org/ who will try to sort this out.").arg(strerror(errno))); + } else { + sample.cpus = ncpu; + } + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + uint64_t cp_time[CPUSTATES]; + len = sizeof(cp_time); + if (sysctl(mib, 2, cp_time, &len, NULL, 0) < 0) { + fatal(i18n("Unable to get CPUSTATES.\n" + "The diagnostics are '%1'.\n" + "Please contact the maintainer at http://bugs.trinitydesktop.org/ who will try to sort this out.").arg(strerror(errno))); + } else { + sample.user = cp_time[CP_USER]; + sample.nice = cp_time[CP_NICE]; + sample.kernel = cp_time[CP_SYS]; + sample.iowait = cp_time[CP_INTR]; + sample.idle = cp_time[CP_IDLE]; + } + + mib[0] = CTL_VM; + mib[1] = VM_UVMEXP2; + + struct uvmexp_sysctl u; + len = sizeof(u); + if (sysctl(mib, 2, &u, &len, NULL, 0) < 0) { + fatal(i18n("Unable to get system wide vertual memory statistics.\n" + "The diagnostics are '%1'.\n" + "Please contact the maintainer at http://bugs.trinitydesktop.org/ who will try to sort this out.").arg(strerror(errno))); + } else { + pg_to_mb_shift = 20 - u.pageshift; + sample.mtotal = u.npages; + sample.free = u.free; + sample.buffers = u.filepages; + sample.cached = u.anonpages + u.execpages; + sample.mkernel = u.wired; + sample.stotal = u.swpages; + sample.sused = u.swpginuse; + sample.sfree = u.swpages - u.swpginuse; + } + + #else #warning This type of system is not supported sample.stotal = sample.sfree = 0; @@ -406,6 +466,8 @@ inline void KSample::makeMBytes(unsigned long &v) v /= 1024; // can it be simpler ;-) #elif defined(USE_SOLARIS) v /= pagesPerMB; +#elif defined(__NetBSD__) + v >>= pg_to_mb_shift; #endif } |
