From e5d2ba754ac998cda0d7561af6748d52df86033a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 13 Sep 2021 20:39:40 -0600 Subject: [PATCH] Match termios structure to that used in redox_termios --- src/header/termios/mod.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index f5d1705785..afe73a613a 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -32,6 +32,7 @@ pub const TCSANOW: usize = 0; pub const TCSADRAIN: usize = 1; pub const TCSAFLUSH: usize = 2; +#[cfg(target_os = "linux")] #[repr(C)] #[derive(Default)] pub struct termios { @@ -45,6 +46,18 @@ pub struct termios { __c_ospeed: speed_t, } +// Must match structure in redox_termios +#[cfg(target_os = "redox")] +#[repr(C)] +#[derive(Default)] +pub struct termios { + c_iflag: tcflag_t, + c_oflag: tcflag_t, + c_cflag: tcflag_t, + c_lflag: tcflag_t, + c_cc: [cc_t; NCCS], +} + #[no_mangle] pub unsafe extern "C" fn tcgetattr(fd: c_int, out: *mut termios) -> c_int { sys_ioctl::ioctl(fd, sys_ioctl::TCGETS, out as *mut c_void) @@ -60,16 +73,33 @@ pub unsafe extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *mut termios) - sys_ioctl::ioctl(fd, sys_ioctl::TCSETS + act as c_ulong, value as *mut c_void) } +#[cfg(target_os = "linux")] #[no_mangle] pub unsafe extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t { (*termios_p).__c_ispeed } +#[cfg(target_os = "redox")] +#[no_mangle] +pub unsafe extern "C" fn cfgetispeed(termios_p: *const termios) -> speed_t { + //TODO + 0 +} + +#[cfg(target_os = "linux")] #[no_mangle] pub unsafe extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t { (*termios_p).__c_ospeed } +#[cfg(target_os = "redox")] +#[no_mangle] +pub unsafe extern "C" fn cfgetospeed(termios_p: *const termios) -> speed_t { + //TODO + 0 +} + +#[cfg(target_os = "linux")] #[no_mangle] pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> c_int { match speed as usize { @@ -84,6 +114,7 @@ pub unsafe extern "C" fn cfsetispeed(termios_p: *mut termios, speed: speed_t) -> } } +#[cfg(target_os = "linux")] #[no_mangle] pub unsafe extern "C" fn cfsetospeed(termios_p: *mut termios, speed: speed_t) -> c_int { match speed as usize {