It's not just a simple (old - new), because wrap-around is handled, too.
return n;
}
+counter_t counter_diff (counter_t old_value, counter_t new_value)
+{
+ counter_t diff;
+
+ if (old_value > new_value)
+ {
+ if (old_value <= 4294967295U)
+ diff = (4294967295U - old_value) + new_value;
+ else
+ diff = (18446744073709551615ULL - old_value)
+ + new_value;
+ }
+ else
+ {
+ diff = new_value - old_value;
+ }
+ return (diff);
+} /* counter_t counter_to_gauge */
void *user_data);
int read_file_contents (const char *filename, char *buf, int bufsize);
+counter_t counter_diff (counter_t old_value, counter_t new_value);
+
#endif /* COMMON_H */