aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/math')
-rw-r--r--src/lib/math/stats.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/math/stats.h b/src/lib/math/stats.h
index fae93c6213..328d61a9d6 100644
--- a/src/lib/math/stats.h
+++ b/src/lib/math/stats.h
@@ -13,7 +13,10 @@
/** Update an average making it a "running average". The "avg" is the current
* value that will be updated to the new one. The "value" is the new value to
* add to the average and "n" is the new count as in including the "value". */
-#define STATS_UPDATE_AVG(avg, value, n) \
- avg = ((avg) * ((n) - 1) + (value)) / (n)
+static inline double
+stats_update_running_avg(double avg, double value, double n)
+{
+ return ((avg * (n - 1)) + value) / n;
+}
#endif /* !defined(TOR_STATS_H) */