2016-08-05 10:30:00 +05:30
|
|
|
/*
|
|
|
|
* libprocps - Library to read proc filesystem
|
|
|
|
*
|
2022-01-01 11:30:00 +05:30
|
|
|
* Copyright (C) 2016-2022 Jim Warner <james.warner@comcast.net>
|
2016-08-05 10:30:00 +05:30
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-07-25 10:30:00 +05:30
|
|
|
#define STRINGIFY_ARG(a) #a
|
|
|
|
#define STRINGIFY(a) STRINGIFY_ARG(a)
|
2016-08-05 10:30:00 +05:30
|
|
|
|
|
|
|
|
|
|
|
// --- DISKSTATS ------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_DISKSTATS_H) && !defined(PROCPS_DISKSTATS_H_DEBUG)
|
|
|
|
#define PROCPS_DISKSTATS_H_DEBUG
|
|
|
|
|
2016-08-05 10:30:00 +05:30
|
|
|
struct diskstats_result *xtra_diskstats_get (
|
|
|
|
struct diskstats_info *info,
|
|
|
|
const char *name,
|
|
|
|
enum diskstats_item actual_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef DISKSTATS_GET
|
2016-08-06 21:41:11 +05:30
|
|
|
#define DISKSTATS_GET( info, name, actual_enum, type ) ( { \
|
|
|
|
struct diskstats_result *r; \
|
|
|
|
r = xtra_diskstats_get(info, name, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct diskstats_result *xtra_diskstats_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct diskstats_stack *stack,
|
|
|
|
struct diskstats_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef DISKSTATS_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define DISKSTATS_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct diskstats_result *r; \
|
|
|
|
r = xtra_diskstats_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|
|
|
|
|
|
|
|
|
|
|
|
// --- MEMINFO --------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_MEMINFO_H) && !defined(PROCPS_MEMINFO_H_DEBUG)
|
|
|
|
#define PROCPS_MEMINFO_H_DEBUG
|
|
|
|
|
2016-08-05 10:30:00 +05:30
|
|
|
struct meminfo_result *xtra_meminfo_get (
|
|
|
|
struct meminfo_info *info,
|
|
|
|
enum meminfo_item actual_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef MEMINFO_GET
|
2016-08-05 10:30:00 +05:30
|
|
|
#define MEMINFO_GET( info, actual_enum, type ) ( { \
|
2016-08-06 21:41:11 +05:30
|
|
|
struct meminfo_result *r; \
|
|
|
|
r = xtra_meminfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct meminfo_result *xtra_meminfo_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct meminfo_stack *stack,
|
|
|
|
struct meminfo_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef MEMINFO_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define MEMINFO_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct meminfo_result *r; \
|
|
|
|
r = xtra_meminfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|
|
|
|
|
|
|
|
|
|
|
|
// --- PIDS -----------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_PIDS_H) && !defined(PROCPS_PIDS_H_DEBUG)
|
|
|
|
#define PROCPS_PIDS_H_DEBUG
|
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct pids_result *xtra_pids_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct pids_stack *stack,
|
|
|
|
struct pids_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef PIDS_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define PIDS_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct pids_result *r; \
|
|
|
|
r = xtra_pids_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|
|
|
|
|
|
|
|
|
|
|
|
// --- SLABINFO -------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_SLABINFO_H) && !defined(PROCPS_SLABINFO_H_DEBUG)
|
|
|
|
#define PROCPS_SLABINFO_H_DEBUG
|
|
|
|
|
2016-08-05 10:30:00 +05:30
|
|
|
struct slabinfo_result *xtra_slabinfo_get (
|
|
|
|
struct slabinfo_info *info,
|
|
|
|
enum slabinfo_item actual_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef SLABINFO_GET
|
2016-08-06 21:41:11 +05:30
|
|
|
#define SLABINFO_GET( info, actual_enum, type ) ( { \
|
|
|
|
struct slabinfo_result *r; \
|
|
|
|
r = xtra_slabinfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct slabinfo_result *xtra_slabinfo_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct slabinfo_stack *stack,
|
|
|
|
struct slabinfo_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef SLABINFO_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define SLABINFO_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct slabinfo_result *r; \
|
|
|
|
r = xtra_slabinfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|
|
|
|
|
|
|
|
|
|
|
|
// --- STAT -----------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_STAT_H) && !defined(PROCPS_STAT_H_DEBUG)
|
|
|
|
#define PROCPS_STAT_H_DEBUG
|
|
|
|
|
2016-08-05 10:30:00 +05:30
|
|
|
struct stat_result *xtra_stat_get (
|
|
|
|
struct stat_info *info,
|
|
|
|
enum stat_item actual_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef STAT_GET
|
2016-08-05 10:30:00 +05:30
|
|
|
#define STAT_GET( info, actual_enum, type ) ( { \
|
2016-08-06 21:41:11 +05:30
|
|
|
struct stat_result *r; \
|
|
|
|
r = xtra_stat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct stat_result *xtra_stat_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct stat_stack *stack,
|
|
|
|
struct stat_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef STAT_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define STAT_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct stat_result *r; \
|
|
|
|
r = xtra_stat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|
|
|
|
|
|
|
|
|
|
|
|
// --- VMSTAT ---------------------------------------------
|
2018-09-01 10:30:00 +05:30
|
|
|
#if defined(PROCPS_VMSTAT_H) && !defined(PROCPS_VMSTAT_H_DEBUG)
|
|
|
|
#define PROCPS_VMSTAT_H_DEBUG
|
|
|
|
|
2016-08-05 10:30:00 +05:30
|
|
|
struct vmstat_result *xtra_vmstat_get (
|
|
|
|
struct vmstat_info *info,
|
|
|
|
enum vmstat_item actual_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef VMSTAT_GET
|
2016-08-05 10:30:00 +05:30
|
|
|
#define VMSTAT_GET( info, actual_enum, type ) ( { \
|
2016-08-06 21:41:11 +05:30
|
|
|
struct vmstat_result *r; \
|
|
|
|
r = xtra_vmstat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
|
2016-08-08 11:53:45 +05:30
|
|
|
struct vmstat_result *xtra_vmstat_val (
|
2016-08-05 10:30:00 +05:30
|
|
|
int relative_enum,
|
|
|
|
const char *typestr,
|
|
|
|
const struct vmstat_stack *stack,
|
|
|
|
struct vmstat_info *info,
|
|
|
|
const char *file,
|
|
|
|
int lineno);
|
|
|
|
|
2018-09-01 10:30:00 +05:30
|
|
|
# undef VMSTAT_VAL
|
2016-08-05 10:30:00 +05:30
|
|
|
#define VMSTAT_VAL( relative_enum, type, stack, info ) ( { \
|
2016-08-08 11:53:45 +05:30
|
|
|
struct vmstat_result *r; \
|
|
|
|
r = xtra_vmstat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
|
|
|
|
r ? r->result . type : 0; } )
|
2016-08-05 10:30:00 +05:30
|
|
|
#endif // . . . . . . . . . .
|