blob: 0979be7525ca780c648db1b9039cc049a3e11558 (
plain)
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
|
$NetBSD: patch-as,v 1.1 2001/07/17 10:48:06 wiz Exp $
--- sysdeps/freebsd/uptime.c.orig Thu May 27 16:04:16 1999
+++ sysdeps/freebsd/uptime.c
@@ -49,6 +49,27 @@
void
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
{
+#ifdef __NetBSD__
+ time_t now;
+ time_t uptime;
+ int mib[2];
+ struct timeval boottime;
+ size_t size;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_BOOTTIME;
+ size = sizeof(boottime);
+ if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
+ boottime.tv_sec != 0) {
+ time(&now);
+ buf->uptime = now - boottime.tv_sec;
+ /* XXX: don't know a useful value to put here. */
+ buf->idletime = 0;
+ buf->flags = _glibtop_sysdeps_uptime;
+ }
+#else
+ buf->flags = _glibtop_sysdeps_uptime;
+
glibtop_cpu cpu;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
@@ -70,4 +91,5 @@
buf->idletime = (double) cpu.idle / (double) cpu.frequency;
buf->flags = _glibtop_sysdeps_uptime;
+#endif
}
|