procps/proc/stat.h
Jim Warner c4d097c709 library: removed all the 'PROCPS_' enumerator prefixes
Many of our item enumerator identifiers are very long,
especially in that <VMSTAT> module. Additionally, they
all contain the exact same universal 'PROCPS_' prefix.

The origins for this are likely found in the desire to
avoid name clashes with other potential include files.
But with procps-ng newlib, we've probably gone way too
far. Did 'PROCPS_PIDS_TICS_SYSTEM' actually offer more
protection against clash than 'PIDS_TICS_SYSTEM' does?

I don't think so. Besides, no matter how big that name
becomes, one can never guarantee they'll never be some
clash. And, conversely, extremely short names will not
always create conflict. Of course, in either case when
some clash occurs, one can always #undef that problem.

Thus, this commit will eliminate that 'PROCPS_' prefix
making all of those enum identifiers a little shorter.
And, we'll still be well above some ridiculously short
(criminally short) names found in some common headers:

- - - - - - - - - - <term.h>
- 'tab', 'TTY', etc
- - - - - - - - - - - - - - - - <search.h>
- 'ENTER', ENTRY', 'FIND', etc

------------------------------------------------------
Finally, with this as a last of the wholesale changes,
we will have established the naming conventions below:

. only functions will begin with that 'procps_' prefix
. exposed structures begin with the module/header name
. item enumerators begin like structs, but capitalized
. other enumerators work exactly like item enumerators
. macros and constants begin just like the enumerators
------------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 20:49:00 +10:00

133 lines
3.8 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_STAT_H
#define PROC_STAT_H
#include <sys/cdefs.h>
__BEGIN_DECLS
enum stat_item {
STAT_noop, // ( never altered )
STAT_extra, // ( reset to zero )
STAT_TIC_ID, // s_int
STAT_TIC_NUMA_NODE, // s_int
STAT_TIC_USER, // ull_int
STAT_TIC_NICE, // ull_int
STAT_TIC_SYSTEM, // ull_int
STAT_TIC_IDLE, // ull_int
STAT_TIC_IOWAIT, // ull_int
STAT_TIC_IRQ, // ull_int
STAT_TIC_SOFTIRQ, // ull_int
STAT_TIC_STOLEN, // ull_int
STAT_TIC_GUEST, // ull_int
STAT_TIC_GUEST_NICE, // ull_int
STAT_TIC_DELTA_USER, // sl_int
STAT_TIC_DELTA_NICE, // sl_int
STAT_TIC_DELTA_SYSTEM, // sl_int
STAT_TIC_DELTA_IDLE, // sl_int
STAT_TIC_DELTA_IOWAIT, // sl_int
STAT_TIC_DELTA_IRQ, // sl_int
STAT_TIC_DELTA_SOFTIRQ, // sl_int
STAT_TIC_DELTA_STOLEN, // sl_int
STAT_TIC_DELTA_GUEST, // sl_int
STAT_TIC_DELTA_GUEST_NICE, // sl_int
STAT_SYS_CTX_SWITCHES, // ul_int
STAT_SYS_INTERRUPTS, // ul_int
STAT_SYS_PROC_BLOCKED, // ul_int
STAT_SYS_PROC_CREATED, // ul_int
STAT_SYS_PROC_RUNNING, // ul_int
STAT_SYS_TIME_OF_BOOT, // ul_int
STAT_SYS_DELTA_CTX_SWITCHES, // s_int
STAT_SYS_DELTA_INTERRUPTS, // s_int
STAT_SYS_DELTA_PROC_BLOCKED, // s_int
STAT_SYS_DELTA_PROC_CREATED, // s_int
STAT_SYS_DELTA_PROC_RUNNING // s_int
};
enum stat_reap_type {
STAT_REAP_CPUS_ONLY,
STAT_REAP_CPUS_AND_NODES
};
struct stat_result {
enum stat_item item;
union {
signed int s_int;
signed long sl_int;
unsigned long ul_int;
unsigned long long ull_int;
} result;
};
struct stat_stack {
struct stat_result *head;
};
struct stat_reap {
int total;
struct stat_stack **stacks;
};
struct stat_reaped {
struct stat_stack *summary;
struct stat_reap *cpus;
struct stat_reap *nodes;
};
#define STAT_SUMMARY_ID -11111
#define STAT_NODE_INVALID -22222
#define STAT_GET( info, actual_enum, type ) \
procps_stat_get( info, actual_enum ) -> result . type
#define STAT_VAL( relative_enum, type, stack ) \
stack -> head [ relative_enum ] . result . type
struct stat_info;
int procps_stat_new (struct stat_info **info);
int procps_stat_ref (struct stat_info *info);
int procps_stat_unref (struct stat_info **info);
struct stat_result *procps_stat_get (
struct stat_info *info,
enum stat_item item);
struct stat_reaped *procps_stat_reap (
struct stat_info *info,
enum stat_reap_type what,
enum stat_item *items,
int numitems);
struct stat_stack *procps_stat_select (
struct stat_info *info,
enum stat_item *items,
int numitems);
__END_DECLS
#endif