long long timeval_diff_usecs(const struct timeval *tv1,
const struct timeval *tv2);
+static inline void
+timeval_add_msecs(struct timeval *tv, unsigned int msecs)
+{
+ tv->tv_sec += msecs / 1000;
+ tv->tv_usec += (msecs % 1000) * 1000;
+ if (tv->tv_usec >= 1000000) {
+ tv->tv_sec++;
+ tv->tv_usec -= 1000000;
+ }
+}
+
+static inline void
+timeval_sub_msecs(struct timeval *tv, unsigned int msecs)
+{
+ tv->tv_sec -= msecs / 1000;
+ tv->tv_usec -= (msecs % 1000) * 1000;
+ if (tv->tv_usec < 0) {
+ tv->tv_sec--;
+ tv->tv_usec += 1000000;
+ }
+}
+
/* Wrapper to strftime() */
const char *t_strflocaltime(const char *fmt, time_t t) ATTR_STRFTIME(1);