From 4473e34acbd9b8f97f04dd52ac7ccd856370e6d1 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 23 Feb 2017 11:09:32 -0800 Subject: [PATCH] Add legacy inlines for more termios stuff. Test: make checkbuild # with my versioner-in-build patches Bug: https://github.com/android-ndk/ndk/issues/302 Change-Id: Ib00b5dadf23592d101486b4f2188285ec03c9e2a --- libc/include/android/legacy_termios_inlines.h | 12 ++++++++++++ libc/include/termios.h | 5 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h index 4424bdb0b..02e942920 100644 --- a/libc/include/android/legacy_termios_inlines.h +++ b/libc/include/android/legacy_termios_inlines.h @@ -91,6 +91,18 @@ static __inline void cfmakeraw(struct termios *s) { s->c_cflag |= CS8; } +static __inline int cfsetspeed(struct termios* s, speed_t speed) { + // TODO: check 'speed' is valid. + s->c_cflag = (s->c_cflag & ~CBAUD) | (speed & CBAUD); + return 0; +} + +static __inline int tcdrain(int fd) { + // A non-zero argument to TCSBRK means "don't send a break". + // The drain is a side-effect of the ioctl! + return ioctl(fd, TCSBRK, __BIONIC_CAST(static_cast, unsigned long, 1)); +} + __END_DECLS #endif diff --git a/libc/include/termios.h b/libc/include/termios.h index 49ffcd2e4..66ae71cd5 100644 --- a/libc/include/termios.h +++ b/libc/include/termios.h @@ -40,8 +40,10 @@ __BEGIN_DECLS speed_t cfgetispeed(const struct termios*) __INTRODUCED_IN(21); speed_t cfgetospeed(const struct termios*) __INTRODUCED_IN(21); void cfmakeraw(struct termios*) __INTRODUCED_IN(21); +int cfsetspeed(struct termios*, speed_t) __INTRODUCED_IN(21); int cfsetispeed(struct termios*, speed_t) __INTRODUCED_IN(21); int cfsetospeed(struct termios*, speed_t) __INTRODUCED_IN(21); +int tcdrain(int) __INTRODUCED_IN(21); int tcflow(int, int) __INTRODUCED_IN(21); int tcflush(int, int) __INTRODUCED_IN(21); int tcgetattr(int, struct termios*) __INTRODUCED_IN(21); @@ -50,9 +52,6 @@ int tcsendbreak(int, int) __INTRODUCED_IN(21); int tcsetattr(int, int, const struct termios*) __INTRODUCED_IN(21); #endif -int cfsetspeed(struct termios*, speed_t) __INTRODUCED_IN(21); -int tcdrain(int) __INTRODUCED_IN(21); - __END_DECLS #include -- 2.11.0