stats: Add osmo_ name prefix to identifiers

Since the the stat_item and stats functions and data types are meant
to be exported, they get an osmo_ prefix.

Sponsored-by: On-Waves ehf

[hfreyther: Prepended the enum values too. This was requested by
Jacob]
diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h
index 0786a3b..4047495 100644
--- a/include/osmocom/core/stat_item.h
+++ b/include/osmocom/core/stat_item.h
@@ -1,6 +1,6 @@
 #pragma once
 
-/*! \defgroup stat_item Statistics value item
+/*! \defgroup osmo_stat_item Statistics value item
  *  @{
  */
 
@@ -10,28 +10,28 @@
 
 #include <osmocom/core/linuxlist.h>
 
-struct stat_item_desc;
+struct osmo_stat_item_desc;
 
 #define STAT_ITEM_NOVALUE_ID 0
 
-struct stat_item_value {
+struct osmo_stat_item_value {
 	int32_t id;
 	int32_t value;
 };
 
 /*! \brief data we keep for each actual value */
-struct stat_item {
-	const struct stat_item_desc *desc;
+struct osmo_stat_item {
+	const struct osmo_stat_item_desc *desc;
 	/*! \brief the index of the freshest value */
 	int32_t last_value_index;
 	/*! \brief offset to the freshest value in the value fifo */
 	int16_t last_offs;
 	/*! \brief value fifo */
-	struct stat_item_value values[0];
+	struct osmo_stat_item_value values[0];
 };
 
 /*! \brief statistics value description */
-struct stat_item_desc {
+struct osmo_stat_item_desc {
 	const char *name;	/*!< \brief name of the item */
 	const char *description;/*!< \brief description of the item */
 	const char *unit;	/*!< \brief unit of a value */
@@ -40,7 +40,7 @@
 };
 
 /*! \brief description of a statistics value group */
-struct stat_item_group_desc {
+struct osmo_stat_item_group_desc {
 	/*! \brief The prefix to the name of all values in this group */
 	const char *group_name_prefix;
 	/*! \brief The human-readable description of the group */
@@ -48,80 +48,80 @@
 	/*! \brief The number of values in this group */
 	const unsigned int num_items;
 	/*! \brief Pointer to array of value names */
-	const struct stat_item_desc *item_desc;
+	const struct osmo_stat_item_desc *item_desc;
 };
 
 /*! \brief One instance of a counter group class */
-struct stat_item_group {
+struct osmo_stat_item_group {
 	/*! \brief Linked list of all value groups in the system */
 	struct llist_head list;
 	/*! \brief Pointer to the counter group class */
-	const struct stat_item_group_desc *desc;
+	const struct osmo_stat_item_group_desc *desc;
 	/*! \brief The index of this value group within its class */
 	unsigned int idx;
 	/*! \brief Actual counter structures below */
-	struct stat_item *items[0];
+	struct osmo_stat_item *items[0];
 };
 
-struct stat_item_group *stat_item_group_alloc(
+struct osmo_stat_item_group *osmo_stat_item_group_alloc(
 	void *ctx,
-	const struct stat_item_group_desc *desc,
+	const struct osmo_stat_item_group_desc *desc,
 	unsigned int idx);
 
-void stat_item_group_free(struct stat_item_group *statg);
+void osmo_stat_item_group_free(struct osmo_stat_item_group *statg);
 
-void stat_item_set(struct stat_item *item, int32_t value);
+void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value);
 
-int stat_item_init(void *tall_ctx);
+int osmo_stat_item_init(void *tall_ctx);
 
-struct stat_item_group *stat_item_get_group_by_name_idx(
+struct osmo_stat_item_group *osmo_stat_item_get_group_by_name_idx(
 	const char *name, const unsigned int idx);
 
-const struct stat_item *stat_item_get_by_name(
-	const struct stat_item_group *statg, const char *name);
+const struct osmo_stat_item *osmo_stat_item_get_by_name(
+	const struct osmo_stat_item_group *statg, const char *name);
 
-/*! \brief Retrieve the next value from the stat_item object.
+/*! \brief Retrieve the next value from the osmo_stat_item object.
  * If a new value has been set, it is returned. The idx is used to decide
  * which value to return.
  * On success, *idx is updated to refer to the next unread value. If
  * values have been missed due to FIFO overflow, *idx is incremented by
  * (1 + num_lost).
- * This way, the stat_item object can be kept stateless from the reader's
+ * This way, the osmo_stat_item object can be kept stateless from the reader's
  * perspective and therefore be used by several backends simultaneously.
  *
- * \param val	the stat_item object
+ * \param val	the osmo_stat_item object
  * \param idx	identifies the next value to be read
  * \param value	a pointer to store the value
  * \returns  the increment of the index (0: no value has been read,
  *           1: one value has been taken,
  *           (1+n): n values have been skipped, one has been taken)
  */
-int stat_item_get_next(const struct stat_item *item, int32_t *idx, int32_t *value);
+int osmo_stat_item_get_next(const struct osmo_stat_item *item, int32_t *idx, int32_t *value);
 
 /*! \brief Get the last (freshest) value */
-static int32_t stat_item_get_last(const struct stat_item *item);
+static int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item);
 
 /*! \brief Skip all values of the item and update idx accordingly */
-int stat_item_discard(const struct stat_item *item, int32_t *idx);
+int osmo_stat_item_discard(const struct osmo_stat_item *item, int32_t *idx);
 
 /*! \brief Skip all values of all items and update idx accordingly */
-int stat_item_discard_all(int32_t *idx);
+int osmo_stat_item_discard_all(int32_t *idx);
 
-typedef int (*stat_item_handler_t)(
-	struct stat_item_group *, struct stat_item *, void *);
+typedef int (*osmo_stat_item_handler_t)(
+	struct osmo_stat_item_group *, struct osmo_stat_item *, void *);
 
-typedef int (*stat_item_group_handler_t)(struct stat_item_group *, void *);
+typedef int (*osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *);
 
 /*! \brief Iteate over all items
  *  \param[in] handle_item Call-back function, aborts if rc < 0
  *  \param[in] data Private data handed through to \a handle_item
  */
-int stat_item_for_each_item(struct stat_item_group *statg,
-	stat_item_handler_t handle_item, void *data);
+int osmo_stat_item_for_each_item(struct osmo_stat_item_group *statg,
+	osmo_stat_item_handler_t handle_item, void *data);
 
-int stat_item_for_each_group(stat_item_group_handler_t handle_group, void *data);
+int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, void *data);
 
-static inline int32_t stat_item_get_last(const struct stat_item *item)
+static inline int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
 {
 	return item->values[item->last_offs].value;
 }
diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h
index 68c2e01..7b3d021 100644
--- a/include/osmocom/core/stats.h
+++ b/include/osmocom/core/stats.h
@@ -23,18 +23,18 @@
 #include <osmocom/core/linuxlist.h>
 
 struct msgb;
-struct stat_item_group;
-struct stat_item_desc;
+struct osmo_stat_item_group;
+struct osmo_stat_item_desc;
 struct rate_ctr_group;
 struct rate_ctr_desc;
 
-enum stats_reporter_type {
-	STATS_REPORTER_STATSD,
-	STATS_REPORTER_LOG,
+enum osmo_stats_reporter_type {
+	OSMO_STATS_REPORTER_STATSD,
+	OSMO_STATS_REPORTER_LOG,
 };
 
-struct stats_reporter {
-	enum stats_reporter_type type;
+struct osmo_stats_reporter {
+	enum osmo_stats_reporter_type type;
 	char *name;
 
 	unsigned int have_net_config : 1;
@@ -58,43 +58,43 @@
 	int agg_enabled;
 
 	struct llist_head list;
-	int (*open)(struct stats_reporter *srep);
-	int (*close)(struct stats_reporter *srep);
-	int (*send_counter)(struct stats_reporter *srep,
+	int (*open)(struct osmo_stats_reporter *srep);
+	int (*close)(struct osmo_stats_reporter *srep);
+	int (*send_counter)(struct osmo_stats_reporter *srep,
 		const struct rate_ctr_group *ctrg,
 		const struct rate_ctr_desc *desc,
 		int64_t value, int64_t delta);
-	int (*send_item)(struct stats_reporter *srep,
-		const struct stat_item_group *statg,
-		const struct stat_item_desc *desc,
+	int (*send_item)(struct osmo_stats_reporter *srep,
+		const struct osmo_stat_item_group *statg,
+		const struct osmo_stat_item_desc *desc,
 		int32_t value);
 };
 
-struct stats_config {
+struct osmo_stats_config {
 	int interval;
 };
 
-extern struct stats_config *stats_config;
+extern struct osmo_stats_config *osmo_stats_config;
 
-void stats_init(void *ctx);
-int stats_report();
+void osmo_stats_init(void *ctx);
+int osmo_stats_report();
 
-int stats_set_interval(int interval);
+int osmo_stats_set_interval(int interval);
 
-struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
+struct osmo_stats_reporter *osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type,
 	const char *name);
-void stats_reporter_free(struct stats_reporter *srep);
+void osmo_stats_reporter_free(struct osmo_stats_reporter *srep);
 
-struct stats_reporter *stats_reporter_create_statsd(const char *name);
-struct stats_reporter *stats_reporter_create_log(const char *name);
+struct osmo_stats_reporter *osmo_stats_reporter_create_statsd(const char *name);
+struct osmo_stats_reporter *osmo_stats_reporter_create_log(const char *name);
 
-struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
+struct osmo_stats_reporter *osmo_stats_reporter_find(enum osmo_stats_reporter_type type,
 	const char *name);
 
-int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr);
-int stats_reporter_set_remote_port(struct stats_reporter *srep, int port);
-int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr);
-int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu);
-int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix);
-int stats_reporter_enable(struct stats_reporter *srep);
-int stats_reporter_disable(struct stats_reporter *srep);
+int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr);
+int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port);
+int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr);
+int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu);
+int osmo_stats_reporter_set_name_prefix(struct osmo_stats_reporter *srep, const char *prefix);
+int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep);
+int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep);
diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h
index 42e0d88..7c3b23c 100644
--- a/include/osmocom/gprs/gprs_ns.h
+++ b/include/osmocom/gprs/gprs_ns.h
@@ -126,7 +126,7 @@
 	unsigned int nsvci_is_valid:1;
 
 	struct rate_ctr_group *ctrg;
-	struct stat_item_group *statg;
+	struct osmo_stat_item_group *statg;
 
 	/*! \brief which link-layer are we based on? */
 	enum gprs_ns_ll ll;
diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h
index 99c2ee6..f3b46db 100644
--- a/include/osmocom/vty/misc.h
+++ b/include/osmocom/vty/misc.h
@@ -14,7 +14,7 @@
 			    struct rate_ctr_group *ctrg);
 
 void vty_out_stat_item_group(struct vty *vty, const char *prefix,
-			     struct stat_item_group *statg);
+			     struct osmo_stat_item_group *statg);
 
 void vty_out_statistics_full(struct vty *vty, const char *prefix);
 
diff --git a/include/osmocom/vty/stats.h b/include/osmocom/vty/stats.h
index eaf854e..3851b4d 100644
--- a/include/osmocom/vty/stats.h
+++ b/include/osmocom/vty/stats.h
@@ -1,3 +1,3 @@
 #pragma once
 
-void stats_vty_add_cmds();
+void osmo_stats_vty_add_cmds();