aboutsummaryrefslogtreecommitdiffstats
path: root/libosmocore/include/osmocore/statistics.h
diff options
context:
space:
mode:
authorHarald Welte <laforge@netfilter.org>2010-02-20 16:24:02 +0100
committerHarald Welte <laforge@netfilter.org>2010-02-20 16:27:23 +0100
commitdfe6c7d910edbba238751d0cfddbb627bb08ef54 (patch)
treec4836091b0d65187ee50c52060d51117b21ac873 /libosmocore/include/osmocore/statistics.h
parent9442c1b9bad3426ece07edc7fa2dca7464fc302a (diff)
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality of all Osmocom.org projects, including OpenBSC but also OsmocomBB The library currently includes the following modules: bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer, tlv_parse, linuxlist msgb allocation error debugging had to be temporarily disabled as it depends on 'debug.c' functionality which at the moment remains in OpenBSC
Diffstat (limited to 'libosmocore/include/osmocore/statistics.h')
-rw-r--r--libosmocore/include/osmocore/statistics.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/libosmocore/include/osmocore/statistics.h b/libosmocore/include/osmocore/statistics.h
new file mode 100644
index 000000000..1d56054ab
--- /dev/null
+++ b/libosmocore/include/osmocore/statistics.h
@@ -0,0 +1,31 @@
+#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);
+
+#endif /* _STATISTICS_H */