From de2075fd2186ccf0563163e1b4295ff152860c3f Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 1 Sep 2017 12:18:36 +0200 Subject: [PATCH] MINOR: freq_ctr: Return the new value after an update This will ease threads support integration. --- include/proto/freq_ctr.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/proto/freq_ctr.h b/include/proto/freq_ctr.h index 70b295e..0d04110 100644 --- a/include/proto/freq_ctr.h +++ b/include/proto/freq_ctr.h @@ -45,14 +45,15 @@ static inline void rotate_freq_ctr(struct freq_ctr *ctr) * rotated if the period is over. It is important that it correctly initializes * a null area. */ -static inline void update_freq_ctr(struct freq_ctr *ctr, unsigned int inc) +static inline unsigned int update_freq_ctr(struct freq_ctr *ctr, unsigned int inc) { if (likely(ctr->curr_sec == now.tv_sec)) { ctr->curr_ctr += inc; - return; + return ctr->curr_ctr; } rotate_freq_ctr(ctr); ctr->curr_ctr = inc; + return ctr->curr_ctr; /* Note: later we may want to propagate the update to other counters */ } @@ -79,15 +80,16 @@ static inline void rotate_freq_ctr_period(struct freq_ctr_period *ctr, * a null area. This one works on frequency counters which have a period * different from one second. */ -static inline void update_freq_ctr_period(struct freq_ctr_period *ctr, - unsigned int period, unsigned int inc) +static inline unsigned int update_freq_ctr_period(struct freq_ctr_period *ctr, + unsigned int period, unsigned int inc) { if (likely(now_ms - ctr->curr_tick < period)) { ctr->curr_ctr += inc; - return; + return ctr->curr_ctr; } rotate_freq_ctr_period(ctr, period); ctr->curr_ctr = inc; + return ctr->curr_ctr; /* Note: later we may want to propagate the update to other counters */ } -- 1.7.10.4