summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2005-07-05 23:05:20 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2005-07-05 23:05:20 +0000
commitb6a10fd8f70374b3a4feb64dd3f42f600676d241 (patch)
tree06e31f2e9365bfa73a9e9492326e17337cd496ff
parentefeca4a8654731cc091606ed773e00aacb4dd5da (diff)
downloadlibgtop-b6a10fd8f70374b3a4feb64dd3f42f600676d241.tar.gz
Made some checks solaris only.
* configure.in: Made some checks solaris only.
-rw-r--r--configure.in49
-rw-r--r--sysdeps/linux/glibtop_private.c17
-rw-r--r--sysdeps/linux/glibtop_private.h6
-rw-r--r--sysdeps/linux/proctime.c11
-rw-r--r--sysdeps/linux/uptime.c2
5 files changed, 53 insertions, 32 deletions
diff --git a/configure.in b/configure.in
index d85e0191..9b4c9926 100644
--- a/configure.in
+++ b/configure.in
@@ -195,28 +195,33 @@ AH_TEMPLATE(HAVE_VMGETINFO, [Define to 1 if you have the 'vmgetinfo' function in
AC_CHECK_LIB(perfstat, vmgetinfo, AC_DEFINE(HAVE_VMGETINFO))
dnl Solaris
-AC_CHECK_LIB(kstat, kstat_open)
-AC_CHECK_FUNCS(getloadavg swapctl)
-AC_CHECK_HEADERS(procfs.h sys/procfs.h, break)
-
-dnl Some versions of Solaris require -lelf for -lkvm
-AC_CHECK_LIB(kvm, kvm_open,[
- LIBS="-lkvm $LIBS"
-],[AC_MSG_CHECKING(for kvm_open in -lkvm with -lelf)
- AC_CACHE_VAL(ac_cv_lib_kvm_with_elf,
- [ac_save_LIBS="$LIBS"
- LIBS="-lkvm -lelf $LIBS"
- AC_TRY_LINK([char kvm_open();], [kvm_open()],
- ac_cv_lib_kvm_with_elf=yes, ac_cv_lib_kvm_with_elf=no)
- LIBS="$ac_save_LIBS"
- ])
- if test "$ac_cv_lib_kvm_with_elf" = "yes"; then
- AC_MSG_RESULT(yes)
- LIBS="-lkvm -lelf $LIBS"
- else
- AC_MSG_RESULT(no)
- fi
-])
+case "$host_os" in
+ solaris*)
+ AC_CHECK_LIB(kstat, kstat_open)
+ AC_CHECK_FUNCS(getloadavg swapctl)
+ AC_CHECK_HEADERS(procfs.h sys/procfs.h, break)
+
+
+ dnl Some versions of Solaris require -lelf for -lkvm
+ AC_CHECK_LIB(kvm, kvm_open,[
+ LIBS="-lkvm $LIBS"
+ ],[AC_MSG_CHECKING(for kvm_open in -lkvm with -lelf)
+ AC_CACHE_VAL(ac_cv_lib_kvm_with_elf,
+ [ac_save_LIBS="$LIBS"
+ LIBS="-lkvm -lelf $LIBS"
+ AC_TRY_LINK([char kvm_open();], [kvm_open()],
+ ac_cv_lib_kvm_with_elf=yes, ac_cv_lib_kvm_with_elf=no)
+ LIBS="$ac_save_LIBS"
+ ])
+ if test "$ac_cv_lib_kvm_with_elf" = "yes"; then
+ AC_MSG_RESULT(yes)
+ LIBS="-lkvm -lelf $LIBS"
+ else
+ AC_MSG_RESULT(no)
+ fi
+ ])
+ ;;
+esac
dnl For DEC OSF1
AC_CHECK_LIB(mach, vm_statistics)
diff --git a/sysdeps/linux/glibtop_private.c b/sysdeps/linux/glibtop_private.c
index ec7a6bdc..32d7462b 100644
--- a/sysdeps/linux/glibtop_private.c
+++ b/sysdeps/linux/glibtop_private.c
@@ -96,3 +96,20 @@ file_to_buffer(glibtop *server, char *buffer, const char *filename)
}
+
+
+unsigned long
+get_boot_time(glibtop *server)
+{
+ char buffer[BUFSIZ];
+ char *btime;
+
+ file_to_buffer(server, buffer, "/proc/stat");
+
+ btime = strstr(buffer, "btime");
+
+ g_return_val_if_fail(btime != NULL, 0UL);
+
+ btime = skip_token(btime);
+ return strtoul(btime, NULL, 10);
+}
diff --git a/sysdeps/linux/glibtop_private.h b/sysdeps/linux/glibtop_private.h
index fc6a1c6c..a207d7d4 100644
--- a/sysdeps/linux/glibtop_private.h
+++ b/sysdeps/linux/glibtop_private.h
@@ -111,6 +111,12 @@ proc_stat_after_cmd (char *p)
*p++ = '\0';
return p;
}
+
+
+unsigned long
+get_boot_time(glibtop *server) G_GNUC_INTERNAL;
+
+
G_END_DECLS
#endif /* __LINUX__GLIBTOP_PRIVATE_H__ */
diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c
index 78831d64..3fbffc6a 100644
--- a/sysdeps/linux/proctime.c
+++ b/sysdeps/linux/proctime.c
@@ -87,11 +87,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid)
/* seconds since epoch */
{
- /* Linux provides start_time as clock_t representing
- the start of <pid> after boot_time.
- Let's use glibtop_get_uptime to get boot_time.
- But i'm not sure if this is safe
-
+ /*
See libgtop documentation.
#ifdef __KERNEL__
@@ -109,10 +105,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid)
system clock is not synchronised with you hardware clock.
'man hwclock'
*/
- glibtop_uptime up;
- glibtop_get_uptime_s(server, &up);
-
- buf->start_time = up.boot_time + strtoull (p, &p, 0) / 100;
+ buf->start_time = get_boot_time(server) + strtoull (p, &p, 0) / 100;
}
buf->frequency = 100;
diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c
index 577842ed..a87c153c 100644
--- a/sysdeps/linux/uptime.c
+++ b/sysdeps/linux/uptime.c
@@ -57,7 +57,7 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
buf->uptime = g_ascii_strtod (buffer, &p);
buf->idletime = g_ascii_strtod (p, &p);
- buf->boot_time = (guint64) time(NULL) - (guint64) buf->uptime;
+ buf->boot_time = get_boot_time(server);
buf->flags = _glibtop_sysdeps_uptime;
}