* m4/mprotect.m4 (gl_FUNC_MPROTECT_WORKS): Don’t assume pointers fit into unsigned long, as this is not true on CheriBSD. Prefer sysconf (_SC_PAGESIZE) to getpagesize. --- ChangeLog | 5 +++++ m4/mprotect.m4 | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog index d1939c1418..690c886f78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2024-06-14 Paul Eggert <egg...@cs.ucla.edu> + mprotect: don’t assume pointers fit in long + * m4/mprotect.m4 (gl_FUNC_MPROTECT_WORKS): Don’t assume pointers + fit into unsigned long, as this is not true on CheriBSD. Prefer + sysconf (_SC_PAGESIZE) to getpagesize. + memchr,strncat: prefer sysconf (_SC_PAGESIZE) * m4/memchr.m4 (gl_FUNC_MEMCHR): * m4/strncat.m4 (gl_FUNC_STRNCAT): diff --git a/m4/mprotect.m4 b/m4/mprotect.m4 index 536f2ad094..f0968b413e 100644 --- a/m4/mprotect.m4 +++ b/m4/mprotect.m4 @@ -1,5 +1,5 @@ # mprotect.m4 -# serial 3 +# serial 4 dnl Copyright (C) 1993-2024 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License as published by the Free Software Foundation; @@ -25,24 +25,20 @@ AC_DEFUN([gl_FUNC_MPROTECT_WORKS], #include <sys/types.h> /* Declare malloc(). */ #include <stdlib.h> - /* Declare getpagesize(). */ - #if HAVE_UNISTD_H - #include <unistd.h> - #endif - #ifdef __hpux - extern - #ifdef __cplusplus - "C" - #endif - int getpagesize (void); - #endif + /* Declare sysconf(). */ + #include <unistd.h> /* Declare mprotect(). */ #include <sys/mman.h> char foo; + static unsigned long int pagesize; + static char * + page_align (char *address) + { + return address - ((unsigned long int) address & (pagesize - 1)); + } int main () { - unsigned long pagesize = getpagesize (); - #define page_align(address) (char*)((unsigned long)(address) & -pagesize) + pagesize = sysconf (_SC_PAGESIZE); ' no_mprotect= AC_RUN_IFELSE( -- 2.45.2