summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/include/osmocom/core/statistics.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/libosmocore/include/osmocom/core/statistics.h')
-rw-r--r--src/shared/libosmocore/include/osmocom/core/statistics.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/shared/libosmocore/include/osmocom/core/statistics.h b/src/shared/libosmocore/include/osmocom/core/statistics.h
new file mode 100644
index 00000000..2c159657
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/statistics.h
@@ -0,0 +1,33 @@
+#ifndef _STATISTICS_H
+#define _STATISTICS_H
+
+struct counter {
+ struct llist_head list;
+ const char *name;
+ const char *description;
+ unsigned long value;
+};
+
+static inline void counter_inc(struct counter *ctr)
+{
+ ctr->value++;
+}
+
+static inline unsigned long counter_get(struct counter *ctr)
+{
+ return ctr->value;
+}
+
+static inline void counter_reset(struct counter *ctr)
+{
+ ctr->value = 0;
+}
+
+struct counter *counter_alloc(const char *name);
+void counter_free(struct counter *ctr);
+
+int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
+
+struct counter *counter_get_by_name(const char *name);
+
+#endif /* _STATISTICS_H */