# HG changeset patch # User Martin Lambers # Date 1198683449 -3600 # Node ID 6632990b081276aac3935488294910b8715aae8e # Parent bd08c714fb5ad859ee2f8ce5539e884f397e088c Override getpagesize on mingw. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-12-10 Martin Lambers + + 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 * modules/localcharset (Notice): New field. diff --git a/lib/getpagesize.c b/lib/getpagesize.c new file mode 100644 --- /dev/null +++ b/lib/getpagesize.c @@ -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 . */ + +/* Written by Bruno Haible and Martin Lambers. */ + +#include + +/* Specification. */ +#include + +/* This implementation is only for native Win32 systems. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include + +int +getpagesize (void) +{ + SYSTEM_INFO system_info; + GetSystemInfo (&system_info); + return system_info.dwPageSize; +} + +#endif diff --git a/lib/unistd.in.h b/lib/unistd.in.h --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -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) diff --git a/m4/getpagesize.m4 b/m4/getpagesize.m4 --- a/m4/getpagesize.m4 +++ b/m4/getpagesize.m4 @@ -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 ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -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]) ]) diff --git a/modules/getpagesize b/modules/getpagesize --- a/modules/getpagesize +++ b/modules/getpagesize @@ -2,6 +2,7 @@ getpagesize() function: Return memory page size. Files: +lib/getpagesize.c m4/getpagesize.m4 Depends-on: diff --git a/modules/unistd b/modules/unistd --- a/modules/unistd +++ b/modules/unistd @@ -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; \