pkgsrc/sysutils/libgtop/patches/patch-ai
drochner 4d7f1acf90 update to 2.20.0
This switches to the new gnome-2.20 branch.

pkgsrc notes:
-System dependant parts were reorganized upstream, in particular there
 if a subtree for FreeBSD now, and one for the other BSDs. I didn't
 pull in the DragonFly patches because I can't decide whether to base
 them on the freebsd or the rest.
-I've changed the NetBSD code to use kinfo_proc2 almost completely.
 Some vm statistics reporting might be less accurate now because
 some fields in proc2 seem to be unmaintained by the current kernel
 (eg ixrss).
-Also, some libgtop functions might be able to run in the non-privileged
 part now, but dealing with this would require even more #ifdefs, so
 we should consider setting up a private subtree as FreeBSD did.
-I didn't verify with older NetBSDs; kvm_getproc2() has been in the
 tree for quite some time so I hope it will just work without the need
 for excessive "#if __NetBSD_Version__ > t".
2007-11-05 19:06:02 +00:00

119 lines
3 KiB
Text

$NetBSD: patch-ai,v 1.4 2007/11/05 19:06:04 drochner Exp $
--- sysdeps/bsd/prockernel.c.orig 2007-04-27 00:27:34.000000000 +0200
+++ sysdeps/bsd/prockernel.c
@@ -45,6 +45,7 @@
#include <osreldate.h>
#endif
+#if 0
#ifdef __NetBSD__
#include <machine/vmparam.h>
#include <machine/pmap.h>
@@ -60,17 +61,22 @@
#define KERNBASE KERNEL_BASE
#endif
#endif
-
+#endif /* 0 */
static const unsigned long _glibtop_sysdeps_proc_kernel_pstats =
(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) +
-(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
-(1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
-(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT);
+(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT)
+#if !defined(__NetBSD__)
++ (1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
+(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT)
+#endif
+;
+#if !defined(__NetBSD__)
static const unsigned long _glibtop_sysdeps_proc_kernel_pcb =
(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) +
(1L << GLIBTOP_PROC_KERNEL_KSTK_ESP);
+#endif
static const unsigned long _glibtop_sysdeps_proc_kernel_wchan =
(1L << GLIBTOP_PROC_KERNEL_NWCHAN) +
@@ -82,7 +88,9 @@ void
_glibtop_init_proc_kernel_p (glibtop *server)
{
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
+#if !defined(__NetBSD__)
_glibtop_sysdeps_proc_kernel_pcb |
+#endif
_glibtop_sysdeps_proc_kernel_wchan;
}
@@ -91,12 +99,16 @@ glibtop_get_proc_kernel_p (glibtop *serv
glibtop_proc_kernel *buf,
pid_t pid)
{
+#if defined(__NetBSD__)
+ struct kinfo_proc2 *pinfo;
+#else
struct kinfo_proc *pinfo;
#if !(defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
struct user *u_addr = (struct user *)USRSTACK;
struct pstats pstats;
struct pcb pcb;
#endif
+#endif /* NetBSD */
int count;
char filename [BUFSIZ];
@@ -113,7 +125,12 @@ glibtop_get_proc_kernel_p (glibtop *serv
if (pid == 0) return;
/* Get the process information */
+#if defined(__NetBSD__)
+ pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ sizeof(*pinfo), &count);
+#else
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
+#endif
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
@@ -125,6 +142,10 @@ glibtop_get_proc_kernel_p (glibtop *serv
#define PROC_WMESG ki_wmesg
#define PROC_WMESG ki_wmesg
+#elif defined(__NetBSD__)
+
+/* nothing for now */
+
#else
#define PROC_WCHAN kp_proc.p_wchan
@@ -133,6 +154,21 @@ glibtop_get_proc_kernel_p (glibtop *serv
#endif
+#if defined(__NetBSD__)
+
+ buf->nwchan = pinfo[0].p_wchan;
+ if (pinfo[0].p_wchan && pinfo[0].p_wmesg)
+ g_strlcpy(buf->wchan, pinfo[0].p_wmesg,
+ sizeof buf->wchan);
+
+ buf->min_flt = pinfo[0].p_uru_minflt;
+ buf->maj_flt = pinfo[0].p_uru_majflt;
+
+ buf->flags |= (_glibtop_sysdeps_proc_kernel_wchan
+ | _glibtop_sysdeps_proc_kernel_pstats);
+
+#else
+
#if !defined(__NetBSD__) || !defined(SACTIVE)
buf->nwchan = (unsigned long) pinfo [0].PROC_WCHAN &~ KERNBASE;
@@ -267,4 +303,6 @@ glibtop_get_proc_kernel_p (glibtop *serv
*/
return;
#endif /* __FreeBSD__ */
+
+#endif /* NetBSD */
}