Make zeroptr.h work on mingw.
authorBruno Haible <bruno@clisp.org>
Wed, 20 May 2009 11:26:51 +0000 (13:26 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 20 May 2009 11:26:51 +0000 (13:26 +0200)
ChangeLog
modules/memchr-tests
modules/memchr2-tests
modules/memcmp-tests
modules/memmem-tests
modules/memrchr-tests
tests/zerosize-ptr.h

index fe17d77..eeab720 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-05-20  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2009-05-20  Simon Josefsson  <simon@josefsson.org>
 
        * tests/test-glob.c: Include string.h for strcmp prototype.
 2009-05-20  Simon Josefsson  <simon@josefsson.org>
 
        * tests/test-glob.c: Include string.h for strcmp prototype.
index c99e557..c2c9e2b 100644 (file)
@@ -9,6 +9,7 @@ getpagesize
 
 configure.ac:
 gl_FUNC_MMAP_ANON
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
index 44d220c..99c02b1 100644 (file)
@@ -9,6 +9,7 @@ getpagesize
 
 configure.ac:
 gl_FUNC_MMAP_ANON
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
index ae1cc38..3f536d7 100644 (file)
@@ -9,6 +9,7 @@ getpagesize
 
 configure.ac:
 gl_FUNC_MMAP_ANON
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
index ff47e51..45ef991 100644 (file)
@@ -9,6 +9,7 @@ getpagesize
 
 configure.ac:
 gl_FUNC_MMAP_ANON
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 AC_CHECK_DECLS_ONCE([alarm])
 
 AC_CHECK_FUNCS_ONCE([mprotect])
 AC_CHECK_DECLS_ONCE([alarm])
 
index 4885fb1..967f92b 100644 (file)
@@ -9,6 +9,7 @@ getpagesize
 
 configure.ac:
 gl_FUNC_MMAP_ANON
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
index fa00aee..9918ac7 100644 (file)
 
 #include <stdlib.h>
 
 
 #include <stdlib.h>
 
-#if HAVE_MPROTECT
+/* 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>
 # include <fcntl.h>
 # include <unistd.h>
 # include <sys/types.h>
@@ -39,7 +43,7 @@ zerosize_ptr (void)
 {
 /* 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).  */
 {
 /* 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_SYS_MMAN_H && HAVE_MPROTECT
 # if HAVE_MAP_ANONYMOUS
   const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
   const int fd = -1;
 # if HAVE_MAP_ANONYMOUS
   const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
   const int fd = -1;