changeset 11580:89e9741f299f

Make zeroptr.h work on mingw.
author Bruno Haible <bruno@clisp.org>
date Wed, 20 May 2009 13:26:51 +0200
parents 6ca34e75d78f
children 33400b68235e
files ChangeLog modules/memchr-tests modules/memchr2-tests modules/memcmp-tests modules/memmem-tests modules/memrchr-tests tests/zerosize-ptr.h
diffstat 7 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/modules/memchr-tests
+++ b/modules/memchr-tests
@@ -9,6 +9,7 @@
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
--- a/modules/memchr2-tests
+++ b/modules/memchr2-tests
@@ -9,6 +9,7 @@
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
--- a/modules/memcmp-tests
+++ b/modules/memcmp-tests
@@ -9,6 +9,7 @@
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
--- a/modules/memmem-tests
+++ b/modules/memmem-tests
@@ -9,6 +9,7 @@
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 AC_CHECK_DECLS_ONCE([alarm])
 
--- a/modules/memrchr-tests
+++ b/modules/memrchr-tests
@@ -9,6 +9,7 @@
 
 configure.ac:
 gl_FUNC_MMAP_ANON
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
 AC_CHECK_FUNCS_ONCE([mprotect])
 
 Makefile.am:
--- a/tests/zerosize-ptr.h
+++ b/tests/zerosize-ptr.h
@@ -20,7 +20,11 @@
 
 #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>
@@ -39,7 +43,7 @@
 {
 /* 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;