X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fzerosize-ptr.h;h=a38a2cf4941ab810d59019f69b9458f8d66bcebe;hb=4e42b89b090f61e189e7161a3f096cabc832b6d3;hp=fa00aeeee5d6e63824432a410df93371f3f77cdb;hpb=bb051a0a3c0febe9d3fabb21ae5b7fcc2ae7aa10;p=gnulib.git diff --git a/tests/zerosize-ptr.h b/tests/zerosize-ptr.h index fa00aeeee..a38a2cf49 100644 --- a/tests/zerosize-ptr.h +++ b/tests/zerosize-ptr.h @@ -20,7 +20,11 @@ #include -#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 # include # include @@ -31,7 +35,9 @@ # endif #endif -/* Return a pointer to a zero-size object in memory, if possible. +/* Return a pointer to a zero-size object in memory (that is, actually, a + pointer to a page boundary where the previous page is readable and writable + and the next page is neither readable not writable), if possible. Return NULL otherwise. */ static void * @@ -39,7 +45,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). */ -#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;