You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/12/29 11:11:21 UTC
[incubator-nuttx] 05/07: libc: Implement terminal api regardless of CONFIG_SERIAL_TERMIOS setting
This is an automated email from the ASF dual-hosted git repository.
gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 4262b09cbf08a6721515531263f28fbd21e547d5
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Dec 17 02:58:49 2021 +0800
libc: Implement terminal api regardless of CONFIG_SERIAL_TERMIOS setting
since many functions aren't related to termios directly
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/serial/serial.c | 2 --
include/cxx/cunistd | 2 --
include/nuttx/serial/serial.h | 4 +---
include/termios.h | 3 ---
include/unistd.h | 2 --
libs/libc/termios/Make.defs | 4 ----
libs/libc/termios/lib_tcgetattr.c | 2 +-
libs/libc/termios/lib_tcsetattr.c | 2 +-
8 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index d9e71bb..f02316b 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -1354,7 +1354,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break;
-#ifdef CONFIG_SERIAL_TERMIOS
case TCFLSH:
{
/* Empty the tx/rx buffers */
@@ -1391,7 +1390,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = uart_tcdrain(dev, true, 10 * TICK_PER_SEC);
}
break;
-#endif
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
/* Make the controlling terminal of the calling process */
diff --git a/include/cxx/cunistd b/include/cxx/cunistd
index 42ae125..91fd625 100644
--- a/include/cxx/cunistd
+++ b/include/cxx/cunistd
@@ -56,9 +56,7 @@ namespace std
// Terminal I/O
-#ifdef CONFIG_SERIAL_TERMIOS
using ::isatty;
-#endif
// Memory management
diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h
index 6645da5..d5aa793 100644
--- a/include/nuttx/serial/serial.h
+++ b/include/nuttx/serial/serial.h
@@ -31,9 +31,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
-#ifdef CONFIG_SERIAL_TERMIOS
-# include <termios.h>
-#endif
+#include <termios.h>
#include <nuttx/fs/fs.h>
#include <nuttx/semaphore.h>
diff --git a/include/termios.h b/include/termios.h
index 924c88c..a966724 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -29,8 +29,6 @@
#include <sys/types.h>
#include <stdint.h>
-#ifdef CONFIG_SERIAL_TERMIOS
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -319,5 +317,4 @@ int tcsetattr(int fd, int options, FAR const struct termios *termiosp);
}
#endif
-#endif /* CONFIG_SERIAL_TERMIOS */
#endif /* __INCLUDE_TERMIOS_H */
diff --git a/include/unistd.h b/include/unistd.h
index 63e5cdd..d6092e1 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -327,14 +327,12 @@ ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset);
int ftruncate(int fd, off_t length);
int fchown(int fd, uid_t owner, gid_t group);
-#ifdef CONFIG_SERIAL_TERMIOS
/* Check if a file descriptor corresponds to a terminal I/O file */
int isatty(int fd);
FAR char *ttyname(int fd);
int ttyname_r(int fd, FAR char *buf, size_t buflen);
-#endif
/* Memory management */
diff --git a/libs/libc/termios/Make.defs b/libs/libc/termios/Make.defs
index 974bc06..ec44a79 100644
--- a/libs/libc/termios/Make.defs
+++ b/libs/libc/termios/Make.defs
@@ -21,8 +21,6 @@
# termios.h support requires file descriptors and that CONFIG_SERIAL_TERMIOS
# is defined
-ifeq ($(CONFIG_SERIAL_TERMIOS),y)
-
# Add the termios C files to the build
CSRCS += lib_cfspeed.c lib_cfmakeraw.c lib_isatty.c lib_tcflush.c
@@ -33,5 +31,3 @@ CSRCS += lib_ttyname.c lib_ttynamer.c
DEPPATH += --dep-path termios
VPATH += termios
-
-endif
diff --git a/libs/libc/termios/lib_tcgetattr.c b/libs/libc/termios/lib_tcgetattr.c
index 61dae53..a1bbcdc 100644
--- a/libs/libc/termios/lib_tcgetattr.c
+++ b/libs/libc/termios/lib_tcgetattr.c
@@ -60,5 +60,5 @@
int tcgetattr(int fd, FAR struct termios *termiosp)
{
- return ioctl(fd, TCGETS, (unsigned long)termiosp);
+ return ioctl(fd, TCGETS, (unsigned long)(uintptr_t)termiosp);
}
diff --git a/libs/libc/termios/lib_tcsetattr.c b/libs/libc/termios/lib_tcsetattr.c
index cde1c06..8142087 100644
--- a/libs/libc/termios/lib_tcsetattr.c
+++ b/libs/libc/termios/lib_tcsetattr.c
@@ -93,5 +93,5 @@ int tcsetattr(int fd, int options, FAR const struct termios *termiosp)
tcflush(fd, TCIFLUSH);
}
- return ioctl(fd, TCSETS, (unsigned long)termiosp);
+ return ioctl(fd, TCSETS, (unsigned long)(uintptr_t)termiosp);
}