diff options
author | Thomas Weißschuh <linux@weissschuh.net> | 2025-01-28 22:22:46 +0100 |
---|---|---|
committer | Thomas Weißschuh <linux@weissschuh.net> | 2025-02-03 20:57:39 +0100 |
commit | cfb1bfe9535a74f01a6b9df9fbf1cf0608d13786 (patch) | |
tree | db6c56dc26e8caa53f9e7ae97fbf6e3f3c2d474d | |
parent | 4da4e35e9d7ebcf575e02791fa3b1784bd0765a2 (diff) |
tools/nolibc: make signature of ioctl() more flexible
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().
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
-rw-r--r-- | tools/include/nolibc/sys.h | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index d4a5c2399a66..8c0a55bc9dc3 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -532,20 +532,16 @@ uid_t getuid(void) /* - * int ioctl(int fd, unsigned long req, void *value); + * int ioctl(int fd, unsigned long cmd, ... arg); */ static __attribute__((unused)) -int sys_ioctl(int fd, unsigned long req, void *value) +long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { - return my_syscall3(__NR_ioctl, fd, req, value); + return my_syscall3(__NR_ioctl, fd, cmd, arg); } -static __attribute__((unused)) -int ioctl(int fd, unsigned long req, void *value) -{ - return __sysret(sys_ioctl(fd, req, value)); -} +#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg))) /* * int kill(pid_t pid, int signal); |