diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-09-11 17:51:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-09-11 17:51:36 -0400 |
commit | 75c9ccd4f851bac6d32cb08ded557ac207bc8002 (patch) | |
tree | 0edd289ca5453ebfad30d52bc55665bad1e76fe0 /src/common/util.c | |
parent | b8f93c5dd7a069c9e5ac3469d067a31c3992fa25 (diff) | |
parent | 9982122f3448293e80adf83cb28c7ab66bc04da9 (diff) | |
download | tor-75c9ccd4f851bac6d32cb08ded557ac207bc8002.tar.gz tor-75c9ccd4f851bac6d32cb08ded557ac207bc8002.zip |
Merge remote-tracking branch 'public/bug6538'
Conflicts:
configure.ac
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c index c2dfb54322..e79e73a0ff 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -333,7 +333,7 @@ tor_mathlog(double d) } /** Return the long integer closest to d. We define this wrapper here so - * that not all users of math.h need to use the right incancations to get + * that not all users of math.h need to use the right intancations to get * the c99 functions. */ long tor_lround(double d) @@ -347,6 +347,21 @@ tor_lround(double d) #endif } +/** Return the 64-bit integer closest to d. We define this wrapper here so + * that not all users of math.h need to use the right incantations to get the + * c99 functions. */ +int64_t +tor_llround(double d) +{ +#if defined(HAVE_LLROUND) + return (int64_t)llround(d); +#elif defined(HAVE_RINT) + return (int64_t)rint(d); +#else + return (int64_t)(d > 0 ? d + 0.5 : ceil(d - 0.5)); +#endif +} + /** Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0. */ int tor_log2(uint64_t u64) |