statistics: use namespace prefix osmo_counter*
[osmocom-bb.git] / include / osmocom / core / statistics.h
1 #ifndef _STATISTICS_H
2 #define _STATISTICS_H
3
4 struct osmo_counter {
5         struct llist_head list;
6         const char *name;
7         const char *description;
8         unsigned long value;
9 };
10
11 static inline void osmo_counter_inc(struct osmo_counter *ctr)
12 {
13         ctr->value++;
14 }
15
16 static inline unsigned long osmo_counter_get(struct osmo_counter *ctr)
17 {
18         return ctr->value;
19 }
20
21 static inline void osmo_counter_reset(struct osmo_counter *ctr)
22 {
23         ctr->value = 0;
24 }
25
26 struct osmo_counter *osmo_counter_alloc(const char *name);
27 void osmo_counter_free(struct osmo_counter *ctr);
28
29 int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
30
31 struct osmo_counter *osmo_counter_get_by_name(const char *name);
32
33 #endif /* _STATISTICS_H */