util-linux/sys-utils/irq-common.h
Karel Zak 44e39c9940 irqtop: cleanup sort stuff
* user "cmp" in the function names (it does not sort)
* keep all in irq-common.c
* use column names on command line (e.g. --sort NAME)
* hardcode default to sort_result()

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-06 15:29:03 +01:00

60 lines
1.5 KiB
C

#ifndef UTIL_LINUX_H_IRQ_COMMON
#define UTIL_LINUX_H_IRQ_COMMON
#include "c.h"
#include "nls.h"
/* supported columns */
enum {
COL_IRQ = 0,
COL_TOTAL,
COL_DELTA,
COL_NAME,
__COL_COUNT
};
struct irq_info {
char *irq; /* short name of this irq */
char *name; /* descriptive name of this irq */
unsigned long total; /* total count since system start up */
unsigned long delta; /* delta count since previous update */
};
struct irq_stat {
unsigned int nr_irq; /* number of irq vector */
unsigned int nr_irq_info; /* number of irq info */
struct irq_info *irq_info; /* array of irq_info */
long nr_active_cpu; /* number of active cpu */
unsigned long total_irq; /* total irqs */
unsigned long delta_irq; /* delta irqs */
};
typedef int (irq_cmp_t)(const struct irq_info *, const struct irq_info *);
/* output definition */
struct irq_output {
int columns[__COL_COUNT * 2];
size_t ncolumns;
irq_cmp_t *sort_cmp_func;
unsigned int
json:1,
no_headings:1;
};
int irq_column_name_to_id(char const *const name, size_t const namesz);
void free_irqstat(struct irq_stat *stat);
void irq_print_columns(FILE *f);
void set_sort_func_by_name(struct irq_output *out, const char *name);
void set_sort_func_by_key(struct irq_output *out, const char c);
struct libscols_table *get_scols_table(struct irq_output *out,
struct irq_stat *prev,
struct irq_stat **xstat);
#endif /* UTIL_LINUX_H_IRQ_COMMON */