From: Yu Watanabe Date: Mon, 9 Jun 2025 04:00:37 +0000 (+0900) Subject: musl: meson: check existence of renameat2() X-Git-Tag: v259-rc1~84^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17e343b58b862306454b64cd66a26588420cffd3;p=thirdparty%2Fsystemd.git musl: meson: check existence of renameat2() 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. --- diff --git a/meson.build b/meson.build index 6d576b4d204..a7c7a0a8109 100644 --- a/meson.build +++ b/meson.build @@ -579,6 +579,7 @@ assert(long_max > 100000) conf.set_quoted('LONG_MAX_STR', f'@long_max@') foreach ident : [ + ['renameat2', '''#include '''], # since musl-1.2.6 ['set_mempolicy', '''#include '''], # declared at numaif.h provided by libnuma, which we do not use ['get_mempolicy', '''#include '''], # declared at numaif.h provided by libnuma, which we do not use ['strerrorname_np', '''#include '''], # since glibc-2.32 diff --git a/src/include/musl/stdio.h b/src/include/musl/stdio.h new file mode 100644 index 00000000000..d677201f457 --- /dev/null +++ b/src/include/musl/stdio.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next + +#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 diff --git a/src/libc/musl/meson.build b/src/libc/musl/meson.build index a876230c67f..8d06d919ef9 100644 --- a/src/libc/musl/meson.build +++ b/src/libc/musl/meson.build @@ -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 index 00000000000..102a22cd5cd --- /dev/null +++ b/src/libc/musl/stdio.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include +#include +#include + +#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