Skip to content

Commit cfb1bfe

Browse files
committed
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 <[email protected]> Signed-off-by: Thomas Weißschuh <[email protected]>
1 parent 4da4e35 commit cfb1bfe

File tree

1 file changed

+4
-8
lines changed
  • tools/include/nolibc

1 file changed

+4
-8
lines changed

tools/include/nolibc/sys.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,20 +532,16 @@ uid_t getuid(void)
532532

533533

534534
/*
535-
* int ioctl(int fd, unsigned long req, void *value);
535+
* int ioctl(int fd, unsigned long cmd, ... arg);
536536
*/
537537

538538
static __attribute__((unused))
539-
int sys_ioctl(int fd, unsigned long req, void *value)
539+
long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
540540
{
541-
return my_syscall3(__NR_ioctl, fd, req, value);
541+
return my_syscall3(__NR_ioctl, fd, cmd, arg);
542542
}
543543

544-
static __attribute__((unused))
545-
int ioctl(int fd, unsigned long req, void *value)
546-
{
547-
return __sysret(sys_ioctl(fd, req, value));
548-
}
544+
#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg)))
549545

550546
/*
551547
* int kill(pid_t pid, int signal);

0 commit comments

Comments
 (0)