[Pkg-wmaker-commits] [wmbubble] 163/207: This patch adds several fixes to make wmbubble work on Debian GNU/kFreeBSD. In particular: - recognize GNU/kFreeBSD as an option in the Makefile - call init_stuff if __FreeBSD_kernel__ is defined instead of just __FreeBSD__ - use sysctl instead of kvm_read for system_cpu; inspired by FreeBSD patch for wmcube-gdk by KOIE Hidetaka (http://lists.freebsd.org/pipermail/ freebsd-ports-bugs/2008-January/135006.html)
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:18:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbubble.
commit 19794d24a76820147e711bdb68817af6d229487f
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Mon Jul 28 00:04:34 2014 -0500
This patch adds several fixes to make wmbubble work on Debian GNU/kFreeBSD.
In particular:
- recognize GNU/kFreeBSD as an option in the Makefile
- call init_stuff if __FreeBSD_kernel__ is defined instead of just __FreeBSD__
- use sysctl instead of kvm_read for system_cpu; inspired by FreeBSD patch for
wmcube-gdk by KOIE Hidetaka (http://lists.freebsd.org/pipermail/
freebsd-ports-bugs/2008-January/135006.html)
---
Makefile | 7 +++++++
bubblemon.c | 2 +-
include/sys_include.h | 4 ++++
sys_freebsd.c | 23 ++++++++++++++++-------
4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index bb1b4a4..fe52e4d 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,13 @@ ifeq ($(OS), FreeBSD)
INSTALL = -c -g kmem -m 2755 -o root
endif
+ifeq ($(OS), GNU/kFreeBSD)
+ OBJS += sys_freebsd.o
+ LIBS = -lX11 -lkvm -lm
+ INSTALL = -c -g kmem -m 2755 -o root
+ CFLAGS += -D_BSD_SOURCE
+endif
+
# special things for NetBSD
ifeq ($(OS), NetBSD)
OBJS += sys_netbsd.o
diff --git a/bubblemon.c b/bubblemon.c
index 1e51cae..ac0a516 100644
--- a/bubblemon.c
+++ b/bubblemon.c
@@ -404,7 +404,7 @@ int main(int argc, char **argv) {
argv++; argc--; /* Otherwise we'll make more of ourselves on a left click */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (init_stuff())
exit(-1);
#endif
diff --git a/include/sys_include.h b/include/sys_include.h
index c4812cc..da211c2 100644
--- a/include/sys_include.h
+++ b/include/sys_include.h
@@ -24,4 +24,8 @@ int system_cpu(void); /* return total CPU load in percent */
void system_memory(void); /* set memory related values in BubbleMonData */
void system_loadavg(void); /* get current load average and put into
bm->loadavg[].{i,f} */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+int init_stuff();
+#endif
+
#endif /* _SYS_INCLUDE_H_ */
diff --git a/sys_freebsd.c b/sys_freebsd.c
index a5098a8..1cf68f7 100644
--- a/sys_freebsd.c
+++ b/sys_freebsd.c
@@ -37,7 +37,6 @@ extern BubbleMonData bm;
static kvm_t *kd = NULL;
static struct nlist nlst[] = {
- {"_cp_time", 0},
{"_cnt", 0},
{"_bufspace", 0},
{0, 0}
@@ -67,7 +66,7 @@ int init_stuff()
kvm_nlist(kd, nlst);
- if (nlst[0].n_type == 0 || nlst[1].n_type == 0 || nlst[2].n_type == 0) {
+ if (nlst[0].n_type == 0 || nlst[1].n_type == 0) {
puts("Error extracting symbols");
return 2;
}
@@ -93,9 +92,19 @@ int system_cpu(void)
unsigned long int cpu_time[CPUSTATES];
int i;
- if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time))
- != sizeof(cpu_time))
- return 0;
+ static int mib[2];
+ size_t len = 2;
+
+ size_t size;
+
+ if (sysctlnametomib("kern.cp_time", mib, &len) < 0)
+ return 0;
+
+ size = sizeof (cpu_time);
+
+
+ if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
+ return 0;
load = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE];
total = load + cpu_time[CP_IDLE];
@@ -133,10 +142,10 @@ void system_memory(void)
static time_t last_time_swap = 0;
time_t curr_time;
- if (kvm_read(kd, nlst[1].n_value, &sum, sizeof(sum)) != sizeof(sum))
+ if (kvm_read(kd, nlst[0].n_value, &sum, sizeof(sum)) != sizeof(sum))
return; /* _cnt */
- if (kvm_read(kd, nlst[2].n_value, &bufspace, sizeof(bufspace)) !=
+ if (kvm_read(kd, nlst[1].n_value, &bufspace, sizeof(bufspace)) !=
sizeof(bufspace))
return; /* _bufspace */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbubble.git
More information about the Pkg-wmaker-commits
mailing list