Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Add legacy inlines for more termios stuff.
Browse files Browse the repository at this point in the history
Test: make checkbuild # with my versioner-in-build patches
Bug: android/ndk#302
Change-Id: Ib00b5dadf23592d101486b4f2188285ec03c9e2a
  • Loading branch information
DanAlbert committed Feb 23, 2017
1 parent 45715b2 commit 4473e34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 12 additions & 0 deletions libc/include/android/legacy_termios_inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions libc/include/termios.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 <android/legacy_termios_inlines.h>
Expand Down

0 comments on commit 4473e34

Please sign in to comment.