[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: zerosize_ptr mingw problems
From: |
Bruno Haible |
Subject: |
Re: zerosize_ptr mingw problems |
Date: |
Wed, 20 May 2009 13:28:06 +0200 |
User-agent: |
KMail/1.9.9 |
Simon Josefsson wrote:
> The zerosize_ptr stuff doesn't seem to work on MinGW:
>
> rm -rf m; gnulib-tool --dir m --create-testdir --with-tests memchr; cd m;
> ./configure --host=i586-mingw32msvc --build=i686-pc-linux-gnu ; make check
>
> In file included from test-memchr.c:25:
> zerosize-ptr.h:27:23: error: sys/mman.h: No such file or directory
> In file included from test-memchr.c:25:
> zerosize-ptr.h: In function ‘zerosize_ptr’:
> zerosize-ptr.h:47: error: ‘MAP_PRIVATE’ undeclared (first use in this
> function)
> zerosize-ptr.h:47: error: (Each undeclared identifier is reported only once
> zerosize-ptr.h:47: error: for each function it appears in.)
> zerosize-ptr.h:54: error: ‘PROT_READ’ undeclared (first use in this function)
> zerosize-ptr.h:54: error: ‘PROT_WRITE’ undeclared (first use in this function)
> zerosize-ptr.h:57: error: ‘PROT_NONE’ undeclared (first use in this function)
> make[3]: *** [test-memchr.o] Error 1
Indeed. On mingw, there is a definition of mprotect in libgcc.a !
This fixes it:
2009-05-20 Bruno Haible <address@hidden>
Make zeroptr.h work on mingw.
* tests/zerosize-ptr.h: Test for the presence of <sys/mman.h> and
mprotect.
* modules/memchr-tests (configure.ac): Also test for sys/mman.h.
* modules/memchr2-tests (configure.ac): Likewise.
* modules/memcmp-tests (configure.ac): Likewise.
* modules/memmem-tests (configure.ac): Likewise.
* modules/memrchr-tests (configure.ac): Likewise.
Reported by Simon Josefsson.
*** modules/memchr-tests.orig 2009-05-20 13:24:03.000000000 +0200
--- modules/memchr-tests 2009-05-20 13:16:30.000000000 +0200
***************
*** 9,14 ****
--- 9,15 ----
configure.ac:
gl_FUNC_MMAP_ANON
+ AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
Makefile.am:
*** modules/memchr2-tests.orig 2009-05-20 13:24:03.000000000 +0200
--- modules/memchr2-tests 2009-05-20 13:16:34.000000000 +0200
***************
*** 9,14 ****
--- 9,15 ----
configure.ac:
gl_FUNC_MMAP_ANON
+ AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
Makefile.am:
*** modules/memcmp-tests.orig 2009-05-20 13:24:03.000000000 +0200
--- modules/memcmp-tests 2009-05-20 13:16:38.000000000 +0200
***************
*** 9,14 ****
--- 9,15 ----
configure.ac:
gl_FUNC_MMAP_ANON
+ AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
Makefile.am:
*** modules/memmem-tests.orig 2009-05-20 13:24:03.000000000 +0200
--- modules/memmem-tests 2009-05-20 13:16:43.000000000 +0200
***************
*** 9,14 ****
--- 9,15 ----
configure.ac:
gl_FUNC_MMAP_ANON
+ AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
AC_CHECK_DECLS_ONCE([alarm])
*** modules/memrchr-tests.orig 2009-05-20 13:24:03.000000000 +0200
--- modules/memrchr-tests 2009-05-20 13:16:47.000000000 +0200
***************
*** 9,14 ****
--- 9,15 ----
configure.ac:
gl_FUNC_MMAP_ANON
+ AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
Makefile.am:
*** tests/zerosize-ptr.h.orig 2009-05-20 13:24:03.000000000 +0200
--- tests/zerosize-ptr.h 2009-05-20 13:23:35.000000000 +0200
***************
*** 20,26 ****
#include <stdlib.h>
! #if HAVE_MPROTECT
# include <fcntl.h>
# include <unistd.h>
# include <sys/types.h>
--- 20,30 ----
#include <stdlib.h>
! /* Test whether mmap() and mprotect() are available.
! We don't use HAVE_MMAP, because AC_FUNC_MMAP would not define it on HP-UX.
! HAVE_MPROTECT is not enough, because mingw does not have mmap() but has an
! mprotect() function in libgcc.a. */
! #if HAVE_SYS_MMAN_H && HAVE_MPROTECT
# include <fcntl.h>
# include <unistd.h>
# include <sys/types.h>
***************
*** 39,45 ****
{
/* Use mmap and mprotect when they exist. Don't test HAVE_MMAP, because it is
not defined on HP-UX 11 (since it does not support MAP_FIXED). */
! #if HAVE_MPROTECT
# if HAVE_MAP_ANONYMOUS
const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
const int fd = -1;
--- 43,49 ----
{
/* Use mmap and mprotect when they exist. Don't test HAVE_MMAP, because it is
not defined on HP-UX 11 (since it does not support MAP_FIXED). */
! #if HAVE_SYS_MMAN_H && HAVE_MPROTECT
# if HAVE_MAP_ANONYMOUS
const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
const int fd = -1;