From 5480c133aeea98845112147f1fe406be02814259 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 23 Nov 2019 21:29:36 +0100 Subject: [PATCH] mescc: Mes C Library: Fix isatty for x86_64. * lib/linux/ioctl.c (ioctl3): New function. * include/sys/ioctl.h: Declare it. * lib/posix/isatty.c (__tcgetattr): Use it. --- include/sys/ioctl.h | 1 + lib/linux/ioctl.c | 7 +++++++ lib/posix/isatty.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index f26c9f8e..2650929e 100644 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -29,6 +29,7 @@ #define TCGETS 0x5401 #define TCGETA 0x5405 int ioctl (int fd, unsigned long request, ...); +int ioctl3 (int fd, unsigned long request, long data); #endif // ! SYSTEM_LIBC diff --git a/lib/linux/ioctl.c b/lib/linux/ioctl.c index 5e45c8c7..7df28a0b 100644 --- a/lib/linux/ioctl.c +++ b/lib/linux/ioctl.c @@ -33,3 +33,10 @@ ioctl (int filedes, unsigned long command, ...) va_end (ap); return r; } + +int +ioctl3 (int filedes, unsigned long command, long data) +{ + int r = _sys_call3 (SYS_ioctl, filedes, command, data); + return r; +} diff --git a/lib/posix/isatty.c b/lib/posix/isatty.c index db2319ec..cf983f6c 100644 --- a/lib/posix/isatty.c +++ b/lib/posix/isatty.c @@ -58,7 +58,7 @@ int __tcgetattr (int filedes, struct termios *termios_p) { struct ktermios kernel_termios; - int r = ioctl (filedes, TCGETS, &kernel_termios); + int r = ioctl3 (filedes, TCGETS, (long) &kernel_termios); termios_p->c_iflag = kernel_termios.c_iflag; termios_p->c_oflag = kernel_termios.c_oflag;