blob: 1d56054ab0f5623d59164367a683def51874d337 [file] [log] [blame]
Harald Welteec8b4502010-02-20 20:34:29 +01001#ifndef _STATISTICS_H
2#define _STATISTICS_H
3
4struct counter {
5 struct llist_head list;
6 const char *name;
7 const char *description;
8 unsigned long value;
9};
10
11static inline void counter_inc(struct counter *ctr)
12{
13 ctr->value++;
14}
15
16static inline unsigned long counter_get(struct counter *ctr)
17{
18 return ctr->value;
19}
20
21static inline void counter_reset(struct counter *ctr)
22{
23 ctr->value = 0;
24}
25
26struct counter *counter_alloc(const char *name);
27void counter_free(struct counter *ctr);
28
29int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
30
31#endif /* _STATISTICS_H */