Provide cgtimer_to_timeval helper functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/util.c b/util.c
index 6e82ab7..8186c1a 100644
--- a/util.c
+++ b/util.c
@@ -817,6 +817,11 @@ void timeval_to_cgtimer(cgtimer_t *cgt, const struct timeval *tv)
{
timeval_to_spec(cgt, tv);
}
+
+void cgtimer_to_timeval(struct timeval *tv, const cgtimer_t *cgt)
+{
+ timespec_to_val(tv, cgt);
+}
#else
static void dtime_to_timeval(struct timeval *tv, DWORD dtime)
{
@@ -845,6 +850,11 @@ void timeval_to_cgtimer(cgtimer_t *cgt, const struct timeval *tv)
{
timeval_to_dtime(cgt, tv);
}
+
+void cgtimer_to_timeval(struct timeval *tv, const cgtimer_t *cgt)
+{
+ dtime_to_timeval(tv, *cgt);
+}
#endif
void subtime(struct timeval *a, struct timeval *b)
diff --git a/util.h b/util.h
index 35a267e..fefccb2 100644
--- a/util.h
+++ b/util.h
@@ -76,6 +76,7 @@ void nmsleep(unsigned int msecs);
void nusleep(unsigned int usecs);
void cgtime(struct timeval *tv);
void timeval_to_cgtimer(cgtimer_t *cgt, const struct timeval *tv);
+void cgtimer_to_timeval(struct timeval *tv, const cgtimer_t *cgt);
void subtime(struct timeval *a, struct timeval *b);
void addtime(struct timeval *a, struct timeval *b);
bool time_more(struct timeval *a, struct timeval *b);