summaryrefslogtreecommitdiff
path: root/src/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/timer.h')
-rw-r--r--src/timer.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/timer.h b/src/timer.h
index accad5b..627bdb2 100644
--- a/src/timer.h
+++ b/src/timer.h
@@ -44,6 +44,21 @@ struct timezone
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz);
+
+/**
+ * timersub(3) from <sys/time.h>
+ */
+static inline void timersub(struct timeval* a, struct timeval* b,
+ struct timeval* res)
+{
+ res->tv_sec = a->tv_sec - b->tv_sec;
+ res->tv_usec = a->tv_usec - b->tv_usec;
+ if (res->tv_usec < 0)
+ {
+ res->tv_usec += 1000000;
+ res->tv_sec--;
+ }
+}
#endif
/* Interface avec select */