summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-02-23 21:35:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-02-23 21:35:12 +0000
commit7cd856380a0d56b28543933a510683b236bc863f (patch)
tree8600efbbb302c0a4d239fdecbecee16a7c9155fd
parent7c90e2bf6b935f524e5dee7871155c454a28e2c0 (diff)
parent40b0d6c85be3f5329dc35a7833512b874bdf37f3 (diff)
downloaddevelopment-ndk-r14-release.tar.gz
Merge "Backport the inlines for cfsetspeed and tcdrain." into ndk-r14-releasendk-r14ndk-r14-release
-rw-r--r--ndk/platforms/android-9/include/sys/cdefs.h6
-rw-r--r--ndk/platforms/android-9/include/termios.h12
2 files changed, 18 insertions, 0 deletions
diff --git a/ndk/platforms/android-9/include/sys/cdefs.h b/ndk/platforms/android-9/include/sys/cdefs.h
index 9a8dfdd20..eb9a654cd 100644
--- a/ndk/platforms/android-9/include/sys/cdefs.h
+++ b/ndk/platforms/android-9/include/sys/cdefs.h
@@ -86,6 +86,12 @@
#define __static_cast(x,y) (x)y
#endif
+#if defined(__cplusplus)
+#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
+#else
+#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
+#endif
+
/*
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
diff --git a/ndk/platforms/android-9/include/termios.h b/ndk/platforms/android-9/include/termios.h
index ad1908995..fc991aba8 100644
--- a/ndk/platforms/android-9/include/termios.h
+++ b/ndk/platforms/android-9/include/termios.h
@@ -108,6 +108,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 /* _TERMIOS_H_ */