]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
lround() missing in MSVC
authorGisle Vanem <gvanem@broadpark.no>
Wed, 24 Aug 2011 17:52:44 +0000 (13:52 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 24 Aug 2011 17:52:44 +0000 (13:52 -0400)
lround() is missing in MS Visual-C's <math.h>. Not available anywhere.
Here is an easy patch.

changes/msvc_lround [new file with mode: 0644]
src/common/util.c

diff --git a/changes/msvc_lround b/changes/msvc_lround
new file mode 100644 (file)
index 0000000..e4aea95
--- /dev/null
@@ -0,0 +1,4 @@
+  o Build fixes:
+    - Provide a substitute implementation of lround() for MSVC, which
+      apparently lacks it.  Patch from Gisle Vanem.
+      
index b47b9c5fa28bf9da5b25a7ddeeafa73b7a5a65fa..ee0acbbb07314af44fbe509c9c590ed239b1944d 100644 (file)
@@ -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. */