[tor-commits] [tor/master] lround() missing in MSVC
nickm at torproject.org
nickm at torproject.org
Wed Aug 24 17:53:29 UTC 2011
commit 5939c09d35de5be4b135bb0ad6dde24700e75fc2
Author: Gisle Vanem <gvanem at broadpark.no>
Date: Wed Aug 24 13:52:44 2011 -0400
lround() missing in MSVC
lround() is missing in MS Visual-C's <math.h>. Not available anywhere.
Here is an easy patch.
---
changes/msvc_lround | 4 ++++
src/common/util.c | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/changes/msvc_lround b/changes/msvc_lround
new file mode 100644
index 0000000..e4aea95
--- /dev/null
+++ b/changes/msvc_lround
@@ -0,0 +1,4 @@
+ o Build fixes:
+ - Provide a substitute implementation of lround() for MSVC, which
+ apparently lacks it. Patch from Gisle Vanem.
+
diff --git a/src/common/util.c b/src/common/util.c
index b47b9c5..ee0acbb 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -334,7 +334,11 @@ tor_mathlog(double d)
long
tor_lround(double d)
{
+#ifdef _MSC_VER
+ return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
+#else
return lround(d);
+#endif
}
/** Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0. */
More information about the tor-commits
mailing list