summaryrefslogtreecommitdiff
path: root/devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c
blob: 583d63e150aa9c2f58239ab7ae8985e8bce78354 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
$FreeBSD$

--- sysdeps/freebsd/proctime.c.orig	Thu Feb 15 01:48:46 2001
+++ sysdeps/freebsd/proctime.c	Tue Oct  2 10:58:26 2001
@@ -66,14 +66,17 @@
 {
 	quad_t totusec;
 	u_quad_t u, st, ut, it, tot;
-#if (__FreeBSD_version < 300003)
-        long sec, usec;
-#endif
         struct timeval tv;
 
+#if __FreeBSD_version < 500023
 	st = p->p_sticks;
 	ut = p->p_uticks;
 	it = p->p_iticks;
+#else
+	st = p->p_kse.ke_sticks;
+	ut = p->p_kse.ke_uticks;
+	it = p->p_kse.ke_iticks;
+#endif
 
 	tot = st + ut + it;
 	if (tot == 0) {
@@ -81,12 +84,7 @@
 		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.
-	 */
-
+#if (defined __FreeBSD__)
 	totusec = (u_quad_t) p->p_runtime;
 #else
 	sec = p->p_rtime.tv_sec;
@@ -157,10 +155,10 @@
 	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 +190,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) &&
@@ -222,6 +235,7 @@
 
 			buf->flags = _glibtop_sysdeps_proc_time_user;
 		}
+#endif
 
 	glibtop_suid_leave (server);
 #endif