FreeBSD 16.0, which is not yet released, adds renameat2 and the
RENAME_NOREPLACE flags [1]. In coreutils, one can see the following test
failure:
depbase=`echo src/copy.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu23 -I. -I./lib -Ilib -I./lib -Isrc -I./src -D_THREAD_SAFE
-I/usr/local/include -g -O2 -MT src/copy.o -MD -MP -MF $depbase.Tpo -c -o
src/copy.o src/copy.c &&\
mv -f $depbase.Tpo $depbase.Po
src/copy.c: In function 'copy_internal':
src/copy.c:2149:51: error: 'RENAME_EXCHANGE' undeclared (first use in this
function)
2149 | x->exchange ? RENAME_EXCHANGE
: 0)
| ^~~~~~~~~~~~~~~
src/copy.c:2149:51: note: each undeclared identifier is reported only once
for each function it appears in
This is because src/copy.c includes sys/fcntl.h transitively through
some other system header. This causes RENAME_EXCHANGE to be defined
before Gnulib's lib/renameatu.h, which causes lib/renameatu.h to not
define the flags that the system does not support.
I pushed the attached patch to fix this by defining the macros
individually if they are not defined. I also pushed a patch to test that
the macros are defined and unique. It wouldn't have caught this issue,
since lib/renameatu.h does not include sys/fcntl.h, but it is only a few
lines and might catch future issues.
Collin
[1]
https://github.com/freebsd/freebsd-src/commit/7aaec5f3faecf98e377c97e24dddb9c65f4b2e75
>From 3437c9aa655de3b2e38f9024cb43ccc05d23e56d Mon Sep 17 00:00:00 2001
Message-ID: <3437c9aa655de3b2e38f9024cb43ccc05d23e56d.1774841479.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 29 Mar 2026 20:27:33 -0700
Subject: [PATCH 1/2] renameatu: Ensure all RENAME_* macros are defined.
* lib/renameatu.h (RENAME_EXCHANGE) [!RENAME_EXCHANGE]: Define macro.
(RENAME_WHITEOUT) [!RENAME_WHITEOUT]: Likewise.
---
ChangeLog | 6 ++++++
lib/renameatu.h | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 01175b8c6f..ee0ab12d4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-03-29 Collin Funk <[email protected]>
+
+ renameatu: Ensure all RENAME_* macros are defined.
+ * lib/renameatu.h (RENAME_EXCHANGE) [!RENAME_EXCHANGE]: Define macro.
+ (RENAME_WHITEOUT) [!RENAME_WHITEOUT]: Likewise.
+
2026-03-26 Collin Funk <[email protected]>
gnu-web-doc-update: Add an environment variable for the CVS username
diff --git a/lib/renameatu.h b/lib/renameatu.h
index c4f27f68ba..1572b053b6 100644
--- a/lib/renameatu.h
+++ b/lib/renameatu.h
@@ -27,7 +27,11 @@ extern "C" {
#ifndef RENAME_NOREPLACE
# define RENAME_NOREPLACE (1 << 0)
+#endif
+#ifndef RENAME_EXCHANGE
# define RENAME_EXCHANGE (1 << 1)
+#endif
+#ifndef RENAME_WHITEOUT
# define RENAME_WHITEOUT (1 << 2)
#endif
--
2.53.0
>From dd1891a52c57d69eab9d178cf7e8e3f978559f4b Mon Sep 17 00:00:00 2001
Message-ID: <dd1891a52c57d69eab9d178cf7e8e3f978559f4b.1774841479.git.collin.fu...@gmail.com>
In-Reply-To: <3437c9aa655de3b2e38f9024cb43ccc05d23e56d.1774841479.git.collin.fu...@gmail.com>
References: <3437c9aa655de3b2e38f9024cb43ccc05d23e56d.1774841479.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 29 Mar 2026 20:29:48 -0700
Subject: [PATCH 2/2] renameatu tests: Test that the RENAME_* macros are
defined.
* tests/test-renameatu.c (main): Test that the RENAME_* macros are
defined and unique.
---
ChangeLog | 4 ++++
tests/test-renameatu.c | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index ee0ab12d4b..8e81a42005 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2026-03-29 Collin Funk <[email protected]>
+ renameatu tests: Test that the RENAME_* macros are defined.
+ * tests/test-renameatu.c (main): Test that the RENAME_* macros are
+ defined and unique.
+
renameatu: Ensure all RENAME_* macros are defined.
* lib/renameatu.h (RENAME_EXCHANGE) [!RENAME_EXCHANGE]: Define macro.
(RENAME_WHITEOUT) [!RENAME_WHITEOUT]: Likewise.
diff --git a/tests/test-renameatu.c b/tests/test-renameatu.c
index e9a56c6ea0..0d7f274e18 100644
--- a/tests/test-renameatu.c
+++ b/tests/test-renameatu.c
@@ -59,6 +59,16 @@ main (void)
char *cwd;
int result;
+ /* Test that the RENAME_* macros are defined and unique. */
+ switch (0)
+ {
+ case RENAME_NOREPLACE:
+ case RENAME_EXCHANGE:
+ case RENAME_WHITEOUT:
+ default:
+ ;
+ }
+
/* Clean up any trash from prior testsuite runs. */
ignore_value (system ("rm -rf " BASE "*"));
--
2.53.0