From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Willy Tarreau <w@1wt.eu>, Shuah Khan <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH 2/5] tools/nolibc: make 64-bit systemcall argument padding generic
Date: Sun, 27 Sep 2026 10:49:13 +0200 [thread overview]
Message-ID: <20260927-nolibc-pread-v1-2-e9af6e47b37a@weissschuh.net> (raw)
In-Reply-To: <20260927-nolibc-pread-v1-0-e9af6e47b37a@weissschuh.net>
Several 32-bit architectures pass a 64-bit systemcall argument
as two 32-bit values requiring alignment to an even register pair.
This case is currently relevant for the ftruncate64() wrapper and handled
by those architectures providing custom wrappers.
With the introduction of pread() and pwrite() wrappers, the same pattern
would lead to a lot of repeated code.
Add a #define, so that the generic code can do the padding where
necessary, without any per-architecture duplication.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/arch-arm.h | 7 +------
tools/include/nolibc/arch-hexagon.h | 7 +------
tools/include/nolibc/arch-mips.h | 7 +------
tools/include/nolibc/arch-powerpc.h | 7 +------
tools/include/nolibc/unistd.h | 4 ++++
5 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h
index b88686fb19c4..b5b3456c75cb 100644
--- a/tools/include/nolibc/arch-arm.h
+++ b/tools/include/nolibc/arch-arm.h
@@ -196,11 +196,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
}
#endif /* NOLIBC_NO_RUNTIME */
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif /* _NOLIBC_ARCH_ARM_H */
diff --git a/tools/include/nolibc/arch-hexagon.h b/tools/include/nolibc/arch-hexagon.h
index 0767054882f3..68f73529a6dd 100644
--- a/tools/include/nolibc/arch-hexagon.h
+++ b/tools/include/nolibc/arch-hexagon.h
@@ -154,11 +154,6 @@ _start(void)
}
#endif /* NOLIBC_NO_RUNTIME */
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif /* _NOLIBC_ARCH_HEXAGON_H */
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 26ad413cec62..21b9959a08e2 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -286,12 +286,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
#endif /* NOLIBC_NO_RUNTIME */
#if defined(_ABIO32)
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif
#endif /* _NOLIBC_ARCH_MIPS_H */
diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h
index dbe2e5205aaa..a4711638cb66 100644
--- a/tools/include/nolibc/arch-powerpc.h
+++ b/tools/include/nolibc/arch-powerpc.h
@@ -222,12 +222,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
#endif /* NOLIBC_NO_RUNTIME */
#if !defined(__powerpc64__)
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif
#endif /* _NOLIBC_ARCH_POWERPC_H */
diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index a264a20da13d..939d4e05a55d 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -52,7 +52,11 @@ int access(const char *path, int amode)
static __attribute__((unused))
int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
{
+#if defined(__NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR)
+ return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
+#else
return __nolibc_syscall3(__NR_ftruncate64, fd, length0, length1);
+#endif
}
#define _sys_ftruncate64 _sys_ftruncate64
#endif
--
2.55.0
next prev parent reply other threads:[~2026-09-27 8:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 8:49 [PATCH 0/5] tools/nolibc: pwrite() and pread() support Thomas Weißschuh
2026-09-27 8:49 ` [PATCH 1/5] selftests/nolibc: make the broken MIPS N32 argument detection reusable Thomas Weißschuh
2026-09-27 8:49 ` Thomas Weißschuh [this message]
2026-09-27 8:49 ` [PATCH 3/5] tools/nolibc: move __NOLIBC_LLARGPART() to compiler.h Thomas Weißschuh
2026-09-27 8:49 ` [PATCH 4/5] tools/nolibc: introduce __NOLIBC_BITS_PER_SYSCALL_ARG Thomas Weißschuh
2026-09-27 8:49 ` [PATCH 5/5] tools/nolibc: add support for pread() and pwrite() Thomas Weißschuh
2026-09-27 9:10 ` [PATCH 0/5] tools/nolibc: pwrite() and pread() support Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260927-nolibc-pread-v1-2-e9af6e47b37a@weissschuh.net \
--to=linux@weissschuh.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®