From bf733f72132d387206c3ffe21fb6b2a085dd5506 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 6 May 2021 11:34:12 -0700 Subject: [PATCH] libc/pty: Make ptsname[_r] support PSEUDOTERM_BSD config too Signed-off-by: Xiang Xiao Change-Id: I82a60ded48ea3437bd5f2b4fe328294d7077b040 --- include/cxx/cstdlib | 2 -- include/stdlib.h | 5 +---- libs/libc/stdlib/Make.defs | 6 +----- libs/libc/stdlib/lib_ptsname.c | 4 ++-- libs/libc/stdlib/lib_ptsnamer.c | 9 +++++++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/cxx/cstdlib b/include/cxx/cstdlib index 694d33e5f66..980956301d8 100644 --- a/include/cxx/cstdlib +++ b/include/cxx/cstdlib @@ -104,10 +104,8 @@ namespace std #ifdef CONFIG_PSEUDOTERM // Pseudo-Terminals -#ifdef CONFIG_PSEUDOTERM_SUSV1 using ::ptsname; using ::ptsname_r; -#endif using ::unlockpt; #endif diff --git a/include/stdlib.h b/include/stdlib.h index f43bae48dd7..690b29448af 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -211,12 +211,9 @@ int posix_memalign(FAR void **, size_t, size_t); /* Pseudo-Terminals */ -#ifdef CONFIG_PSEUDOTERM_SUSV1 +#ifdef CONFIG_PSEUDOTERM FAR char *ptsname(int fd); int ptsname_r(int fd, FAR char *buf, size_t buflen); -#endif - -#ifdef CONFIG_PSEUDOTERM int unlockpt(int fd); /* int grantpt(int fd); Not implemented */ diff --git a/libs/libc/stdlib/Make.defs b/libs/libc/stdlib/Make.defs index 3cb6269538f..3d1aa3423e0 100644 --- a/libs/libc/stdlib/Make.defs +++ b/libs/libc/stdlib/Make.defs @@ -32,12 +32,8 @@ CSRCS += lib_mblen.c lib_mbtowc.c lib_wctomb.c CSRCS += lib_mbstowcs.c lib_wcstombs.c endif -ifeq ($(CONFIG_PSEUDOTERM_SUSV1),y) -CSRCS += lib_ptsname.c lib_ptsnamer.c -endif - ifeq ($(CONFIG_PSEUDOTERM),y) -CSRCS += lib_unlockpt.c +CSRCS += lib_ptsname.c lib_ptsnamer.c lib_unlockpt.c endif # Add the stdlib directory to the build diff --git a/libs/libc/stdlib/lib_ptsname.c b/libs/libc/stdlib/lib_ptsname.c index 4ed9d2ae077..170db5d7e6a 100644 --- a/libs/libc/stdlib/lib_ptsname.c +++ b/libs/libc/stdlib/lib_ptsname.c @@ -26,7 +26,7 @@ #include -#ifdef CONFIG_PSEUDOTERM_SUSV1 +#ifdef CONFIG_PSEUDOTERM /**************************************************************************** * Public Functions @@ -55,4 +55,4 @@ FAR char *ptsname(int fd) return ret < 0 ? NULL : devname; } -#endif /* CONFIG_PSEUDOTERM_SUSV1 */ +#endif /* CONFIG_PSEUDOTERM */ diff --git a/libs/libc/stdlib/lib_ptsnamer.c b/libs/libc/stdlib/lib_ptsnamer.c index f7ef41cc684..cf8343f7979 100644 --- a/libs/libc/stdlib/lib_ptsnamer.c +++ b/libs/libc/stdlib/lib_ptsnamer.c @@ -29,7 +29,7 @@ #include #include -#ifdef CONFIG_PSEUDOTERM_SUSV1 +#ifdef CONFIG_PSEUDOTERM /**************************************************************************** * Public Functions @@ -73,8 +73,13 @@ int ptsname_r(int fd, FAR char *buf, size_t buflen) * error detection. */ +#ifdef CONFIG_PSEUDOTERM_SUSV1 snprintf(buf, buflen, "/dev/pts/%d", ptyno); +#else + snprintf(buf, buflen, "/dev/ttyp%d", ptyno); +#endif + return OK; } -#endif /* CONFIG_PSEUDOTERM_SUSV1 */ +#endif /* CONFIG_PSEUDOTERM */