]> Savannah Git Hosting - gnulib.git/commitdiff
getcwd: simplify abort bug checking
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Jun 2024 17:26:30 +0000 (10:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Jun 2024 20:19:02 +0000 (13:19 -0700)
* 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
m4/getcwd-abort-bug.m4
modules/getcwd
tests/test-getcwd.c

index 7b94a3ef80c80f5313d4a357f2fff3b00b9e1941..84c773b9303e90c195cc15df534f0bad5575af53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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.
 
index 8286f01af620f7886048d032887cb84b600c79cc..0fce79227342f2dcdaaae9017ce42c69a7b1b369 100644 (file)
@@ -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
index 597d22ca0b8dd190b053dee65b2a45521b65cd60..f1aa6317b97dbe77edb0bd17988bccb15e6d37d9 100644 (file)
@@ -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:
index 00447e83a844dcd231eaeed24027cc9e73d1d847..e9d893408ef284f97a7bdd112c8572e2673e1c84 100644 (file)
 #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