]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check for lround with autoconf; fall back to rint.
authorNick Mathewson <nickm@torproject.org>
Wed, 31 Aug 2011 02:22:15 +0000 (22:22 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 31 Aug 2011 02:22:15 +0000 (22:22 -0400)
configure.in
src/common/util.c

index 4e84298456d4e02d8edd553b7bce389ed4aea076..df1b70978b7b9e315726aa418aa5d0d2bcba6221 100644 (file)
@@ -223,7 +223,7 @@ dnl -------------------------------------------------------------------
 dnl Check for functions before libevent, since libevent-1.2 apparently
 dnl exports strlcpy without defining it in a header.
 
-AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull getaddrinfo localtime_r gmtime_r memmem strtok_r writev readv flock prctl vasprintf)
+AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull getaddrinfo localtime_r gmtime_r memmem strtok_r writev readv flock prctl vasprintf lround rint)
 
 using_custom_malloc=no
 if test x$enable_openbsd_malloc = xyes ; then
index ee0acbbb07314af44fbe509c9c590ed239b1944d..de1ca3684d93afd3b11dda8728d757697b29d1a7 100644 (file)
@@ -334,10 +334,12 @@ tor_mathlog(double d)
 long
 tor_lround(double d)
 {
-#ifdef _MSC_VER
-  return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
-#else
+#if defined(HAVE_LROUND)
   return lround(d);
+#elif defined(HAVE_RINT)
+  return (long)rint(d);
+#else
+  return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
 #endif
 }