[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250123-nolibc-ioctl-v1-1-93f8bca99de5@weissschuh.net>
Date: Thu, 23 Jan 2025 14:04:29 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>
Cc: linux-kernel@...r.kernel.org,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH] tools/nolibc: align signature of ioctl() with POSIX
POSIX defines the signature of ioctl() as follows,
to allow passing a pointer or integer without casting:
int ioctl(int fildes, int request, ... /* arg */);
Nolibc ioctl() expects a pointer, forcing the user to manually cast.
Using va_arg to make the signature more flexible would work but seems to
prevent inlining of the function. Instead use a macro. "fd" and "req"
will still be typechecked through sys_ioctl().
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
tools/include/nolibc/sys.h | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index d4a5c2399a66b200ebf7ab249569cce2285481a5..5cb2c66cc8cccc4d4a1126acfd0b30a6efc886c3 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -532,7 +532,7 @@ uid_t getuid(void)
/*
- * int ioctl(int fd, unsigned long req, void *value);
+ * int ioctl(int fd, unsigned long req, ... value);
*/
static __attribute__((unused))
@@ -541,11 +541,7 @@ int sys_ioctl(int fd, unsigned long req, void *value)
return my_syscall3(__NR_ioctl, fd, req, value);
}
-static __attribute__((unused))
-int ioctl(int fd, unsigned long req, void *value)
-{
- return __sysret(sys_ioctl(fd, req, value));
-}
+#define ioctl(fd, req, value) __sysret(sys_ioctl(fd, req, (void *)(value)))
/*
* int kill(pid_t pid, int signal);
---
base-commit: 21266b8df5224c4f677acf9f353eecc9094731f0
change-id: 20250123-nolibc-ioctl-03e86c20049a
Best regards,
--
Thomas Weißschuh <linux@...ssschuh.net>
Powered by blists - more mailing lists