Added implementation.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
@@ -24,14 +24,17 @@
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime = 0;
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_uptime =
|
||||
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_uptime_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
}
|
||||
|
||||
/* Provides uptime and idle time. */
|
||||
@@ -39,5 +42,16 @@ glibtop_init_uptime_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
libgtop_stat_t stat;
|
||||
unsigned long total;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
|
||||
if (glibtop_get_proc_data_stat_s (server, &stat))
|
||||
return;
|
||||
|
||||
total = stat.cpu.user + stat.cpu.nice + stat.cpu.sys + stat.cpu.idle;
|
||||
|
||||
buf->uptime = (double) total / (double) stat.frequency;
|
||||
buf->idletime = (double) stat.cpu.idle / (double) stat.frequency;
|
||||
}
|
||||
|
Reference in New Issue
Block a user