summaryrefslogtreecommitdiff
path: root/src/sys/termios.rs
diff options
context:
space:
mode:
authorTim JIANG <p90eri@gmail.com>2015-07-23 17:38:18 +0800
committerCarl Lerche <me@carllerche.com>2015-07-27 10:31:26 -0700
commit08a55288d143e7674b0f7b3c302a601dcc72bdb0 (patch)
treee0d4ad627c4dcd6d15c3ebe2a8f63fa2515ef020 /src/sys/termios.rs
parent5801318c0c4c6eeb3431144a89496830f55d6628 (diff)
downloadnix-08a55288d143e7674b0f7b3c302a601dcc72bdb0.zip
Make it compatible for Android.
* Fixed an unused_import error in `termios.rs` for Android. * Fixed undefined references to `preadv` and `pwritev` for Android - At least they don't exist from API level 3 to 21. * Fixed the uid > 0 and gid > 0 checks in `stat`'s tests - Running the tests by root is possible, especially when running on a rooted Android device. Those changes made rust-nix buildable (again) on Android. All the tests passed as well.
Diffstat (limited to 'src/sys/termios.rs')
-rw-r--r--src/sys/termios.rs42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 4050e7d5..a9fd41ec 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -10,29 +10,35 @@ pub use self::ffi::consts::FlushArg::*;
pub use self::ffi::consts::FlowArg::*;
mod ffi {
- use libc::c_int;
-
pub use self::consts::*;
- // `Termios` contains bitflags which are not considered
- // `foreign-function-safe` by the compiler.
- #[allow(improper_ctypes)]
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))]
- extern {
- pub fn cfgetispeed(termios: *const Termios) -> speed_t;
- pub fn cfgetospeed(termios: *const Termios) -> speed_t;
- pub fn cfsetispeed(termios: *mut Termios, speed: speed_t) -> c_int;
- pub fn cfsetospeed(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,
- termios: *const Termios) -> c_int;
- pub fn tcdrain(fd: c_int) -> c_int;
- pub fn tcflow(fd: c_int, action: c_int) -> c_int;
- pub fn tcflush(fd: c_int, action: c_int) -> c_int;
- pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
+ mod non_android {
+ use super::consts::*;
+ use libc::c_int;
+
+ // `Termios` contains bitflags which are not considered
+ // `foreign-function-safe` by the compiler.
+ #[allow(improper_ctypes)]
+ extern {
+ pub fn cfgetispeed(termios: *const Termios) -> speed_t;
+ pub fn cfgetospeed(termios: *const Termios) -> speed_t;
+ pub fn cfsetispeed(termios: *mut Termios, speed: speed_t) -> c_int;
+ pub fn cfsetospeed(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,
+ termios: *const Termios) -> c_int;
+ pub fn tcdrain(fd: c_int) -> c_int;
+ pub fn tcflow(fd: c_int, action: c_int) -> c_int;
+ pub fn tcflush(fd: c_int, action: c_int) -> c_int;
+ pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
+ }
}
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))]
+ pub use self::non_android::*;
+
// On Android before 5.0, Bionic directly inline these to ioctl() calls.
#[inline]
#[cfg(all(target_os = "android", not(target_arch = "mips")))]