--- /dev/null
+#include "time.h"
+
+void
+time_add(struct timeval *tv, long microseconds)
+{
+ tv->tv_usec += microseconds;
+ while (tv->tv_usec >= 1000000) {
+ tv->tv_usec -= 1000000;
+ ++tv->tv_sec;
+ }
+ while (tv->tv_usec < 0) {
+ tv->tv_usec += 1000000;
+ --tv->tv_sec;
+ }
+}
+
+long
+time_compare(struct timeval *a, struct timeval *b)
+{
+ long r;
+ if ((r = a->tv_sec - b->tv_sec)) return r;
+ return a->tv_usec - b->tv_usec;
+}