diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-11-15 15:35:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-11-15 15:35:00 -0500 |
commit | 7a2b30fe16eacc040b3dd11f8c39c410628c2f43 (patch) | |
tree | 356e060be24608160a8e5d4fea33d39cc01a4c46 /src/common | |
parent | 4aa9affec2eac0a95ba026e380718b032451a0af (diff) | |
parent | 59f50c80d443a7e148f85cfed493e3e703cc4386 (diff) | |
download | tor-7a2b30fe16eacc040b3dd11f8c39c410628c2f43.tar.gz tor-7a2b30fe16eacc040b3dd11f8c39c410628c2f43.zip |
Merge remote-tracking branch 'origin/maint-0.2.4'
Conflicts:
src/or/relay.c
Conflict changes were easy; compilation fixes required were using
using TOR_SIMPLEQ_FIRST to get head of cell queue.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 12 | ||||
-rw-r--r-- | src/common/util.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index f3a6c10621..0771c9424e 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. */ diff --git a/src/common/util.h b/src/common/util.h index dcf45942f0..3199ab1129 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -253,6 +253,7 @@ int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen); /* Time helpers */ long tv_udiff(const struct timeval *start, const struct timeval *end); long tv_mdiff(const struct timeval *start, const struct timeval *end); +int64_t tv_to_msec(const struct timeval *tv); int tor_timegm(const struct tm *tm, time_t *time_out); #define RFC1123_TIME_LEN 29 void format_rfc1123_time(char *buf, time_t t); |