]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
musl: meson: check existence of renameat2()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 9 Jun 2025 04:00:37 +0000 (13:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Nov 2025 19:44:00 +0000 (04:44 +0900)
musl-1.2.5 does not provide renameat2(). Note, it is added by
https://github.com/kraj/musl/commit/05ce67fea99ca09cd4b6625cff7aec9cc222dd5a,
hence hopefully it will be provided by musl-1.2.6 or newer.

meson.build
src/include/musl/stdio.h [new file with mode: 0644]
src/libc/musl/meson.build
src/libc/musl/stdio.c [new file with mode: 0644]

index 6d576b4d2049c6bfd36f738e08032bf1d10a5583..a7c7a0a81091c92b5adb11d806b7cc813cf54419 100644 (file)
@@ -579,6 +579,7 @@ assert(long_max > 100000)
 conf.set_quoted('LONG_MAX_STR', f'@long_max@')
 
 foreach ident : [
+        ['renameat2',         '''#include <stdio.h>'''],        # since musl-1.2.6
         ['set_mempolicy',     '''#include <sys/syscall.h>'''],  # declared at numaif.h provided by libnuma, which we do not use
         ['get_mempolicy',     '''#include <sys/syscall.h>'''],  # declared at numaif.h provided by libnuma, which we do not use
         ['strerrorname_np',   '''#include <string.h>'''],       # since glibc-2.32
diff --git a/src/include/musl/stdio.h b/src/include/musl/stdio.h
new file mode 100644 (file)
index 0000000..d677201
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include_next <stdio.h>
+
+#if !HAVE_RENAMEAT2
+#  define RENAME_NOREPLACE (1 << 0)
+#  define RENAME_EXCHANGE  (1 << 1)
+#  define RENAME_WHITEOUT  (1 << 2)
+
+int missing_renameat2(int __oldfd, const char *__old, int __newfd, const char *__new, unsigned __flags);
+#  define renameat2 missing_renameat2
+#endif
index a876230c67f878730c95ac5bc3a21b9b76976861..8d06d919ef9ce87c678890c9d2360643f519f130 100644 (file)
@@ -3,3 +3,7 @@
 if get_option('libc') != 'musl'
         subdir_done()
 endif
+
+libc_wrapper_sources += files(
+        'stdio.c',
+)
diff --git a/src/libc/musl/stdio.c b/src/libc/musl/stdio.c
new file mode 100644 (file)
index 0000000..102a22c
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <stdio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#if !HAVE_RENAMEAT2
+int missing_renameat2(int __oldfd, const char *__old, int __newfd, const char *__new, unsigned __flags) {
+        return syscall(__NR_renameat2, __oldfd, __old, __newfd, __new, __flags);
+}
+#endif