pkgsrc/devel/libgtop/patches/patch-al
2001-08-10 10:48:13 +00:00

97 lines
2.8 KiB
Text

$NetBSD: patch-al,v 1.13 2001/08/10 10:48:13 martin Exp $
--- sysdeps/freebsd/prockernel.c.orig Sat Oct 16 20:31:43 1999
+++ sysdeps/freebsd/prockernel.c Fri Aug 10 12:38:19 2001
@@ -34,7 +34,7 @@
#if (!defined __OpenBSD__) && (!defined __bsdi__)
#include <sys/user.h>
#endif
-#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__))
+#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__)) && !defined(__NetBSD__)
#include <machine/pcb.h>
#endif
#if defined(__FreeBSD__) && !defined(__alpha__)
@@ -48,6 +48,14 @@
#include <osreldate.h>
#endif
+#ifdef __NetBSD__
+#include <machine/vmparam.h>
+#include <machine/pmap.h>
+#ifdef __arm32__
+#define KERNBASE KERNEL_BASE
+#endif
+#endif
+
static const unsigned long _glibtop_sysdeps_proc_kernel_pstats =
(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) +
(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
@@ -129,8 +137,15 @@
glibtop_suid_enter (server);
+#ifdef __NetBSD__
+ /* On NetBSD, there is no kvm_uread(), and kvm_read() always reads
+ * from kernel memory. */
+
+ if (kvm_read (server->machine.kd,
+#else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
+#endif
(unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats))
{
@@ -149,8 +164,12 @@
buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
}
+#ifdef __NetBSD__
+ if (kvm_read (server->machine.kd,
+#else
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
+#endif
(unsigned long) &u_addr->u_pcb,
(char *) &pcb, sizeof (pcb)) == sizeof (pcb))
{
@@ -167,14 +186,39 @@
/*xxx FreeBSD/Alpha? */
#endif
#else
+#ifdef __i386__
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
#ifdef __bsdi__
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
#else
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
#endif
+#else
+#if defined(__NetBSD__)
+#if defined(__m68k__)
+ buf->kstk_esp = (u_int64_t) pcb.pcb_usp;
+ buf->kstk_eip = (u_int64_t) 0;
+#elif (defined(__arm32__) || defined(__powerpc__))
+ buf->kstk_esp = (u_int64_t) pcb.pcb_sp;
+ buf->kstk_eip = (u_int64_t) 0;
+#elif defined(__mipsel__)
+ buf->kstk_esp = (u_int64_t) pcb.pcb_context[8];
+ buf->kstk_eip = (u_int64_t) 0;
+#elif defined(__sparc__)
+ buf->kstk_esp = (u_int64_t) pcb.pcb_sp;
+ buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
+#elif defined(__alpha__)
+ buf->kstk_esp = (u_int64_t) pcb.pcb_context[9];
+ buf->kstk_eip = (u_int64_t) pcb.pcb_context[8];
+#else
+ /* provide some defaults for other platforms */
+ buf->kstk_esp = (u_int64_t) 0;
+ buf->kstk_eip = (u_int64_t) 0;
+#endif /* ${MACHINE_ARCH} */
+#endif /* __NetBSD__ */
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
+#endif
#endif
}