X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Fzerosize-ptr.h;h=beeb3da3e0d609c2ee8c7ec517fda5f136a04005;hb=ca6143b425589c3a64bd28efd7af14463f96d576;hp=9918ac7210e0d858a9b3eeecd78956898d771d2d;hpb=8a8d9a4c3ec9708460aa68e9c65ed1efde4735ec;p=gnulib.git diff --git a/tests/zerosize-ptr.h b/tests/zerosize-ptr.h index 9918ac721..beeb3da3e 100644 --- a/tests/zerosize-ptr.h +++ b/tests/zerosize-ptr.h @@ -1,5 +1,5 @@ /* Return a pointer to a zero-size object in memory. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 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 @@ -35,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 * @@ -55,11 +57,11 @@ zerosize_ptr (void) { int pagesize = getpagesize (); char *two_pages = - (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, - flags, fd, 0); + (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, + flags, fd, 0); if (two_pages != (char *)(-1) - && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) - return two_pages + pagesize; + && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) + return two_pages + pagesize; } #endif return NULL;