+static inline void cnt_add(counter_t *dst, const counter_t *src)
+{
+ int i, carry = 0;
+
+ for (i = 0; i < STAT_CNT_NUM; ++i) {
+ unsigned x = dst->cnt[i];
+ unsigned y = src->cnt[i];
+ unsigned a = x + y + carry;
+
+ carry = (int)((x & y) | ((x | y) & ~a)) < 0 ? 1 : 0;
+
+ dst->cnt[i] = a;
+ }
+}
+
+/**
+ * add an (positive) integer to an counter
+ */
+static inline void cnt_add_i(counter_t *dst, int src)
+{
+ int i;
+ unsigned carry = src;
+
+ for (i = 0; i < STAT_CNT_NUM; ++i) {
+ unsigned a = dst->cnt[i] + carry;
+
+ carry = a < dst->cnt[i];
+
+ dst->cnt[i] = a;
+
+ if (! carry)
+ break;
+ }
+}
+
+/**
+ * compare two counter
+ */
+static inline int cnt_cmp(const counter_t *a, const counter_t *b)
+{
+ int i;
+ unsigned va = 0;
+ unsigned vb = 0;
+
+ for (i = STAT_CNT_NUM - 1 ; i >= 0; --i) {
+ va = a->cnt[i];
+ vb = b->cnt[i];
+
+ if (va != vb)
+ break;
+ }
+
+ if (va != vb)
+ return va < vb ? -1 : 1;
+ return 0;
+}
+
+/**
+ * convert a counter into a double
+ */
+static inline double cnt_to_dbl(const counter_t *a)