diff options
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index f3a6c1062..0771c9424 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1303,6 +1303,18 @@ tv_mdiff(const struct timeval *start, const struct timeval *end) return mdiff; } +/** + * Converts timeval to milliseconds. + */ +int64_t +tv_to_msec(const struct timeval *tv) +{ + int64_t conv = ((int64_t)tv->tv_sec)*1000L; + /* Round ghetto-style */ + conv += ((int64_t)tv->tv_usec+500)/1000L; + return conv; +} + /** Yield true iff <b>y</b> is a leap-year. */ #define IS_LEAPYEAR(y) (!(y % 4) && ((y % 100) || !(y % 400))) /** Helper: Return the number of leap-days between Jan 1, y1 and Jan 1, y2. */ |