summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/util/time.c9
-rw-r--r--lib/util/time.h5
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c
index 4843fc9697..de1553aff8 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -580,6 +580,15 @@ _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
}
/**
+ return a timeval milliseconds into the future
+*/
+_PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs)
+{
+ struct timeval tv = timeval_current();
+ return timeval_add(&tv, msecs / 1000, (msecs % 1000) * 1000);
+}
+
+/**
compare two timeval structures.
Return -1 if tv1 < tv2
Return 0 if tv1 == tv2
diff --git a/lib/util/time.h b/lib/util/time.h
index 3a406340f4..4e4f72f71f 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -213,6 +213,11 @@ struct timeval timeval_sum(const struct timeval *tv1,
_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs);
/**
+ return a timeval milliseconds into the future
+*/
+_PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs);
+
+/**
compare two timeval structures.
Return -1 if tv1 < tv2
Return 0 if tv1 == tv2