split out winsize from sys_ioctl header
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/termios.h.html
|
||||
#
|
||||
# This type is split out to include it in the following headers:
|
||||
# - sys/ioctl.h (Non-POSIX)
|
||||
# - termios.h (POSIX, where it should be defined)
|
||||
include_guard = "_RELIBC_BITS_WINSIZE_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
[export]
|
||||
include = ["winsize"]
|
||||
@@ -0,0 +1,16 @@
|
||||
use crate::platform::types::c_ushort;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct winsize {
|
||||
ws_row: c_ushort,
|
||||
ws_col: c_ushort,
|
||||
ws_xpixel: c_ushort,
|
||||
ws_ypixel: c_ushort,
|
||||
}
|
||||
|
||||
impl winsize {
|
||||
pub fn get_row_col(&self) -> (c_ushort, c_ushort) {
|
||||
(self.ws_row, self.ws_col)
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ pub mod bits_timeval;
|
||||
pub mod bits_uid_t;
|
||||
#[path = "bits_useconds-t/mod.rs"]
|
||||
pub mod bits_useconds_t;
|
||||
pub mod bits_winsize;
|
||||
// complex.h implemented in C (currently through openlibm)
|
||||
pub mod cpio;
|
||||
pub mod crypt;
|
||||
|
||||
@@ -29,7 +29,7 @@ pub unsafe extern "C" fn openpty(
|
||||
aslave: *mut c_int,
|
||||
namep: *mut c_char,
|
||||
termp: *const termios::termios,
|
||||
winp: *const sys_ioctl::winsize,
|
||||
winp: *const termios::winsize,
|
||||
) -> c_int {
|
||||
let mut tmp_name = [0; limits::PATH_MAX];
|
||||
let name = if !namep.is_null() {
|
||||
@@ -63,7 +63,7 @@ pub unsafe extern "C" fn forkpty(
|
||||
pm: *mut c_int,
|
||||
name: *mut c_char,
|
||||
tio: *const termios::termios,
|
||||
ws: *const sys_ioctl::winsize,
|
||||
ws: *const termios::winsize,
|
||||
) -> c_int {
|
||||
let mut m = 0;
|
||||
let mut s = 0;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
include_guard = "_RELIBC_SYS_IOCTL_H"
|
||||
after_includes = """
|
||||
#include <bits/winsize.h> // for winsize from termios.h
|
||||
|
||||
// Shamelessly copy-pasted from musl
|
||||
|
||||
#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
|
||||
@@ -21,4 +23,4 @@ cpp_compat = true
|
||||
prefix_with_name = true
|
||||
|
||||
[export]
|
||||
include = ["sgttyb", "winsize"]
|
||||
include = ["sgttyb"]
|
||||
|
||||
@@ -12,21 +12,6 @@ pub struct sgttyb {
|
||||
sg_flags: c_ushort,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct winsize {
|
||||
ws_row: c_ushort,
|
||||
ws_col: c_ushort,
|
||||
ws_xpixel: c_ushort,
|
||||
ws_ypixel: c_ushort,
|
||||
}
|
||||
|
||||
impl winsize {
|
||||
pub fn get_row_col(&self) -> (c_ushort, c_ushort) {
|
||||
(self.ws_row, self.ws_col)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use self::linux::*;
|
||||
|
||||
|
||||
@@ -4,15 +4,13 @@ use syscall;
|
||||
|
||||
use crate::{
|
||||
error::{Errno, Result, ResultExt},
|
||||
header::{errno::EINVAL, fcntl, termios},
|
||||
header::{bits_winsize::winsize, errno::EINVAL, fcntl, termios},
|
||||
platform::{
|
||||
Pal, Sys,
|
||||
types::{c_int, c_ulong, c_ulonglong, c_void, pid_t},
|
||||
},
|
||||
};
|
||||
|
||||
use super::winsize;
|
||||
|
||||
mod drm;
|
||||
|
||||
pub const TCGETS: c_ulong = 0x5401;
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
# - "The <termios.h> header shall define the pid_t type as described in <sys/types.h>."
|
||||
sys_includes = []
|
||||
after_includes = """
|
||||
#include <bits/pid-t.h> // for pid_t from sys/types.h
|
||||
#include <bits/pid-t.h> // for pid_t from sys/types.h
|
||||
#include <bits/winsize.h> // for winsize
|
||||
"""
|
||||
include_guard = "_RELIBC_TERMIOS_H"
|
||||
language = "C"
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
pub use crate::header::sys_ioctl::winsize;
|
||||
pub use crate::header::bits_winsize::winsize;
|
||||
|
||||
pub use self::sys::*;
|
||||
|
||||
@@ -39,9 +39,6 @@ pub const TCSANOW: c_int = 0;
|
||||
pub const TCSADRAIN: c_int = 1;
|
||||
pub const TCSAFLUSH: c_int = 2;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn cbindgen_export_winsize(winsize: winsize) {}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/termios.h.html>.
|
||||
#[cfg(target_os = "linux")]
|
||||
#[repr(C)]
|
||||
|
||||
Reference in New Issue
Block a user