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

[or-cvs] [tor/master] Fix compilation on OSX 10.3.



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri, 20 Nov 2009 13:28:16 -0500
Subject: Fix compilation on OSX 10.3.
Commit: 444eff62862551fd984b8173ecb174483d7dbb7b

On this OSX version, there is a stub mlockall() function
that doesn't work, *and* the declaration for it is hidden by
an '#ifdef _P1003_1B_VISIBLE'.  This would make autoconf
successfully find the function, but our code fail to build
when no declaration was found.

This patch adds an additional test for the declaration.
---
 ChangeLog           |    4 ++++
 configure.in        |    9 +++++++--
 src/common/compat.c |    9 +++------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c00fcdb..1aa07a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Changes in version 0.2.2.7-alpha - 2009-??-??
+  o Minor bugfixes:
+    - Fix compilation on OSX 10.3, which has a stub mlockall() but hides it.
+
 Changes in version 0.2.2.6-alpha - 2009-11-19
   o Major features:
     - Directory authorities can now create, vote on, and serve multiple
diff --git a/configure.in b/configure.in
index 6f2baf7..f419fdf 100644
--- a/configure.in
+++ b/configure.in
@@ -629,9 +629,14 @@ if test x$tcmalloc = xyes ; then
 fi
 
 # By default, we're going to assume we don't have mlockall()
-# bionic and other platforms have various broken mlockall subsystems
-# some of systems don't have a working mlockall, some aren't linkable
+# bionic and other platforms have various broken mlockall subsystems.
+# Some systems don't have a working mlockall, some aren't linkable,
+# and some have it but don't declare it.
 AC_CHECK_FUNCS(mlockall)
+AC_CHECK_DECLS([mlockall], , , [
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif])
 
 # Allow user to specify an alternate syslog facility
 AC_ARG_WITH(syslog-facility,
diff --git a/src/common/compat.c b/src/common/compat.c
index 96012e2..4fc44af 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2258,7 +2258,6 @@ int
 tor_mlockall(void)
 {
   static int memory_lock_attempted = 0;
-  int ret;
 
   if (memory_lock_attempted) {
     return 1;
@@ -2273,15 +2272,13 @@ tor_mlockall(void)
    * http://msdn.microsoft.com/en-us/library/aa366895(VS.85).aspx
    */
 
-#ifdef HAVE_MLOCKALL
-  ret = tor_set_max_memlock();
-  if (ret == 0) {
+#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL
+  if (tor_set_max_memlock() == 0) {
     /* Perhaps we only want to log this if we're in a verbose mode? */
     log_notice(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
   }
 
-  ret = mlockall(MCL_CURRENT|MCL_FUTURE);
-  if (ret == 0) {
+  if (mlockall(MCL_CURRENT|MCL_FUTURE) == 0) {
     log_notice(LD_GENERAL, "Insecure OS paging is effectively disabled.");
     return 0;
   } else {
-- 
1.5.6.5