d3a7ec4abc
Fallout from <sys/user.h> removal.
128 lines
3.3 KiB
Text
128 lines
3.3 KiB
Text
$NetBSD: patch-ai,v 1.5 2017/06/23 16:42:05 kamil Exp $
|
|
|
|
--- sysdeps/bsd/prockernel.c.orig 2011-06-01 15:40:47.000000000 +0000
|
|
+++ sysdeps/bsd/prockernel.c
|
|
@@ -30,7 +30,7 @@
|
|
#include <sys/param.h>
|
|
#include <sys/sysctl.h>
|
|
#include <sys/proc.h>
|
|
-#if (!defined __OpenBSD__) && (!defined __bsdi__)
|
|
+#if (!defined __OpenBSD__) && (!defined __bsdi__) && (!defined __NetBSD__)
|
|
#include <sys/user.h>
|
|
#endif
|
|
#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__)) && \
|
|
@@ -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 */
|
|
}
|