diff options
author | Bastien Nocera <hadess@hadess.net> | 2004-03-09 23:13:31 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@src.gnome.org> | 2004-03-09 23:13:31 +0000 |
commit | 4bd9752d52b68936127655b6a2a903b7dc27ed1c (patch) | |
tree | 3a0b051b3bc10bca840307921c7d793958028463 /sysdeps/freebsd/uptime.c | |
parent | a795ff4847e6357e583ce2036f2623577fa0d051 (diff) | |
download | libgtop-4bd9752d52b68936127655b6a2a903b7dc27ed1c.tar.gz |
implement NetBSD support, and some build problems on FreeBSD (Closes:
2004-03-09 Bastien Nocera <hadess@hadess.net>
* Makefile.am:
* cpu.c: (glibtop_init_cpu_p), (glibtop_get_cpu_p):
* glibtop_machine.h:
* mem.c:
* netload.c: (glibtop_get_netload_p):
* prockernel.c: (glibtop_get_proc_kernel_p):
* proclist.c: (glibtop_get_proclist_p):
* procmap.c: (glibtop_get_proc_map_p):
* procmem.c: (glibtop_get_proc_mem_p):
* procsignal.c: (glibtop_get_proc_signal_p):
* procstate.c: (glibtop_get_proc_state_p):
* proctime.c:
* procuid.c: (glibtop_get_proc_uid_p):
* uptime.c: (glibtop_get_uptime_p): implement NetBSD support, and
some build problems on FreeBSD (Closes: #135674)
Diffstat (limited to 'sysdeps/freebsd/uptime.c')
-rw-r--r-- | sysdeps/freebsd/uptime.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sysdeps/freebsd/uptime.c b/sysdeps/freebsd/uptime.c index 250a72d1..73275d7b 100644 --- a/sysdeps/freebsd/uptime.c +++ b/sysdeps/freebsd/uptime.c @@ -49,6 +49,27 @@ glibtop_init_uptime_p (glibtop *server) 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 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) buf->idletime = (double) cpu.idle / (double) cpu.frequency; buf->flags = _glibtop_sysdeps_uptime; +#endif } |