summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Palmer <daniel@thingy.jp>2026-05-21 20:31:03 +0300
committerThomas Weißschuh <linux@weissschuh.net>2026-05-25 00:57:59 +0300
commitacbbec15195b40adefd24993661c93022f6de2b7 (patch)
treeee45624c24405e4de72c3c1a23b37b2f06405303
parentf66d6bc35e45dfd71c95f3f4e0407081db2c0c35 (diff)
downloadlinux-acbbec15195b40adefd24993661c93022f6de2b7.tar.xz
tools/nolibc: add a helper to split a 64-bit argument into 32-bit halves
On 32-bit architectures some system calls require a single 64-bit argument to be passed as two 32-bit halves. Add a helper to easily split such arguments. This works on little and bit endian. Signed-off-by: Daniel Palmer <daniel@thingy.jp> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260521-nolibc-ftruncate-v1-2-5384a83b2402@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
-rw-r--r--tools/include/nolibc/sys.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 33f9c970ae57..548f94d96ed2 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -70,6 +70,17 @@ static __inline__ int __nolibc_enosys(const char *syscall, ...)
}
#endif
+
+/*
+ * Helper for 32-bit machines where a 64-bit syscall arg needs to be split into
+ * two 32-bit parts while making sure the order of the low/high parts are correct
+ * for the endianness:
+ * __NOLIBC_LLARGPART(x, 0), __NOLIBC_LLARGPART(x, 1)
+ */
+#define __NOLIBC_LLARGPART(_arg, _part) \
+ (((union { long long ll; long l[2]; }) { .ll = _arg }).l[_part])
+
+
/* Functions in this file only describe syscalls. They're declared static so
* that the compiler usually decides to inline them while still being allowed
* to pass a pointer to one of their instances. Each syscall exists in two