changeset 29243:bc19ad176424

Override getpagesize on mingw.
author Martin Lambers <marlam@marlam.de>
date Wed, 26 Dec 2007 16:37:29 +0100
parents 41975c374e2f
children 1cb4729211f8
files ChangeLog lib/getpagesize.c lib/unistd.in.h m4/getpagesize.m4 m4/unistd_h.m4 modules/getpagesize modules/unistd
diffstat 7 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Dec 26 16:33:48 2007 +0100
+++ b/ChangeLog	Wed Dec 26 16:37:29 2007 +0100
@@ -1,3 +1,14 @@
+2007-12-10  Martin Lambers <marlam@marlam.de>
+
+	Override getpagesize on mingw.
+	* lib/getpagesize.c: New file.
+	* m4/getpagesize.m4 (gl_FUNC_GETPAGESIZE): Enable replacement on mingw.
+	* modules/getpagesize (Files): Add lib/getpagesize.c.
+	* lib/unistd.in.h (getpagesize): Declare if we are using a replacement.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
+	REPLACE_GETPAGESIZE.
+	* modules/unistd (Makefile.am): Substitute REPLACE_GETPAGESIZE.
+
 2007-12-25  Bruno Haible  <bruno@clisp.org>
 
 	* modules/localcharset (Notice): New field.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/getpagesize.c	Wed Dec 26 16:37:29 2007 +0100
@@ -0,0 +1,39 @@
+/* getpagesize emulation for systems where it cannot be done in a C macro.
+
+   Copyright (C) 2007 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible and Martin Lambers.  */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+/* This implementation is only for native Win32 systems.  */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+int
+getpagesize (void)
+{
+  SYSTEM_INFO system_info;
+  GetSystemInfo (&system_info);
+  return system_info.dwPageSize;
+}
+
+#endif
--- a/lib/unistd.in.h	Wed Dec 26 16:33:48 2007 +0100
+++ b/lib/unistd.in.h	Wed Dec 26 16:37:29 2007 +0100
@@ -181,7 +181,10 @@
 
 
 #if @GNULIB_GETPAGESIZE@
-# if !@HAVE_GETPAGESIZE@
+# if @REPLACE_GETPAGESIZE@
+#  define getpagesize rpl_getpagesize
+extern int getpagesize (void);
+# elif !@HAVE_GETPAGESIZE@
 /* This is for POSIX systems.  */
 #  if !defined getpagesize && defined _SC_PAGESIZE
 #   if ! (defined __VMS && __VMS_VER < 70000000)
--- a/m4/getpagesize.m4	Wed Dec 26 16:33:48 2007 +0100
+++ b/m4/getpagesize.m4	Wed Dec 26 16:37:29 2007 +0100
@@ -7,6 +7,7 @@
 AC_DEFUN([gl_FUNC_GETPAGESIZE],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_FUNCS([getpagesize])
   if test $ac_cv_func_getpagesize = no; then
     HAVE_GETPAGESIZE=0
@@ -19,4 +20,10 @@
       HAVE_SYS_PARAM_H=1
     fi
   fi
+  case "$host_os" in
+    mingw*)
+      REPLACE_GETPAGESIZE=1
+      AC_LIBOBJ([getpagesize])
+      ;;
+  esac
 ])
--- a/m4/unistd_h.m4	Wed Dec 26 16:33:48 2007 +0100
+++ b/m4/unistd_h.m4	Wed Dec 26 16:37:29 2007 +0100
@@ -55,6 +55,7 @@
   REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
   REPLACE_FCHDIR=0;       AC_SUBST([REPLACE_FCHDIR])
   REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
+  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
   REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
   REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
 ])
--- a/modules/getpagesize	Wed Dec 26 16:33:48 2007 +0100
+++ b/modules/getpagesize	Wed Dec 26 16:37:29 2007 +0100
@@ -2,6 +2,7 @@
 getpagesize() function: Return memory page size.
 
 Files:
+lib/getpagesize.c
 m4/getpagesize.m4
 
 Depends-on:
--- a/modules/unistd	Wed Dec 26 16:33:48 2007 +0100
+++ b/modules/unistd	Wed Dec 26 16:37:29 2007 +0100
@@ -45,6 +45,7 @@
 	      -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
 	      -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
 	      -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+	      -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
 	      -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
 	      -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
 	      < $(srcdir)/unistd.in.h; \