Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1 | #ifndef _STATISTICS_H |
| 2 | #define _STATISTICS_H |
| 3 | |
| 4 | struct counter { |
| 5 | struct llist_head list; |
| 6 | const char *name; |
| 7 | const char *description; |
| 8 | unsigned long value; |
| 9 | }; |
| 10 | |
| 11 | static inline void counter_inc(struct counter *ctr) |
| 12 | { |
| 13 | ctr->value++; |
| 14 | } |
| 15 | |
| 16 | static inline unsigned long counter_get(struct counter *ctr) |
| 17 | { |
| 18 | return ctr->value; |
| 19 | } |
| 20 | |
| 21 | static inline void counter_reset(struct counter *ctr) |
| 22 | { |
| 23 | ctr->value = 0; |
| 24 | } |
| 25 | |
| 26 | struct counter *counter_alloc(const char *name); |
| 27 | void counter_free(struct counter *ctr); |
| 28 | |
| 29 | int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data); |
| 30 | |
| 31 | #endif /* _STATISTICS_H */ |