[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Check for lround with autoconf; fall back to rint.



commit 0ac4b0f99d12a76f07f24d747a77f2bc07e481e3
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Aug 30 22:22:15 2011 -0400

    Check for lround with autoconf; fall back to rint.
---
 configure.in      |    2 +-
 src/common/util.c |    8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/configure.in b/configure.in
index 4e84298..df1b709 100644
--- a/configure.in
+++ b/configure.in
@@ -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
diff --git a/src/common/util.c b/src/common/util.c
index ee0acbb..de1ca36 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -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
 }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits