library: more tweaks for code and/or comments, 3rd gen
Following is a summary of significant changes (if any) to each of these now upgraded 3rd gen library modules. <meminfo> ............................................ . eliminated duplicate decl of 'struct procps_meminfo' . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . how did i miss relocating all these friggin' #undefs . cleanup 'get' return logic (remove a redundant 'if') <pids> ............................................... . repositioned the procps_pidsinfo structure in header . removed the extra trailing comma from enum pids_item . standardized/normalized results struct union members <slabinfo> ........................................... . corrected comment typo (jeeze, in an 'aligned' para) . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . removed an obsolete #undef from procps_slabinfo_sort . cleanup 'get' return logic (remove a redundant 'if') <stat> ............................................... . how did i miss relocating all these friggin' #undefs . corrected an initialization fencepost used with numa <=== see Craig, here's a bug fix . removed the extra trailing comma from enum stat_item . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . strengthen those parm checks in procps_stat_get func . cleanup 'get' return logic (remove a redundant 'if') <vmstat> ............................................. . standardized/normalized results struct union members . added 'std' & 'var' dividers in .c file, like <pids> . cleanup 'get' return logic (remove a redundant 'if') [ virtually all of these tweaks reflect the author's ] [ continuing pursuit of an unreasonable goal -- that ] [ of a 'perfect' (plus 'pretty') C language program! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
38
proc/stat.c
38
proc/stat.c
@ -185,6 +185,12 @@ setDECL(SYS_DELTA_PROC_BLOCKED) { (void)T; R->result.s_int = S->new.procs_blocke
|
||||
SYSsetH(SYS_DELTA_PROC_CREATED, s_int, procs_created)
|
||||
setDECL(SYS_DELTA_PROC_RUNNING) { (void)T; R->result.s_int = S->new.procs_running - S->old.procs_running; }
|
||||
|
||||
#undef setDECL
|
||||
#undef TIC_set
|
||||
#undef SYS_set
|
||||
#undef TICsetH
|
||||
#undef SYSsetH
|
||||
|
||||
|
||||
// ___ Results 'Get' Support ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
|
||||
@ -244,6 +250,12 @@ getDECL(SYS_DELTA_PROC_BLOCKED) { return I->sys_hist.new.procs_blocked - I->sys_
|
||||
SYSgetH(SYS_DELTA_PROC_CREATED, procs_created)
|
||||
getDECL(SYS_DELTA_PROC_RUNNING) { return I->sys_hist.new.procs_running - I->sys_hist.old.procs_running; }
|
||||
|
||||
#undef getDECL
|
||||
#undef TIC_get
|
||||
#undef SYS_get
|
||||
#undef TICgetH
|
||||
#undef SYSgetH
|
||||
|
||||
|
||||
// ___ Controlling Table ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
|
||||
@ -314,17 +326,7 @@ enum stat_item PROCPS_STAT_TIC_highest = PROCPS_STAT_TIC_DELTA_GUEST_NICE;
|
||||
enum stat_item PROCPS_STAT_logical_end = PROCPS_STAT_SYS_DELTA_PROC_RUNNING + 1;
|
||||
|
||||
#undef setNAME
|
||||
#undef setDECL
|
||||
#undef TIC_set
|
||||
#undef SYS_set
|
||||
#undef TICsetH
|
||||
#undef SYSsetH
|
||||
#undef getNAME
|
||||
#undef getDECL
|
||||
#undef TIC_get
|
||||
#undef SYS_get
|
||||
#undef TICgetH
|
||||
#undef SYSgetH
|
||||
#undef RS
|
||||
#undef RG
|
||||
|
||||
@ -458,6 +460,7 @@ static int make_numa_hist (
|
||||
( and be careful, this libnuma call returns the highest node id in use, )
|
||||
( NOT an actual number of nodes - some of those 'slots' might be unused ) */
|
||||
info->nodes.total = info->our_max_node() + 1;
|
||||
|
||||
if (!info->nodes.hist.n_alloc
|
||||
|| !(info->nodes.total < info->nodes.hist.n_alloc)) {
|
||||
info->nodes.hist.n_alloc = info->nodes.total + NEWOLD_INCR;
|
||||
@ -469,7 +472,7 @@ static int make_numa_hist (
|
||||
// forget all of the prior node statistics & anticipate unassigned slots
|
||||
memset(info->nodes.hist.tics, 0, info->nodes.hist.n_alloc * sizeof(struct hist_tic));
|
||||
nod_ptr = info->nodes.hist.tics;
|
||||
for (i = 0; i < info->cpus.hist.n_alloc; i++) {
|
||||
for (i = 0; i < info->nodes.total; i++) {
|
||||
nod_ptr->id = nod_ptr->numa_node = PROCPS_STAT_NODE_INVALID;
|
||||
++nod_ptr;
|
||||
}
|
||||
@ -808,6 +811,8 @@ static struct stat_stack *update_single_stack (
|
||||
|
||||
// ___ Public Functions |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
|
||||
// --- standard required functions --------------------------------------------
|
||||
|
||||
/*
|
||||
* procps_stat_new:
|
||||
*
|
||||
@ -922,6 +927,8 @@ PROCPS_EXPORT int procps_stat_unref (
|
||||
} // end: procps_stat_unref
|
||||
|
||||
|
||||
// --- variable interface functions -------------------------------------------
|
||||
|
||||
PROCPS_EXPORT signed long long procps_stat_get (
|
||||
struct procps_statinfo *info,
|
||||
enum stat_item item)
|
||||
@ -930,6 +937,11 @@ PROCPS_EXPORT signed long long procps_stat_get (
|
||||
time_t cur_secs;
|
||||
int rc;
|
||||
|
||||
if (info == NULL)
|
||||
return -EINVAL;
|
||||
if (item < 0 || item >= PROCPS_STAT_logical_end)
|
||||
return -EINVAL;
|
||||
|
||||
/* no sense reading the stat with every call from a program like vmstat
|
||||
who chooses not to use the much more efficient 'select' function ... */
|
||||
cur_secs = time(NULL);
|
||||
@ -939,9 +951,7 @@ PROCPS_EXPORT signed long long procps_stat_get (
|
||||
sav_secs = cur_secs;
|
||||
}
|
||||
|
||||
if (item < PROCPS_STAT_logical_end)
|
||||
return Item_table[item].getsfunc(info);
|
||||
return -EINVAL;
|
||||
return Item_table[item].getsfunc(info);
|
||||
} // end: procps_stat_get
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user