2c159657958c7262ccfce890ebefeb2ea39008f4
[osmocom-bb.git] / include / osmocom / core / statistics.h
1 #ifndef _STATISTICS_H
2 #define _STATISTICS_H
3
4 struct counter {
5         struct llist_head list;
6         const char *name;
7         const char *description;
8         unsigned long value;
9 };
10
11 static inline void counter_inc(struct counter *ctr)
12 {
13         ctr->value++;
14 }
15
16 static inline unsigned long counter_get(struct counter *ctr)
17 {
18         return ctr->value;
19 }
20
21 static inline void counter_reset(struct counter *ctr)
22 {
23         ctr->value = 0;
24 }
25
26 struct counter *counter_alloc(const char *name);
27 void counter_free(struct counter *ctr);
28
29 int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
30
31 struct counter *counter_get_by_name(const char *name);
32
33 #endif /* _STATISTICS_H */