2024-06-14 Paul Eggert <eggert@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.
# 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,
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.
# 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. */
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
#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. */
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