Author: Pino Toscano <toscano.pino@tiscali.it>
Description: Enable building on kFreeBSD
 Make use of the "freebsd" OS implementation, as the kernel is the same.
 .
 Also, provide build fixes for task-manager-freebsd.c:
 - include <sys/vmmeter.h>, needed with FreeBSD >= 9.0 (see also the upstream
   bug #8081)
 - NZERO is not provided by kfreebsd-kernel-headers, as already provided by
   limits.h but only when _XOPEN_SOURCE is requested (and it is not in this
   case); make use of sysconf to query that value instead
Last-Update: 2013-9-14
Forwarded: no

---
 configure.ac               |    2 +-
 src/task-manager-freebsd.c |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

--- a/configure.ac
+++ b/configure.ac
@@ -94,7 +94,7 @@ if test x"$ac_skel" = x"yes"; then
 	ac_os_implementation="skel"
 else
 	case "$target_os" in
-		freebsd*)
+		freebsd*|kfreebsd*-gnu)
 		ac_os_implementation="freebsd"
 		AC_CHECK_LIB([kvm], [kvm_openfiles])
 		AC_CHECK_HEADERS([fcntl.h kvm.h paths.h pwd.h sys/param.h sys/proc.h \
--- a/src/task-manager-freebsd.c
+++ b/src/task-manager-freebsd.c
@@ -18,6 +18,7 @@
 #include <fcntl.h>
 #include <paths.h>
 #include <unistd.h>
+#include <sys/vmmeter.h>
 
 #include <glib.h>
 
@@ -104,6 +105,7 @@ get_task_details (kvm_t *kd, struct kinf
 	struct passwd *pw;
 	char **argv;
 	int i;
+	long nzero = sysconf (_SC_NZERO);
 
 	task->pid = kp->ki_pid;
 	task->ppid = kp->ki_ppid;
@@ -168,9 +170,9 @@ get_task_details (kvm_t *kd, struct kinf
 	i++;
 	if (!(kp->ki_sflag & PS_INMEM))
 		task->state[i++] = 'W';
-	if (kp->ki_nice < NZERO)
+	if (kp->ki_nice < nzero)
 		task->state[i++] = '<';
-	else if (kp->ki_nice > NZERO)
+	else if (kp->ki_nice > nzero)
 		task->state[i++] = 'N';
 	if (kp->ki_flag & P_TRACED)
 		task->state[i++] = 'X';
