Skip to content
Snippets Groups Projects
Commit efcc232d authored by Ticki's avatar Ticki
Browse files

32-bit support

parent 22ef2409
No related branches found
No related tags found
No related merge requests found
......@@ -12,18 +12,30 @@ struct TermSize {
_y: c_ushort,
}
// Since attributes on non-item statements is not stable yet, we use a function.
#[cfg(target_pointer_width = "64")]
fn tiocgwinsz() -> u64 {
use termios::TIOCGWINSZ;
TIOCGWINSZ as u64
}
#[cfg(target_pointer_width = "32")]
fn tiocgwinsz() -> u32 {
use termios::TIOCGWINSZ;
TIOCGWINSZ as u32
}
/// Get the size of the terminal.
#[cfg(not(target_os = "redox"))]
pub fn terminal_size() -> Result<(usize, usize), TerminalError> {
use libc::ioctl;
use libc::STDOUT_FILENO;
use termios::TIOCGWINSZ;
use std::mem;
unsafe {
let mut size: TermSize = mem::zeroed();
if ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut size as *mut _) == 0 {
if ioctl(STDOUT_FILENO, tiocgwinsz(), &mut size as *mut _) == 0 {
Ok((size.col as usize, size.row as usize))
} else {
Err(TerminalError::TermSizeError)
......
use libc::{c_int, c_uint, c_uchar};
#[cfg(not(target_os = "macos"))]
pub const TIOCGWINSZ: u64 = 0x00005413;
pub const TIOCGWINSZ: usize = 0x00005413;
#[cfg(target_os = "macos")]
pub const TIOCGWINSZ: u64 = 0x40087468;
pub const TIOCGWINSZ: usize = 0x40087468;
extern {
pub fn tcgetattr(filedes: c_int, termptr: *mut Termios) -> c_int;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment