Merge branch 'termios-baudrate' into 'master'
Add termios baud rate functions See merge request redox-os/relibc!165
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
//! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html
|
||||
|
||||
use header::errno;
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
@@ -31,6 +33,44 @@ pub extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *mut termios) -> c_int
|
||||
Sys::tcsetattr(fd, act, value)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t {
|
||||
unsafe { (*termios_p).__c_ispeed }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t {
|
||||
unsafe { (*termios_p).__c_ospeed }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int {
|
||||
match speed as usize {
|
||||
B0..=B38400 | B57600..=B4000000 => {
|
||||
unsafe { (*termios_p).__c_ispeed = speed };
|
||||
0
|
||||
}
|
||||
_ => {
|
||||
unsafe { platform::errno = errno::EINVAL };
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int {
|
||||
match speed as usize {
|
||||
B0..=B38400 | B57600..=B4000000 => {
|
||||
unsafe { (*termios_p).__c_ospeed = speed };
|
||||
0
|
||||
}
|
||||
_ => {
|
||||
unsafe { platform::errno = errno::EINVAL };
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const VINTR: usize = 0;
|
||||
pub const VQUIT: usize = 1;
|
||||
pub const VERASE: usize = 2;
|
||||
|
||||
Reference in New Issue
Block a user