procps/proc/readstat.h
Jim Warner 63e828fe88 library: minor tweaks of program logic and/or comments
This commit just corrects the oversight wherein 'item'
was being employed when 'these' was actually intended.

Also, it trades some 'item' use for a more descriptive
input parameter which henceforth is known as a 'dest'.

And, there was one leftover 'next' pointer eliminated.

Finally, some logic was made a tad less dependent upon
enumerator names and a few comments were also updated.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-28 21:51:00 +10:00

118 lines
3.1 KiB
C

/*
* libprocps - Library to read proc filesystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PROC_READ_STAT_H
#define PROC_READ_STAT_H
#include <proc/procps.h>
__BEGIN_DECLS
enum procps_cpu_item {
PROCPS_CPU_USER, // jiff
PROCPS_CPU_NICE, // jiff
PROCPS_CPU_SYSTEM, // jiff
PROCPS_CPU_IDLE, // jiff
PROCPS_CPU_IOWAIT, // jiff
PROCPS_CPU_IRQ, // jiff
PROCPS_CPU_SIRQ, // jiff
PROCPS_CPU_STOLEN, // jiff
PROCPS_CPU_GUEST, // jiff
PROCPS_CPU_GNICE, // jiff
PROCPS_CPU_noop, // n/a
PROCPS_CPU_stack_end // n/a
};
enum procps_stat_item {
PROCPS_STAT_INTR, // u_int
PROCPS_STAT_CTXT, // u_int
PROCPS_STAT_BTIME, // u_int
PROCPS_STAT_PROCS, // u_int
PROCPS_STAT_PROCS_BLK, // u_int
PROCPS_STAT_PROCS_RUN, // u_int
PROCPS_STAT_noop, // n/a
PROCPS_STAT_stack_end // n/a
};
typedef unsigned long long jiff;
struct procps_jiffs {
jiff user, nice, system, idle, iowait, irq, sirq, stolen, guest, gnice;
};
struct procps_jiffs_hist {
struct procps_jiffs new;
struct procps_jiffs old;
int id;
};
struct stat_result {
int item;
union {
unsigned int u_int;
jiff jiff;
} result;
};
struct procps_stat;
int procps_stat_new (struct procps_stat **info);
int procps_stat_read (struct procps_stat *info, const int cpu_only);
int procps_stat_read_jiffs (struct procps_stat *info);
int procps_stat_ref (struct procps_stat *info);
int procps_stat_unref (struct procps_stat **info);
jiff procps_stat_cpu_get (
struct procps_stat *info,
enum procps_cpu_item item);
int procps_stat_cpu_getstack (
struct procps_stat *info,
struct stat_result *these);
int procps_stat_jiffs_get (
struct procps_stat *info,
struct procps_jiffs *dest,
int which);
int procps_stat_jiffs_hist_get (
struct procps_stat *info,
struct procps_jiffs_hist *dest,
int which);
int procps_stat_jiffs_fill (
struct procps_stat *info,
struct procps_jiffs *dests,
int maxdests);
int procps_stat_jiffs_hist_fill (
struct procps_stat *info,
struct procps_jiffs_hist *dests,
int maxdests);
unsigned int procps_stat_sys_get (
struct procps_stat *info,
enum procps_stat_item item);
int procps_stat_sys_getstack (
struct procps_stat *info,
struct stat_result *these);
__END_DECLS
#endif