123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- extern "C" {
- struct stats_name_map {
- uint16_t snm_off;
- const char *snm_name;
- } __attribute__((packed));
- struct stats_hdr {
- const char *s_name;
- uint8_t s_size;
- uint16_t s_cnt;
- uint8_t s_pad1;
- const struct stats_name_map *s_map;
- int s_map_cnt;
- struct stats_hdr *s_next;
- };
- struct stats_
- STATS_SECT_DECL(group__) { \
- struct stats_hdr s_hdr;
- ((group__).var__ += (n__))
- STATS_INCN(group__, var__, 1)
- ((group__).var__ = 0)
- (size__), \
- ((sizeof(group__)) - sizeof(struct stats_hdr)) / (size__)
- stats_init_and_reg( \
- &(group__).s_hdr, \
- (size__), \
- (sizeof(group__) - sizeof(struct stats_hdr)) / (size__), \
- STATS_NAME_INIT_PARMS(group__), \
- (name__))
- void stats_init(struct stats_hdr *shdr, uint8_t size, uint16_t cnt,
- const struct stats_name_map *map, uint16_t map_cnt);
- int stats_register(const char *name, struct stats_hdr *shdr);
- int stats_init_and_reg(struct stats_hdr *hdr, uint8_t size, uint16_t cnt,
- const struct stats_name_map *map, uint16_t map_cnt,
- const char *name);
- void stats_reset(struct stats_hdr *shdr);
- typedef int stats_walk_fn(struct stats_hdr *hdr, void *arg,
- const char *name, uint16_t off);
- int stats_walk(struct stats_hdr *hdr, stats_walk_fn *walk_cb, void *arg);
- typedef int stats_group_walk_fn(struct stats_hdr *hdr, void *arg);
- int stats_group_walk(stats_group_walk_fn *walk_cb, void *arg);
- struct stats_hdr *stats_group_get_next(const struct stats_hdr *cur);
- struct stats_hdr *stats_group_find(const char *name);
- STATS_SECT_DECL(group__) {
- const struct stats_name_map STATS_NAME_MAP_NAME(sectname__)[] = {
- { offsetof(STATS_SECT_DECL(sectname__), entry__),
- &(STATS_NAME_MAP_NAME(name__)[0]), \
- (sizeof(STATS_NAME_MAP_NAME(name__)) / sizeof(struct stats_name_map))
- }
|