summaryrefslogtreecommitdiff
path: root/src/common/compat_time.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-10 10:47:11 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-13 10:41:08 -0400
commitd8ef9a2d1e0701073d8209115bc3c34857c2d7b4 (patch)
treefd7439b0c9d3d743e9fcde67ae5ebc5ad785381f /src/common/compat_time.c
parent16f08de0fd85b9fe8ace9f4905190fa6dc27e4ea (diff)
downloadtor-d8ef9a2d1e0701073d8209115bc3c34857c2d7b4.tar.gz
tor-d8ef9a2d1e0701073d8209115bc3c34857c2d7b4.zip
Expose a function that computes stamp units from msec.
(It turns out we can't just expose STAMP_TICKS_PER_SECOND, since Apple doesn't have that.)
Diffstat (limited to 'src/common/compat_time.c')
-rw-r--r--src/common/compat_time.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/compat_time.c b/src/common/compat_time.c
index 183a60a480..b940447b67 100644
--- a/src/common/compat_time.c
+++ b/src/common/compat_time.c
@@ -830,11 +830,24 @@ monotime_coarse_stamp_units_to_approx_msec(uint64_t units)
return (abstime_diff * mach_time_info.numer) /
(mach_time_info.denom * ONE_MILLION);
}
+uint64_t
+monotime_msec_to_approx_coarse_stamp_units(uint64_t msec)
+{
+ uint64_t abstime_val =
+ (((uint64_t)msec) * ONE_MILLION * mach_time_info.denom) /
+ mach_time_info.numer;
+ return abstime_val >> monotime_shift;
+}
#else
uint64_t
monotime_coarse_stamp_units_to_approx_msec(uint64_t units)
{
return (units * 1000) / STAMP_TICKS_PER_SECOND;
}
+uint64_t
+monotime_msec_to_approx_coarse_stamp_units(uint64_t msec)
+{
+ return (msec * STAMP_TICKS_PER_SECOND) / 1000;
+}
#endif