]> Savannah Git Hosting - gnulib.git/commitdiff
renameatu: Simplify configure test.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Jan 2025 09:05:01 +0000 (10:05 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Jan 2025 09:05:01 +0000 (10:05 +0100)
* m4/renameat.m4 (gl_FUNC_RENAMEAT): Prepare the test scenario outside
of the test program. Use a bit mask as the test program's exit code.

ChangeLog
m4/renameat.m4

index 35e25d2c0397cfda2045f8ea9d6fe69f4bb25ae9..e01201e36d0f4df54c96b5ee71b7fb07d56b9ce8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-01-19  Bruno Haible  <bruno@clisp.org>
+
+       renameatu: Simplify configure test.
+       * m4/renameat.m4 (gl_FUNC_RENAMEAT): Prepare the test scenario outside
+       of the test program. Use a bit mask as the test program's exit code.
+
 2025-01-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        flexmember: port to IBM XL C 16.1
index 238412d7287464a67c3a6c9e122ae0213557c2d5..129e7fe067ae49df5acc53bd1478664a35382243 100644 (file)
@@ -1,5 +1,5 @@
 # renameat.m4
-# serial 5
+# serial 6
 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,27 +29,25 @@ AC_DEFUN([gl_FUNC_RENAMEAT],
   if test $ac_cv_func_renameat2 = yes; then
     AC_CACHE_CHECK([whether renameat2 works],
       [gl_cv_func_renameat2_works],
-      [AC_RUN_IFELSE(
+      [rm -rf conftest.a conftest.b
+       touch conftest.a
+       AC_RUN_IFELSE(
          [AC_LANG_SOURCE([[
             #include <unistd.h>
             #include <fcntl.h>
             #include <stdio.h>
             int main ()
             {
-              int fd;
+              int result = 0;
               /* This test fails on Cygwin 3.4.6.  */
               if (renameat2 (AT_FDCWD, "conftest.c", AT_FDCWD, "conftest.c",
                              RENAME_NOREPLACE) == 0)
-                return 1;
-              fd = open ("conftest.a", O_CREAT | O_EXCL | O_WRONLY, 0600);
-              if (fd < 0)
-                return 1;
+                result |= 1;
               /* This test fails on GNU/Hurd.  */
-              if (renameat2 (AT_FDCWD, "conftest.a", AT_FDCWD, "conftest.b/", 0) == 0)
-                return 1;
-              if (close (fd) < 0)
-                return 1;
-              return 0;
+              if (renameat2 (AT_FDCWD, "conftest.a", AT_FDCWD, "conftest.b/", 0)
+                  == 0)
+                result |= 2;
+              return result;
             }
          ]])],
          [gl_cv_func_renameat2_works=yes],
@@ -58,14 +56,14 @@ AC_DEFUN([gl_FUNC_RENAMEAT],
                      # Guess yes on Linux.
             linux*)  gl_cv_func_renameat2_works="guessing yes" ;;
                      # Guess no on GNU/Hurd.
-            gnu*) gl_cv_func_renameat2_works="guessing no" ;;
+            gnu*)    gl_cv_func_renameat2_works="guessing no" ;;
                      # Guess no on Cygwin.
             cygwin*) gl_cv_func_renameat2_works="guessing no" ;;
                      # If we don't know, obey --enable-cross-guesses.
             *)       gl_cv_func_renameat2_works="$gl_cross_guess_normal" ;;
           esac
          ])
-        rm -rf conftest.a conftest.b
+       rm -rf conftest.a conftest.b
       ])
     case "$gl_cv_func_renameat2_works" in
       *yes)