From: Martin Lambers Date: Wed, 26 Dec 2007 15:37:29 +0000 (+0100) Subject: Override getpagesize on mingw. X-Git-Tag: v0.1~7901 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=e3e32d7bf018d298af7561cf0d1bdec32bc32e9b;p=gnulib.git Override getpagesize on mingw. --- diff --git a/ChangeLog b/ChangeLog index 5e68d46ca..364a429f2 100644 --- 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 index 000000000..5498aa948 --- /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 index 89c6fd5a1..5400c8636 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -181,7 +181,10 @@ extern int getlogin_r (char *name, size_t size); #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 index 37a06838f..0d07a3a53 100644 --- a/m4/getpagesize.m4 +++ b/m4/getpagesize.m4 @@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. 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 @@ AC_DEFUN([gl_FUNC_GETPAGESIZE], 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 index 91c02e7c8..4b8857ca5 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -55,6 +55,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], 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 index 91113b958..9cc4f37a5 100644 --- a/modules/getpagesize +++ b/modules/getpagesize @@ -2,6 +2,7 @@ Description: getpagesize() function: Return memory page size. Files: +lib/getpagesize.c m4/getpagesize.m4 Depends-on: diff --git a/modules/unistd b/modules/unistd index 5fb287d46..4d16cf3ab 100644 --- a/modules/unistd +++ b/modules/unistd @@ -45,6 +45,7 @@ unistd.h: unistd.in.h -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; \