pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/45402: tmux-1.5 build on dragonfly
>Number: 45402
>Category: pkg
>Synopsis: tmux-1.5 build on dragonfly
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 26 10:25:00 +0000 2011
>Originator: Goetz Isenmann
>Release: DragonFly 2.11-DEVELOPMENT x86_64
>Organization:
>Environment:
DragonFly dfly-h64 2.11-DEVELOPMENT DragonFly v2.11.0.809.g7cbfd8-DEVELOPMENT
#4: Mon Sep 5 17:11:35 CEST 2011
isenmann@dfly-h64:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64
>Description:
Since tmux-1.5 the FreeBSD specific code (osdep-freebsd.c) is also
used for DragonFly, but struct kinfo_proc names have changed (2.8/i386
and 2.11/x86_64):
In file included from osdep-freebsd.c:20:
/usr/include/sys/proc.h:48:2: error: #error "Userland must include sys/user.h
instead of sys/proc.h"
In file included from /usr/include/sys/user.h:102,
from osdep-freebsd.c:23:
/usr/include/sys/kinfo.h:120: error: field 'kl_stat' has incomplete type
/usr/include/sys/kinfo.h:156: error: field 'kp_stat' has incomplete type
osdep-freebsd.c: In function 'cmp_procs':
osdep-freebsd.c:49: error: 'struct kinfo_proc' has no member named 'ki_stat'
osdep-freebsd.c:49: error: 'SRUN' undeclared (first use in this function)
osdep-freebsd.c:49: error: (Each undeclared identifier is reported only once
osdep-freebsd.c:49: error: for each function it appears in.)
osdep-freebsd.c:49: error: 'struct kinfo_proc' has no member named 'ki_stat'
osdep-freebsd.c:49: error: 'SIDL' undeclared (first use in this function)
osdep-freebsd.c:49: error: 'struct kinfo_proc' has no member named 'ki_stat'
...
...
>How-To-Repeat:
cd /usr/pkgsrc/misc/tmux && bmake
>Fix:
Below changes work for me. But I am not sure, if the result is
correct. I only changed names until it builds, but did not try to
verify, that the values and the logic is still valid.
Besides configure, also configure.ac should be changed, and I guess,
there should be a IS_DRAGONFLY added.
--- configure.orig 2011-08-23 12:56:30.216553000 +0200
+++ configure 2011-08-23 12:56:47.586820000 +0200
@@ -5642,11 +5642,16 @@
$as_echo "linux" >&6; }
PLATFORM=linux
;;
- *freebsd*|*dragonfly*)
+ *freebsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: freebsd" >&5
$as_echo "freebsd" >&6; }
PLATFORM=freebsd
;;
+ *dragonfly*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: dragonfly" >&5
+$as_echo "dragonfly" >&6; }
+ PLATFORM=dragonfly
+ ;;
*netbsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: netbsd" >&5
$as_echo "netbsd" >&6; }
--- /dev/null 2011-09-26 04:14:29.550505721 +0200
+++ osdep-dragonfly.c 2011-09-26 04:15:09.082158000 +0200
@@ -0,0 +1,136 @@
+/* $Id: osdep-freebsd.c 2553 2011-07-09 09:42:33Z tcunha $ */
+
+/*
+ * Copyright (c) 2009 Nicholas Marriott <nicm%users.sourceforge.net@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+#include <err.h>
+#include <errno.h>
+#include <event.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
+char *osdep_get_name(int, char *);
+struct event_base *osdep_event_init(void);
+
+#ifndef nitems
+#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
+#endif
+
+#define is_runnable(p) \
+ ((p)->kp_stat == SACTIVE || (p)->kp_stat == SIDL)
+#define is_stopped(p) \
+ ((p)->kp_stat == SSTOP || (p)->kp_stat == SZOMB)
+
+struct kinfo_proc *
+cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
+{
+ if (is_runnable(p1) && !is_runnable(p2))
+ return (p1);
+ if (!is_runnable(p1) && is_runnable(p2))
+ return (p2);
+
+ if (is_stopped(p1) && !is_stopped(p2))
+ return (p1);
+ if (!is_stopped(p1) && is_stopped(p2))
+ return (p2);
+
+ if (p1->kp_lwp.kl_estcpu > p2->kp_lwp.kl_estcpu)
+ return (p1);
+ if (p1->kp_lwp.kl_estcpu < p2->kp_lwp.kl_estcpu)
+ return (p2);
+
+ if (p1->kp_lwp.kl_slptime < p2->kp_lwp.kl_slptime)
+ return (p1);
+ if (p1->kp_lwp.kl_slptime > p2->kp_lwp.kl_slptime)
+ return (p2);
+
+ if (strcmp(p1->kp_comm, p2->kp_comm) < 0)
+ return (p1);
+ if (strcmp(p1->kp_comm, p2->kp_comm) > 0)
+ return (p2);
+
+ if (p1->kp_pid > p2->kp_pid)
+ return (p1);
+ return (p2);
+}
+
+char *
+osdep_get_name(int fd, char *tty)
+{
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PGRP, 0 };
+ struct stat sb;
+ size_t len;
+ struct kinfo_proc *buf, *newbuf, *bestp;
+ u_int i;
+ char *name;
+
+ buf = NULL;
+
+ if (stat(tty, &sb) == -1)
+ return (NULL);
+ if ((mib[3] = tcgetpgrp(fd)) == -1)
+ return (NULL);
+
+retry:
+ if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) == -1)
+ return (NULL);
+ len = (len * 5) / 4;
+
+ if ((newbuf = realloc(buf, len)) == NULL)
+ goto error;
+ buf = newbuf;
+
+ if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) == -1) {
+ if (errno == ENOMEM)
+ goto retry;
+ goto error;
+ }
+
+ bestp = NULL;
+ for (i = 0; i < len / sizeof (struct kinfo_proc); i++) {
+ if (buf[i].kp_tdev != sb.st_rdev)
+ continue;
+ if (bestp == NULL)
+ bestp = &buf[i];
+ else
+ bestp = cmp_procs(&buf[i], bestp);
+ }
+
+ name = NULL;
+ if (bestp != NULL)
+ name = strdup(bestp->kp_comm);
+
+ free(buf);
+ return (name);
+
+error:
+ free(buf);
+ return (NULL);
+}
+
+struct event_base *
+osdep_event_init(void)
+{
+ return (event_init());
+}
Home |
Main Index |
Thread Index |
Old Index