aboutsummaryrefslogtreecommitdiffstats
path: root/src/stat_item.c
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2019-04-27 23:19:55 +0200
committerHarald Welte <laforge@gnumonks.org>2019-05-07 13:20:57 +0000
commitcc72cc45a49b13b0c5147a7af21c083e47ca73f5 (patch)
tree7223813047542b5e2a27011e99a12fe50be25efb /src/stat_item.c
parentaa98c481fa7888e2bcd9d5c9ae1993744ee47f33 (diff)
add osmo_stat_item_inc/osmo_stat_item_dec to set it relative
Diffstat (limited to 'src/stat_item.c')
-rw-r--r--src/stat_item.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/stat_item.c b/src/stat_item.c
index cb9b90fe..67165754 100644
--- a/src/stat_item.c
+++ b/src/stat_item.c
@@ -150,6 +150,30 @@ void osmo_stat_item_group_free(struct osmo_stat_item_group *grp)
talloc_free(grp);
}
+/*! Increase the stat_item to the given value.
+ * This function adds a new value for the given stat_item at the end of
+ * the FIFO.
+ * \param[in] item The stat_item whose \a value we want to set
+ * \param[in] value The numeric value we want to store at end of FIFO
+ */
+void osmo_stat_item_inc(struct osmo_stat_item *item, int32_t value)
+{
+ int32_t oldvalue = item->values[item->last_offs].value;
+ osmo_stat_item_set(item, oldvalue + value);
+}
+
+/*! Descrease the stat_item to the given value.
+ * This function adds a new value for the given stat_item at the end of
+ * the FIFO.
+ * \param[in] item The stat_item whose \a value we want to set
+ * \param[in] value The numeric value we want to store at end of FIFO
+ */
+void osmo_stat_item_dec(struct osmo_stat_item *item, int32_t value)
+{
+ int32_t oldvalue = item->values[item->last_offs].value;
+ osmo_stat_item_set(item, oldvalue - value);
+}
+
/*! Set the a given stat_item to the given value.
* This function adds a new value for the given stat_item at the end of
* the FIFO.