On Fri, 2002-10-04 at 10:39, Lars Eggert wrote: > The Gupta Age wrote: > > Hi. > > > > I was trying to compile GNOME 2.0 on a freebsd current > > machine on which the world was recently cvsuped, built > > and installed. CVSUP-ed on 09/22/2002 > > > > the gnome compilation breaks while trying to compile > > libgtop2. here is the error: > > I ran into the same problem last week. Check the archives for the > "sys/sys/proc.h 1.250 breaks devel/libgtop2 port" thread, it has some > fixes in its replies.
Okay, I'm back from vacation, here are the patches. These will be committed when the ports freeze lifts. Thanks goes to julian for pointing me to using a pure libkvm solution. Joe > > Lars > -- > Lars Eggert <[EMAIL PROTECTED]> USC Information Sciences Institute -- PGP Key : http://www.marcuscom.com/pgp.asc
--- sysdeps/freebsd/proctime.c.orig Mon Jun 10 17:34:42 2002 +++ sysdeps/freebsd/proctime.c Wed Oct 2 21:18:38 2002 @@ -57,6 +57,7 @@ * system, and interrupt time usage. */ +#ifndef __FreeBSD__ static void calcru(p, up, sp, ip) struct proc *p; @@ -66,9 +67,6 @@ { quad_t totusec; u_quad_t u, st, ut, it, tot; -#if (__FreeBSD_version < 300003) - long sec, usec; -#endif struct timeval tv; st = p->p_sticks; @@ -81,19 +79,10 @@ tot = 1; } -#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) - - /* This was changed from a `struct timeval' into a `u_int64_t' - * on FreeBSD 3.0 and renamed p_rtime -> p_runtime. - */ - - totusec = (u_quad_t) p->p_runtime; -#else sec = p->p_rtime.tv_sec; usec = p->p_rtime.tv_usec; totusec = (quad_t)sec * 1000000 + usec; -#endif if (totusec < 0) { /* XXX no %qd in kernel. Truncate. */ @@ -116,6 +105,7 @@ ip->tv_usec = it % 1000000; } } +#endif /* Provides detailed information about a process. */ @@ -142,25 +132,25 @@ /* It does not work for the swapper task. */ if (pid == 0) return; -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) +#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)) if (server->sysdeps.proc_time == 0) return; +#endif #ifndef __bsdi__ sprintf (filename, "/proc/%d/mem", (int) pid); if (stat (filename, &statb)) return; #endif -#endif /* Get the process information */ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count); if ((pinfo == NULL) || (count != 1)) glibtop_error_io_r (server, "kvm_getprocs (%d)", pid); -#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003) - buf->rtime = pinfo [0].kp_proc.p_runtime; +#if (defined __FreeBSD__) && (__FreeBSD_version >= 500013) + buf->rtime = pinfo [0].ki_runtime; #else - buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime); + buf->rtime = pinfo [0].kp_proc.p_runtime; #endif buf->frequency = 1000000; @@ -192,6 +182,21 @@ buf->flags |= _glibtop_sysdeps_proc_time_user; #else +#if __FreeBSD_version >= 500013 +#if __FreeBSD_version >= 500016 + if ((pinfo [0].ki_flag & PS_INMEM)) { +#else + if ((pinfo [0].ki_flag & P_INMEM)) { +#endif + buf->utime = pinfo [0].ki_runtime; + buf->stime = 0; /* XXX */ + buf->cutime = tv2sec (pinfo [0].ki_childtime); + buf->cstime = 0; /* XXX */ + buf->start_time = tv2sec (pinfo [0].ki_start); + buf->flags = _glibtop_sysdeps_proc_time_user; + } + +#else glibtop_suid_enter (server); if ((pinfo [0].kp_proc.p_flag & P_INMEM) && @@ -199,29 +204,16 @@ (unsigned long) &u_addr->u_stats, (char *) &pstats, sizeof (pstats)) == sizeof (pstats)) { - /* This is taken form the kernel source code of - * FreeBSD 2.2.6. */ - - /* Well, we just do the same getrusage () does ... */ - - register struct rusage *rup; - - glibtop_suid_leave (server); - - rup = &pstats.p_ru; - calcru(&(pinfo [0]).kp_proc, - &rup->ru_utime, &rup->ru_stime, NULL); - - buf->utime = tv2sec (pstats.p_ru.ru_utime); - buf->stime = tv2sec (pstats.p_ru.ru_stime); - - buf->cutime = tv2sec (pstats.p_cru.ru_utime); - buf->cstime = tv2sec (pstats.p_cru.ru_stime); - - buf->start_time = tv2sec (pstats.p_start); + buf->utime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_utime); + buf->stime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_stime); + buf->cutime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_utime); + buf->cstime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_stime); + buf->start_time = tv2sec (pinfo[0].kp_eproc.e_stats.p_start); buf->flags = _glibtop_sysdeps_proc_time_user; + glibtop_suid_leave (server); } +#endif glibtop_suid_leave (server); #endif
--- sysdeps/freebsd/procmap.c.orig Mon Jun 10 17:34:42 2002 +++ sysdeps/freebsd/procmap.c Fri Sep 20 16:10:37 2002 @@ -33,7 +33,11 @@ #include <sys/proc.h> #include <sys/resource.h> #include <vm/vm_object.h> +#if (__FreeBSD_version >= 400011) +#include <vm/vm.h> +#else #include <vm/vm_prot.h> +#endif #include <vm/vm_map.h> #include <sys/vnode.h> @@ -92,7 +96,6 @@ #if defined __FreeBSD__ struct vnode vnode; struct inode inode; - struct mount mount; #endif int count, i = 0; int update = 0; @@ -114,7 +117,11 @@ /* Now we get the memory maps. */ if (kvm_read (server->machine.kd, +#if (__FreeBSD_version >= 500013) + (unsigned long) pinfo [0].ki_vmspace, +#else (unsigned long) pinfo [0].kp_proc.p_vmspace, +#endif (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) glibtop_error_io_r (server, "kvm_read (vmspace)"); @@ -244,18 +251,17 @@ &vnode, sizeof (vnode)) != sizeof (vnode)) glibtop_error_io_r (server, "kvm_read (vnode)"); +#if __FreeBSD_version > 500039 + if ((vnode.v_type != VREG) || strcmp("ufs", vnode.v_tag) || +#else if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) || +#endif !vnode.v_data) continue; if (kvm_read (server->machine.kd, (unsigned long) vnode.v_data, &inode, sizeof (inode)) != sizeof (inode)) glibtop_error_io_r (server, "kvm_read (inode)"); - - if (kvm_read (server->machine.kd, - (unsigned long) vnode.v_mount, - &mount, sizeof (mount)) != sizeof (mount)) - glibtop_error_io_r (server, "kvm_read (mount)"); maps [i-1].inode = inode.i_number; maps [i-1].device = inode.i_dev;