From e5b0fe2e3c84dd0de7021d65d416356612db4260 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 15:00:59 +0200 Subject: core: Update osmo_counters_for_each doc Fix type and add a note about the semantics of the handler's return code. Sponsored-by: On-Waves ehf --- include/osmocom/core/statistics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/osmocom/core/statistics.h') diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index de250bec..a9a623d3 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -37,8 +37,8 @@ struct osmo_counter *osmo_counter_alloc(const char *name); */ void osmo_counter_free(struct osmo_counter *ctr); -/*! \brief Iteate over all counters - * \param[in] handle_counter Call-back function +/*! \brief Iterate over all counters + * \param[in] handle_counter Call-back function, aborts if rc < 0 * \param[in] data Private dtata handed through to \a handle_counter */ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data); -- cgit v1.2.3 From 80db4ec3875b0de7f06de769881d6c5d4b713f2d Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 14:39:08 +0100 Subject: core: Add difference function to osmo_counter The osmo_counter_difference returns the counter value difference since the last call of this function with the given counter object. Sponsored-by: On-Waves ehf --- include/osmocom/core/statistics.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/osmocom/core/statistics.h') diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index a9a623d3..1e472ffd 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -9,6 +9,7 @@ struct osmo_counter { const char *name; /*!< \brief human-readable name */ const char *description; /*!< \brief humn-readable description */ unsigned long value; /*!< \brief current value */ + unsigned long previous; /*!< \brief previous value */ }; /*! \brief Increment counter */ @@ -48,3 +49,6 @@ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), * \returns pointer to counter (\ref osmo_counter) or NULL otherwise */ struct osmo_counter *osmo_counter_get_by_name(const char *name); + +/*! \brief Return the counter difference since the last call to this function */ +int osmo_counter_difference(struct osmo_counter *ctr); -- cgit v1.2.3