[svn] GnuPG - r4477 - in branches/STABLE-BRANCH-1-4: . util

svn author dshaw cvs at cvs.gnupg.org
Mon Apr 16 15:37:10 CEST 2007


Author: dshaw
Date: 2007-04-16 15:37:09 +0200 (Mon, 16 Apr 2007)
New Revision: 4477

Modified:
   branches/STABLE-BRANCH-1-4/ChangeLog
   branches/STABLE-BRANCH-1-4/acinclude.m4
   branches/STABLE-BRANCH-1-4/configure.ac
   branches/STABLE-BRANCH-1-4/util/ChangeLog
   branches/STABLE-BRANCH-1-4/util/secmem.c
Log:
Use sysconf() when possible as not all platforms have getpagesize().


Modified: branches/STABLE-BRANCH-1-4/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/ChangeLog	2007-04-15 16:37:01 UTC (rev 4476)
+++ branches/STABLE-BRANCH-1-4/ChangeLog	2007-04-16 13:37:09 UTC (rev 4477)
@@ -1,3 +1,10 @@
+2007-04-16  David Shaw  <dshaw at jabberwocky.com>
+
+	* acinclude.m4: Use sysconf() if available to avoid a false
+	positive on HAVE_BROKEN_MLOCK when checking for page size.
+
+	* configure.ac: Check for sysconf.
+
 2007-04-15  David Shaw  <dshaw at jabberwocky.com>
 
 	* configure.ac: QNX puts resolver functions in libsocket.  From

Modified: branches/STABLE-BRANCH-1-4/acinclude.m4
===================================================================
--- branches/STABLE-BRANCH-1-4/acinclude.m4	2007-04-15 16:37:01 UTC (rev 4476)
+++ branches/STABLE-BRANCH-1-4/acinclude.m4	2007-04-16 13:37:09 UTC (rev 4477)
@@ -420,8 +420,17 @@
                 {
                     char *pool;
                     int err;
-                    long int pgsize = getpagesize();
+                    long int pgsize;
 
+		#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+                    pgsize = sysconf(_SC_PAGESIZE);
+		#elif defined(HAVE_GETPAGESIZE)
+                    pgsize = getpagesize();
+		#endif
+
+		    if(pgsize==-1)
+	               pgsize = 4096;
+
                     pool = malloc( 4096 + pgsize );
                     if( !pool )
                         return 2;

Modified: branches/STABLE-BRANCH-1-4/configure.ac
===================================================================
--- branches/STABLE-BRANCH-1-4/configure.ac	2007-04-15 16:37:01 UTC (rev 4476)
+++ branches/STABLE-BRANCH-1-4/configure.ac	2007-04-16 13:37:09 UTC (rev 4477)
@@ -953,7 +953,7 @@
 AC_FUNC_FSEEKO
 AC_FUNC_VPRINTF
 AC_FUNC_FORK
-AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap)
+AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap sysconf)
 AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times unsetenv getpwnam getpwuid)
 AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
 AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)

Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/util/ChangeLog	2007-04-15 16:37:01 UTC (rev 4476)
+++ branches/STABLE-BRANCH-1-4/util/ChangeLog	2007-04-16 13:37:09 UTC (rev 4477)
@@ -1,3 +1,8 @@
+2007-04-16  David Shaw  <dshaw at jabberwocky.com>
+
+	* secmem.c (init_pool): Use sysconf() if available to determine
+	page size.
+
 2007-04-15  David Shaw  <dshaw at jabberwocky.com>
 
 	* argparse.c (default_strusage): Copyright 2007.

Modified: branches/STABLE-BRANCH-1-4/util/secmem.c
===================================================================
--- branches/STABLE-BRANCH-1-4/util/secmem.c	2007-04-15 16:37:01 UTC (rev 4476)
+++ branches/STABLE-BRANCH-1-4/util/secmem.c	2007-04-16 13:37:09 UTC (rev 4477)
@@ -1,5 +1,6 @@
 /* secmem.c  -	memory allocation from a secure heap
- *	Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ *	Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ *                    2007 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -218,19 +219,22 @@
 static void
 init_pool( size_t n)
 {
-    size_t pgsize;
+    size_t pgsize=-1;
 
     poolsize = n;
 
     if( disable_secmem )
 	log_bug("secure memory is disabled");
 
-#ifdef HAVE_GETPAGESIZE
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+    pgsize = sysconf(_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
     pgsize = getpagesize();
-#else
-    pgsize = 4096;
 #endif
 
+    if(pgsize==-1)
+      pgsize = 4096;
+
 #ifdef HAVE_MMAP
     poolsize = (poolsize + pgsize -1 ) & ~(pgsize-1);
 #ifdef MAP_ANONYMOUS




More information about the Gnupg-commits mailing list