diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-02-20 20:34:29 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-02-20 20:34:29 +0100 |
commit | ec8b4501c7b0bfb286db7789635168d1b84f9105 (patch) | |
tree | 0db0073e589513d803d2b5be80580191e215dbe3 /include/osmocore/statistics.h |
intial checkin of the libosmocore project
Diffstat (limited to 'include/osmocore/statistics.h')
-rw-r--r-- | include/osmocore/statistics.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/osmocore/statistics.h b/include/osmocore/statistics.h new file mode 100644 index 00000000..1d56054a --- /dev/null +++ b/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 */ |