* m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Don’t invoke gl_CHECK_FUNC_GETPAGESIZE or #define or use HAVE_GETPAGESIZE. Protect ‘bug_possible’ with ‘defined _SC_PAGESIZE’ instead. That’s good enough as the buggy platforms all define _SC_PAGESIZE. * modules/getcwd (Files): Remove m4/getpagesize.m4. * tests/test-getcwd.c (getpagsize): Remove replacement macro. (test_abort_bug): Similar fix for ‘bug_possible’. --- ChangeLog | 9 +++++++++ m4/getcwd-abort-bug.m4 | 19 ++++--------------- modules/getcwd | 1 - tests/test-getcwd.c | 10 +++------- 4 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 7b94a3ef80..84c773b930 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2024-06-14 Paul Eggert <egg...@cs.ucla.edu> + getcwd: simplify abort bug checking + * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Don’t invoke + gl_CHECK_FUNC_GETPAGESIZE or #define or use HAVE_GETPAGESIZE. + Protect ‘bug_possible’ with ‘defined _SC_PAGESIZE’ instead. + That’s good enough as the buggy platforms all define _SC_PAGESIZE. + * modules/getcwd (Files): Remove m4/getpagesize.m4. + * tests/test-getcwd.c (getpagsize): Remove replacement macro. + (test_abort_bug): Similar fix for ‘bug_possible’. + getpagesize: remove outdated ref * lib/.cppi-disable: Remove getpagesize.h. diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4 index 8286f01af6..0fce792273 100644 --- a/m4/getcwd-abort-bug.m4 +++ b/m4/getcwd-abort-bug.m4 @@ -1,5 +1,5 @@ # getcwd-abort-bug.m4 -# serial 17 +# serial 18 dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,12 +19,6 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], AC_CHECK_HEADERS_ONCE([unistd.h]) AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ]) - gl_CHECK_FUNC_GETPAGESIZE - if test $gl_cv_func_getpagesize = yes; then - AC_DEFINE_UNQUOTED([HAVE_GETPAGESIZE], [1], - [Define to 1 if the system has the 'getpagesize' function.]) - fi - AC_CACHE_CHECK([whether getcwd succeeds when 4k < cwd_length < 16k], [gl_cv_func_getcwd_succeeds_beyond_4k], [# Remove any remnants of a previous test. @@ -52,11 +46,6 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], # define S_IRWXU 0700 #endif -/* FIXME: skip the run-test altogether on systems without getpagesize. */ -#if ! HAVE_GETPAGESIZE -# define getpagesize() 0 -#endif - /* This size is chosen to be larger than PATH_MAX (4k), yet smaller than the 16kB pagesize on ia64 linux. Those conditions make the code below trigger a bug in glibc's getcwd implementation before 2.4.90-10. */ @@ -69,10 +58,10 @@ main () size_t initial_cwd_len; int fail = 0; - /* The bug is triggered when PATH_MAX < getpagesize (), so skip + /* The bug is triggered when PATH_MAX < page size, so skip this relatively expensive and invasive test if that's not true. */ -#ifdef PATH_MAX - int bug_possible = PATH_MAX < getpagesize (); +#if defined PATH_MAX && defined _SC_PAGESIZE + int bug_possible = PATH_MAX < sysconf (_SC_PAGESIZE); #else int bug_possible = 0; #endif diff --git a/modules/getcwd b/modules/getcwd index 597d22ca0b..f1aa6317b9 100644 --- a/modules/getcwd +++ b/modules/getcwd @@ -6,7 +6,6 @@ lib/getcwd.c m4/getcwd-abort-bug.m4 m4/getcwd-path-max.m4 m4/getcwd.m4 -m4/getpagesize.m4 m4/pathmax.m4 Depends-on: diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c index 00447e83a8..e9d893408e 100644 --- a/tests/test-getcwd.c +++ b/tests/test-getcwd.c @@ -30,10 +30,6 @@ #include "qemu.h" #include "macros.h" -#if !(HAVE_GETPAGESIZE || defined getpagesize) -# define getpagesize() 0 -#endif - /* This size is chosen to be larger than PATH_MAX (4k), yet smaller than the 16kB pagesize on ia64 linux. Those conditions make the code below trigger a bug in glibc's getcwd implementation before 2.4.90-10. */ @@ -53,10 +49,10 @@ test_abort_bug (void) size_t initial_cwd_len; int fail = 0; - /* The bug is triggered when PATH_MAX < getpagesize (), so skip + /* The bug is triggered when PATH_MAX < page size, so skip this relatively expensive and invasive test if that's not true. */ -#ifdef PATH_MAX - int bug_possible = PATH_MAX < getpagesize (); +#if defined PATH_MAX && defined _SC_PAGESIZE + int bug_possible = PATH_MAX < sysconf (_SC_PAGESIZE); #else int bug_possible = 0; #endif -- 2.45.2