summaryrefslogtreecommitdiffstats
path: root/include/osmocore/statistics.h
blob: 1d56054ab0f5623d59164367a683def51874d337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef _STATISTICS_H
#define _STATISTICS_H

struct counter {
	struct llist_head list;
	const char *name;
	const char *description;
	unsigned long value;
};

static inline void counter_inc(struct counter *ctr)
{
	ctr->value++;
}

static inline unsigned long counter_get(struct counter *ctr)
{
	return ctr->value;
}

static inline void counter_reset(struct counter *ctr)
{
	ctr->value = 0;
}

struct counter *counter_alloc(const char *name);
void counter_free(struct counter *ctr);

int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);

#endif /* _STATISTICS_H */