libosmocore  0.6.3
Osmocom core library
statistics.h
Go to the documentation of this file.
1 #ifndef _STATISTICS_H
2 #define _STATISTICS_H
3 
8 struct osmo_counter {
9  struct llist_head list;
10  const char *name;
11  const char *description;
12  unsigned long value;
13 };
14 
16 static inline void osmo_counter_inc(struct osmo_counter *ctr)
17 {
18  ctr->value++;
19 }
20 
22 static inline unsigned long osmo_counter_get(struct osmo_counter *ctr)
23 {
24  return ctr->value;
25 }
26 
28 static inline void osmo_counter_reset(struct osmo_counter *ctr)
29 {
30  ctr->value = 0;
31 }
32 
34 struct osmo_counter *osmo_counter_alloc(const char *name);
35 
39 void osmo_counter_free(struct osmo_counter *ctr);
40 
45 int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
46 
51 struct osmo_counter *osmo_counter_get_by_name(const char *name);
52 
53 #endif /* _STATISTICS_H */