summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2017-02-26 13:16:12 -0800
committerBryant Mairs <bryant@mai.rs>2017-02-27 09:54:58 -0800
commit39e554f3f8ca0ba501f66275a7586a610d843355 (patch)
treefbd1e22da7fea495a5827bfa81a132f45fb018dd
parentb9a0a6a77cd940cc646724923137c32f0008930f (diff)
downloadrust-libc-39e554f3f8ca0ba501f66275a7586a610d843355.tar.gz
Add cfmakeraw and cfsetspeed
This includes implementations for Android.
-rw-r--r--src/unix/mod.rs2
-rw-r--r--src/unix/notbsd/android/mod.rs15
2 files changed, 17 insertions, 0 deletions
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 47edaf1ae1..3030f80e09 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -835,8 +835,10 @@ extern {
pub fn tcdrain(fd: ::c_int) -> ::c_int;
pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
+ pub fn cfmakeraw(termios: *mut ::termios);
pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
+ pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
pub fn tcsetattr(fd: ::c_int,
optional_actions: ::c_int,
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index 79d8a53764..3884a77078 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -752,6 +752,16 @@ f! {
pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t {
(*termios).c_cflag & ::CBAUD
}
+ pub fn cfmakeraw(termios: *mut ::termios) -> () {
+ (*termios).c_iflag &= !(::IGNBRK | ::BRKINT | ::PARMRK | ::ISTRIP |
+ ::INLCR | ::IGNCR | ::ICRNL | ::IXON);
+ (*termios).c_oflag &= !::OPOST;
+ (*termios).c_lflag &= !(::ECHO | ::ECHONL | ::ICANON | ::ISIG |
+ ::IEXTEN);
+ (*termios).c_cflag &= !(::CSIZE | ::PARENB);
+ (*termios).c_cflag |= ::CS8;
+ ()
+ }
pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int {
let cbaud = ::CBAUD;
(*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
@@ -762,6 +772,11 @@ f! {
(*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
return 0
}
+ pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int {
+ let cbaud = ::CBAUD;
+ (*termios).c_cflag = ((*termios).c_cflag & !cbaud) | (speed & cbaud);
+ return 0
+ }
pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int {
ioctl(fd, ::TCGETS, termios)
}