diff options
author | Joshua M. Clulow <josh@sysmgr.org> | 2020-04-05 15:01:47 -0600 |
---|---|---|
committer | David Cuddeback <david.cuddeback@gmail.com> | 2020-04-05 15:54:36 -0600 |
commit | 3a74afc2010b9068dc4bd76ca26ef0aca6b412a2 (patch) | |
tree | be0706de14226d25bad809028df1352f00a6b0db | |
parent | 3f47df3516da01f0426b7197ddb6c97705bbdcb9 (diff) | |
download | termios-rs-3a74afc2010b9068dc4bd76ca26ef0aca6b412a2.zip |
Illumos fixes
Fixes the fallback `cfmakeraw()` implementation to set `VMIN` and
`VTIME` appropriately for blocking reads.
Also adds a few missing constants to `solaris.rs` and reorders the
constants to match the header files in OpenIndiana and OmniOS.
-rw-r--r-- | src/ffi.rs | 16 | ||||
-rw-r--r-- | src/os/solaris.rs | 71 |
2 files changed, 46 insertions, 41 deletions
@@ -26,14 +26,16 @@ extern "C" { pub unsafe extern "C" fn cfmakeraw(termios: *mut ::os::target::termios) { use ::os::target::{IMAXBEL, IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON}; use ::os::target::{OPOST, ECHO, ECHONL, ICANON, ISIG, IEXTEN, CSIZE, PARENB, CS8}; + use ::os::target::{VMIN, VTIME}; - let mut t = *termios; - - t.c_iflag &= !(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - t.c_oflag &= !OPOST; - t.c_lflag &= !(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - t.c_cflag &= !(CSIZE|PARENB); - t.c_cflag |= CS8; + // Equivalent of cfmakeraw() in glibc + (*termios).c_iflag &= !(IMAXBEL | 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; + (*termios).c_cc[VMIN] = 1; + (*termios).c_cc[VTIME] = 0; } #[cfg(target_os = "solaris")] diff --git a/src/os/solaris.rs b/src/os/solaris.rs index 27ffc61..eca1686 100644 --- a/src/os/solaris.rs +++ b/src/os/solaris.rs @@ -55,39 +55,42 @@ pub const IXON: tcflag_t = 0o002000; pub const IXANY: tcflag_t = 0o004000; pub const IXOFF: tcflag_t = 0o010000; pub const IMAXBEL: tcflag_t = 0o020000; +pub const DOSMODE: tcflag_t = 0o100000; // c_oflag bits -pub const OPOST: tcflag_t = 0o000001; -pub const OLCUC: tcflag_t = 0o000002; -pub const ONLCR: tcflag_t = 0o000004; -pub const OCRNL: tcflag_t = 0o000010; -pub const ONOCR: tcflag_t = 0o000020; -pub const ONLRET: tcflag_t = 0o000040; -pub const OFILL: tcflag_t = 0o000100; -pub const OFDEL: tcflag_t = 0o000200; -pub const NLDLY: tcflag_t = 0o000400; -pub const NL0: tcflag_t = 0o000000; -pub const NL1: tcflag_t = 0o000400; -pub const CRDLY: tcflag_t = 0o003000; -pub const CR0: tcflag_t = 0o000000; -pub const CR1: tcflag_t = 0o001000; -pub const CR2: tcflag_t = 0o002000; -pub const CR3: tcflag_t = 0o003000; -pub const TABDLY: tcflag_t = 0o014000; -pub const TAB0: tcflag_t = 0o000000; -pub const TAB1: tcflag_t = 0o004000; -pub const TAB2: tcflag_t = 0o010000; -pub const TAB3: tcflag_t = 0o014000; -pub const BSDLY: tcflag_t = 0o020000; -pub const BS0: tcflag_t = 0o000000; -pub const BS1: tcflag_t = 0o020000; -pub const FFDLY: tcflag_t = 0o100000; -pub const FF0: tcflag_t = 0o000000; -pub const FF1: tcflag_t = 0o100000; -pub const VTDLY: tcflag_t = 0o040000; -pub const VT0: tcflag_t = 0o000000; -pub const VT1: tcflag_t = 0o040000; -pub const XTABS: tcflag_t = 0o014000; +pub const OPOST: tcflag_t = 0o000001; +pub const OLCUC: tcflag_t = 0o000002; +pub const ONLCR: tcflag_t = 0o000004; +pub const OCRNL: tcflag_t = 0o000010; +pub const ONOCR: tcflag_t = 0o000020; +pub const ONLRET: tcflag_t = 0o000040; +pub const OFILL: tcflag_t = 0o000100; +pub const OFDEL: tcflag_t = 0o000200; +pub const NLDLY: tcflag_t = 0o000400; +pub const NL0: tcflag_t = 0o000000; +pub const NL1: tcflag_t = 0o000400; +pub const CRDLY: tcflag_t = 0o003000; +pub const CR0: tcflag_t = 0o000000; +pub const CR1: tcflag_t = 0o001000; +pub const CR2: tcflag_t = 0o002000; +pub const CR3: tcflag_t = 0o003000; +pub const TABDLY: tcflag_t = 0o014000; +pub const TAB0: tcflag_t = 0o000000; +pub const TAB1: tcflag_t = 0o004000; +pub const TAB2: tcflag_t = 0o010000; +pub const TAB3: tcflag_t = 0o014000; +pub const XTABS: tcflag_t = 0o014000; +pub const BSDLY: tcflag_t = 0o020000; +pub const BS0: tcflag_t = 0o000000; +pub const BS1: tcflag_t = 0o020000; +pub const VTDLY: tcflag_t = 0o040000; +pub const VT0: tcflag_t = 0o000000; +pub const VT1: tcflag_t = 0o040000; +pub const FFDLY: tcflag_t = 0o100000; +pub const FF0: tcflag_t = 0o000000; +pub const FF1: tcflag_t = 0o100000; +pub const PAGEOUT: tcflag_t = 0o200000; +pub const WRAP: tcflag_t = 0o400000; // c_cflag bits pub const CBAUD: tcflag_t = 0o000017; @@ -171,6 +174,6 @@ pub const TCOFLUSH: c_int = 1; pub const TCIOFLUSH: c_int = 2; // tcsetattr() -pub const TCSANOW: c_int = 0o052016; -pub const TCSADRAIN: c_int = 0o052017; -pub const TCSAFLUSH: c_int = 0o052020; +pub const TCSANOW: c_int = 0x540E; +pub const TCSADRAIN: c_int = 0x540F; +pub const TCSAFLUSH: c_int = 0x5410; |