From 9b470d448d9fa4beacea532d9e5ab18088a9b38e Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 2 Sep 2020 10:18:52 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8F=96=E6=B6=88isatty=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=9C=A8=E6=9C=AC=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=EF=BC=8C=E8=BD=AC=E7=A7=BB=E5=88=B0=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/termios/posix_termios.c | 9 +-------- components/libc/termios/posix_termios.h | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/components/libc/termios/posix_termios.c b/components/libc/termios/posix_termios.c index 75c876dd33..9c736c3184 100644 --- a/components/libc/termios/posix_termios.c +++ b/components/libc/termios/posix_termios.c @@ -5,7 +5,7 @@ * * Change Logs: * Date Author Notes - * 2017/08/30 Bernard The first version + * 2017/08/30 Bernard The first version */ #include #include @@ -111,13 +111,6 @@ int tcdrain(int fd) return 0; } -int isatty (int fd) -{ - struct termios term; - - return tcgetattr (fd, &term) == 0; -} - #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) void cfmakeraw(struct termios *t) { diff --git a/components/libc/termios/posix_termios.h b/components/libc/termios/posix_termios.h index 6d4be129ff..c61191b7dc 100644 --- a/components/libc/termios/posix_termios.h +++ b/components/libc/termios/posix_termios.h @@ -5,13 +5,13 @@ * * Change Logs: * Date Author Notes - * 2017/08/30 Bernard The first version + * 2017/08/30 Bernard The first version */ #ifndef TERMIOS_H__ #define TERMIOS_H__ #include -#include +#include #ifdef __cplusplus extern "C" { From 837604553b4483a324357dbbb7060491f3b2f39c Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 2 Sep 2020 10:22:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0unistd.c=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/armlibc/unistd.h | 1 + components/libc/compilers/common/unistd.c | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 components/libc/compilers/common/unistd.c diff --git a/components/libc/compilers/armlibc/unistd.h b/components/libc/compilers/armlibc/unistd.h index 70187722d8..736fc219a8 100644 --- a/components/libc/compilers/armlibc/unistd.h +++ b/components/libc/compilers/armlibc/unistd.h @@ -7,3 +7,4 @@ * Date Author Notes */ #include "sys/unistd.h" + diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c new file mode 100644 index 0000000000..04a0886655 --- /dev/null +++ b/components/libc/compilers/common/unistd.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-09-01 Meco Man First Version + */ + +#include +#include + +#ifdef RT_USING_POSIX_TERMIOS +int isatty(int fd) +{ + struct termios ts; + return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/ +} +#endif + +char *ttyname(int fd) +{ + return "/dev/tty0"; /*TODO: need to add more specific*/ +} From a162640f89933847d411513e69082325538411df Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 2 Sep 2020 10:25:52 +0800 Subject: [PATCH 3/4] Signed-off-by: mysterywolf --- components/libc/compilers/armlibc/sys/ioctl.h | 15 +++++++++++++++ components/libc/compilers/armlibc/sys/unistd.h | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 components/libc/compilers/armlibc/sys/ioctl.h diff --git a/components/libc/compilers/armlibc/sys/ioctl.h b/components/libc/compilers/armlibc/sys/ioctl.h new file mode 100644 index 0000000000..033a57014a --- /dev/null +++ b/components/libc/compilers/armlibc/sys/ioctl.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-09-01 Meco Man First Version + */ +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H + + + +#endif diff --git a/components/libc/compilers/armlibc/sys/unistd.h b/components/libc/compilers/armlibc/sys/unistd.h index 33f0561e72..3199b01e0e 100644 --- a/components/libc/compilers/armlibc/sys/unistd.h +++ b/components/libc/compilers/armlibc/sys/unistd.h @@ -46,4 +46,8 @@ #define O_SYNC _FSYNC #endif + +int isatty (int fd); +char * ttyname (int desc); + #endif /* _SYS_UNISTD_H */ From 5721fa8990e4178a427564a1e546df507c87c2b4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 2 Sep 2020 10:33:37 +0800 Subject: [PATCH 4/4] Signed-off-by: mysterywolf --- components/libc/compilers/armlibc/fcntl.h | 2 ++ components/libc/compilers/dlib/sys/unistd.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/components/libc/compilers/armlibc/fcntl.h b/components/libc/compilers/armlibc/fcntl.h index 80cf1b4409..3e650a8471 100644 --- a/components/libc/compilers/armlibc/fcntl.h +++ b/components/libc/compilers/armlibc/fcntl.h @@ -9,6 +9,8 @@ #ifndef FCNTL_H__ #define FCNTL_H__ +#include + #ifdef RT_USING_DFS #include #endif diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 29f68f24f8..9564daba8d 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -36,4 +36,8 @@ #endif + +int isatty (int fd); +char * ttyname (int desc); + #endif /* _SYS_UNISTD_H */