Changed boot time to unsigned long long.

* glibtop_machine.h: Changed boot time to unsigned long long.

        * open.c: Added proper type checking for boot value. There's
        no point in saving a few nanoseconds in init function. And
        one day it will become 64-bit value.

        In glibtop_get_kstats(): Don't reread vminfo_snaptime when
        reinitializing kstats.
This commit is contained in:
Drazen Kacar
1999-05-03 23:02:58 +00:00
parent 333d0c5709
commit 3f65468299
3 changed files with 32 additions and 8 deletions

View File

@@ -1,3 +1,14 @@
1999-05-04 Drazen Kacar <dave@srce.hr>
* glibtop_machine.h: Changed boot time to unsigned long long.
* open.c: Added proper type checking for boot value. There's
no point in saving a few nanoseconds in init function. And
one day it will become 64-bit value.
In glibtop_get_kstats(): Don't reread vminfo_snaptime when
reinitializing kstats.
1999-05-03 Drazen Kacar <dave@srce.hr>
* glibtop_private.h: Fixed typoo.

View File

@@ -51,13 +51,13 @@ struct _glibtop_machine
kstat_t *cpu_stat_kstat [64];
kstat_t *system; /* boot_time & avenrun* where needed */
kstat_t *syspages; /* memory usage */
kstat_t *bunyip; /* more memory usage */
kstat_t *system; /* boot_time & avenrun* where needed */
kstat_t *syspages; /* memory usage */
kstat_t *bunyip; /* more memory usage */
int pagesize; /* in kilobytes */
int ticks; /* clock ticks, as returned by sysconf(_SC_CLK_TCK) */
unsigned boot; /* boot time, it's ui32 in kstat */
int pagesize; /* in kilobytes */
int ticks; /* clock ticks, as returned by sysconf() */
unsigned long long boot; /* boot time, it's ui32 in kstat */
};
END_LIBGTOP_DECLS

View File

@@ -60,7 +60,9 @@ glibtop_get_kstats(glibtop *server)
if(ksp)
{
kstat_read(kc, ksp, &server->machine.vminfo);
server->machine.vminfo_snaptime = ksp->ks_snaptime;
/* Don't change snaptime if we only need to reinitialize kstats */
if(!(server->machine.vminfo_snaptime))
server->machine.vminfo_snaptime = ksp->ks_snaptime;
}
/* We don't know why was kstat chain invalidated. It could have
@@ -164,6 +166,7 @@ glibtop_open_s (glibtop *server, const char *program_name,
glibtop_warn_io_r (server, "kstat_open ()");
server->ncpu = -1; /* Force processor detection */
server->machine.vminfo_snaptime = 0; /* Force snaptime read */
glibtop_get_kstats(server);
server->machine.boot = 0;
@@ -171,7 +174,17 @@ glibtop_open_s (glibtop *server, const char *program_name,
{
kn = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
if(kn)
server->machine.boot = kn->value.ui32;
switch(kn->data_type)
{
case KSTAT_DATA_INT32: server->machine.boot = kn->value.i32;
break;
case KSTAT_DATA_UINT32: server->machine.boot = kn->value.ui32;
break;
case KSTAT_DATA_INT64: server->machine.boot = kn->value.i64;
break;
case KSTAT_DATA_UINT64: server->machine.boot = kn->value.ui64;
break;
}
}
server->machine.kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);