library: misc tweaks for code and comments, <PIDS> api
This commit simply tries to keep naming plus formating conventions on a par with the continuing climb up that learning curve. These changes were suggested following <slabinfo> sources upgrade from 2nd to 3rd generation. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
335cbc2e61
commit
aa9f00dcaf
37
proc/pids.c
37
proc/pids.c
@ -60,8 +60,8 @@ struct fetch_support {
|
|||||||
struct pids_stack **anchor; // reap/select consolidated extents
|
struct pids_stack **anchor; // reap/select consolidated extents
|
||||||
int n_alloc; // number of above pointers allocated
|
int n_alloc; // number of above pointers allocated
|
||||||
int n_inuse; // number of above pointers occupied
|
int n_inuse; // number of above pointers occupied
|
||||||
int n_alloc_save; // last known summary.stacks allocation
|
int n_alloc_save; // last known results.stacks allocation
|
||||||
struct pids_fetch summary; // counts + stacks for return to caller
|
struct pids_fetch results; // counts + stacks for return to caller
|
||||||
};
|
};
|
||||||
|
|
||||||
struct procps_pidsinfo {
|
struct procps_pidsinfo {
|
||||||
@ -254,7 +254,6 @@ REG_set(VSIZE_PGS, ul_int, vsize)
|
|||||||
REG_set(WCHAN_ADDR, ul_int, wchan)
|
REG_set(WCHAN_ADDR, ul_int, wchan)
|
||||||
setDECL(WCHAN_NAME) { (void)I; R->result.str = strdup(lookup_wchan(P->tid)); }
|
setDECL(WCHAN_NAME) { (void)I; R->result.str = strdup(lookup_wchan(P->tid)); }
|
||||||
|
|
||||||
|
|
||||||
#undef mkSTR
|
#undef mkSTR
|
||||||
#undef xySTR
|
#undef xySTR
|
||||||
|
|
||||||
@ -515,12 +514,18 @@ static struct {
|
|||||||
// next MUST be kept in sync with highest value enum
|
// next MUST be kept in sync with highest value enum
|
||||||
enum pids_item PROCPS_PIDS_logical_end = PROCPS_PIDS_WCHAN_NAME + 1;
|
enum pids_item PROCPS_PIDS_logical_end = PROCPS_PIDS_WCHAN_NAME + 1;
|
||||||
|
|
||||||
|
#undef setNAME
|
||||||
|
#undef setDECL
|
||||||
|
#undef CVT_set
|
||||||
|
#undef DUP_set
|
||||||
|
#undef REG_set
|
||||||
|
#undef STR_set
|
||||||
|
#undef VEC_set
|
||||||
|
#undef freNAME
|
||||||
|
#undef srtNAME
|
||||||
#undef RS
|
#undef RS
|
||||||
#undef FF
|
#undef FF
|
||||||
#undef QS
|
#undef QS
|
||||||
#undef setNAME
|
|
||||||
#undef freNAME
|
|
||||||
#undef srtNAME
|
|
||||||
|
|
||||||
//#undef f_either // needed later
|
//#undef f_either // needed later
|
||||||
#undef f_grp
|
#undef f_grp
|
||||||
@ -1080,7 +1085,7 @@ static int stacks_fetch (
|
|||||||
}
|
}
|
||||||
cleanup_stacks_all(info);
|
cleanup_stacks_all(info);
|
||||||
toggle_history(info);
|
toggle_history(info);
|
||||||
memset(&info->fetch.summary.counts, 0, sizeof(struct pids_counts));
|
memset(&info->fetch.results.counts, 0, sizeof(struct pids_counts));
|
||||||
|
|
||||||
// iterate stuff --------------------------------------
|
// iterate stuff --------------------------------------
|
||||||
n_inuse = 0;
|
n_inuse = 0;
|
||||||
@ -1092,7 +1097,7 @@ static int stacks_fetch (
|
|||||||
return -1;
|
return -1;
|
||||||
memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * MEMORY_INCR);
|
memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * MEMORY_INCR);
|
||||||
}
|
}
|
||||||
if (!proc_tally(info, &info->fetch.summary.counts, &task))
|
if (!proc_tally(info, &info->fetch.results.counts, &task))
|
||||||
return -1;
|
return -1;
|
||||||
assign_results(info, info->fetch.anchor[n_inuse++], &task);
|
assign_results(info, info->fetch.anchor[n_inuse++], &task);
|
||||||
}
|
}
|
||||||
@ -1100,11 +1105,11 @@ static int stacks_fetch (
|
|||||||
// finalize stuff -------------------------------------
|
// finalize stuff -------------------------------------
|
||||||
if (n_saved < n_alloc + 1) {
|
if (n_saved < n_alloc + 1) {
|
||||||
n_saved = n_alloc + 1;
|
n_saved = n_alloc + 1;
|
||||||
if (!(info->fetch.summary.stacks = realloc(info->fetch.summary.stacks, sizeof(void *) * n_saved)))
|
if (!(info->fetch.results.stacks = realloc(info->fetch.results.stacks, sizeof(void *) * n_saved)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(info->fetch.summary.stacks, info->fetch.anchor, sizeof(void *) * n_inuse);
|
memcpy(info->fetch.results.stacks, info->fetch.anchor, sizeof(void *) * n_inuse);
|
||||||
info->fetch.summary.stacks[n_inuse] = NULL;
|
info->fetch.results.stacks[n_inuse] = NULL;
|
||||||
return n_inuse; // callers beware, this might be zero !
|
return n_inuse; // callers beware, this might be zero !
|
||||||
#undef n_alloc
|
#undef n_alloc
|
||||||
#undef n_inuse
|
#undef n_inuse
|
||||||
@ -1218,8 +1223,8 @@ PROCPS_EXPORT int procps_pids_unref (
|
|||||||
}
|
}
|
||||||
if ((*info)->fetch.anchor)
|
if ((*info)->fetch.anchor)
|
||||||
free((*info)->fetch.anchor);
|
free((*info)->fetch.anchor);
|
||||||
if ((*info)->fetch.summary.stacks)
|
if ((*info)->fetch.results.stacks)
|
||||||
free((*info)->fetch.summary.stacks);
|
free((*info)->fetch.results.stacks);
|
||||||
|
|
||||||
if ((*info)->items)
|
if ((*info)->items)
|
||||||
free((*info)->items);
|
free((*info)->items);
|
||||||
@ -1335,7 +1340,7 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_reap (
|
|||||||
|
|
||||||
oldproc_close(&info->PT);
|
oldproc_close(&info->PT);
|
||||||
// we better have found at least 1 pid
|
// we better have found at least 1 pid
|
||||||
return (rc > 0) ? &info->fetch.summary : NULL;
|
return (rc > 0) ? &info->fetch.results : NULL;
|
||||||
} // end: procps_pids_reap
|
} // end: procps_pids_reap
|
||||||
|
|
||||||
|
|
||||||
@ -1415,7 +1420,7 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_select (
|
|||||||
|
|
||||||
oldproc_close(&info->PT);
|
oldproc_close(&info->PT);
|
||||||
// no guarantee any pids/uids were found
|
// no guarantee any pids/uids were found
|
||||||
return (rc > -1) ? &info->fetch.summary : NULL;
|
return (rc > -1) ? &info->fetch.results : NULL;
|
||||||
} // end: procps_pids_select
|
} // end: procps_pids_select
|
||||||
|
|
||||||
|
|
||||||
@ -1445,7 +1450,7 @@ PROCPS_EXPORT struct pids_stack **procps_pids_sort (
|
|||||||
// a pids_item is currently unsigned, but we'll protect our future
|
// a pids_item is currently unsigned, but we'll protect our future
|
||||||
if (sortitem < 0 || sortitem >= PROCPS_PIDS_logical_end)
|
if (sortitem < 0 || sortitem >= PROCPS_PIDS_logical_end)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (order != PROCPS_SORT_ASCEND && order != PROCPS_SORT_DESCEND)
|
if (order != PROCPS_PIDS_ASCEND && order != PROCPS_PIDS_DESCEND)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (numstacked < 2)
|
if (numstacked < 2)
|
||||||
return stacks;
|
return stacks;
|
||||||
|
@ -158,8 +158,8 @@ enum pids_select_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum pids_sort_order {
|
enum pids_sort_order {
|
||||||
PROCPS_SORT_ASCEND = +1,
|
PROCPS_PIDS_ASCEND = +1,
|
||||||
PROCPS_SORT_DESCEND = -1
|
PROCPS_PIDS_DESCEND = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -232,7 +232,5 @@ struct pids_stack **procps_pids_sort (
|
|||||||
enum pids_item sortitem,
|
enum pids_item sortitem,
|
||||||
enum pids_sort_order order);
|
enum pids_sort_order order);
|
||||||
|
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif /* _PROC_PIDS_H */
|
#endif /* _PROC_PIDS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user