mirror of https://gerrit.osmocom.org/libosmocore
statistics: use namespace prefix osmo_counter*
Summary of changes: s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free/g s/counters_for_each/osmo_counters_for_each/g
This commit is contained in:
parent
9111d930a5
commit
220abab3fa
|
@ -1,33 +1,33 @@
|
||||||
#ifndef _STATISTICS_H
|
#ifndef _STATISTICS_H
|
||||||
#define _STATISTICS_H
|
#define _STATISTICS_H
|
||||||
|
|
||||||
struct counter {
|
struct osmo_counter {
|
||||||
struct llist_head list;
|
struct llist_head list;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void counter_inc(struct counter *ctr)
|
static inline void osmo_counter_inc(struct osmo_counter *ctr)
|
||||||
{
|
{
|
||||||
ctr->value++;
|
ctr->value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long counter_get(struct counter *ctr)
|
static inline unsigned long osmo_counter_get(struct osmo_counter *ctr)
|
||||||
{
|
{
|
||||||
return ctr->value;
|
return ctr->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void counter_reset(struct counter *ctr)
|
static inline void osmo_counter_reset(struct osmo_counter *ctr)
|
||||||
{
|
{
|
||||||
ctr->value = 0;
|
ctr->value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct counter *counter_alloc(const char *name);
|
struct osmo_counter *osmo_counter_alloc(const char *name);
|
||||||
void counter_free(struct counter *ctr);
|
void osmo_counter_free(struct osmo_counter *ctr);
|
||||||
|
|
||||||
int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
|
int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
|
||||||
|
|
||||||
struct counter *counter_get_by_name(const char *name);
|
struct osmo_counter *osmo_counter_get_by_name(const char *name);
|
||||||
|
|
||||||
#endif /* _STATISTICS_H */
|
#endif /* _STATISTICS_H */
|
||||||
|
|
|
@ -30,9 +30,9 @@ static LLIST_HEAD(counters);
|
||||||
|
|
||||||
void *tall_ctr_ctx;
|
void *tall_ctr_ctx;
|
||||||
|
|
||||||
struct counter *counter_alloc(const char *name)
|
struct osmo_counter *osmo_counter_alloc(const char *name)
|
||||||
{
|
{
|
||||||
struct counter *ctr = talloc_zero(tall_ctr_ctx, struct counter);
|
struct osmo_counter *ctr = talloc_zero(tall_ctr_ctx, struct osmo_counter);
|
||||||
|
|
||||||
if (!ctr)
|
if (!ctr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -43,15 +43,16 @@ struct counter *counter_alloc(const char *name)
|
||||||
return ctr;
|
return ctr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void counter_free(struct counter *ctr)
|
void osmo_counter_free(struct osmo_counter *ctr)
|
||||||
{
|
{
|
||||||
llist_del(&ctr->list);
|
llist_del(&ctr->list);
|
||||||
talloc_free(ctr);
|
talloc_free(ctr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data)
|
int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *),
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
struct counter *ctr;
|
struct osmo_counter *ctr;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
llist_for_each_entry(ctr, &counters, list) {
|
llist_for_each_entry(ctr, &counters, list) {
|
||||||
|
@ -63,9 +64,9 @@ int counters_for_each(int (*handle_counter)(struct counter *, void *), void *dat
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct counter *counter_get_by_name(const char *name)
|
struct osmo_counter *osmo_counter_get_by_name(const char *name)
|
||||||
{
|
{
|
||||||
struct counter *ctr;
|
struct osmo_counter *ctr;
|
||||||
|
|
||||||
llist_for_each_entry(ctr, &counters, list) {
|
llist_for_each_entry(ctr, &counters, list) {
|
||||||
if (!strcmp(ctr->name, name))
|
if (!strcmp(ctr->name, name))
|
||||||
|
|
Loading…
Reference in New Issue