$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 #endif +#if 0 #ifdef __NetBSD__ #include #include @@ -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 */ }