blob: 2c159657958c7262ccfce890ebefeb2ea39008f4 [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
Daniel Willmann334c8e12011-04-08 10:46:19 +020031struct counter *counter_get_by_name(const char *name);
32
Harald Welteec8b4502010-02-20 20:34:29 +010033#endif /* _STATISTICS_H */