aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-11-15 15:29:24 -0500
committerNick Mathewson <nickm@torproject.org>2013-11-15 15:29:24 -0500
commit59f50c80d443a7e148f85cfed493e3e703cc4386 (patch)
treebdaef44fe052c88c81c3e5fb130837f6ebc65202 /src/common
parenta82b18f2168ce19e0637740fed5746d6daac4e3a (diff)
parent9e907076025ccd91abfad7fc70c09ba4c9228f82 (diff)
downloadtor-59f50c80d443a7e148f85cfed493e3e703cc4386.tar
tor-59f50c80d443a7e148f85cfed493e3e703cc4386.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.3' into maint-0.2.4
Conflicts: src/or/or.h src/or/relay.c Conflicts were simple to resolve. More fixes were needed for compilation, including: reinstating the tv_to_msec function, and renaming *_conn_cells to *_chan_cells.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c12
-rw-r--r--src/common/util.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index ae385e1b9..5eb0f9a69 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1232,6 +1232,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 96a02dd77..73daa6e2a 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);