Delete duplicate types

Now that we use cbindgen differently :D
This commit is contained in:
jD91mZM2
2018-09-02 08:17:15 +02:00
parent dbe18b92f0
commit 6fe3e05ea0
30 changed files with 148 additions and 278 deletions
+12 -9
View File
@@ -4,19 +4,22 @@ use core::{mem, ptr};
use super::types::*;
use super::{errno, FileWriter, Pal};
use c_str::CStr;
use header::dirent::dirent;
use header::errno::{EINVAL, ENOSYS};
use header::signal::SIGCHLD;
use header::sys_resource::rusage;
use header::sys_select::fd_set;
use header::sys_stat::stat;
use header::sys_time::{itimerval, timeval, timezone};
use header::sys_times::tms;
use header::sys_utsname::utsname;
use header::sys_ioctl::{winsize, TCGETS, TCSETS, TIOCGWINSZ};
use header::termios::termios;
use header::time::timespec;
mod signal;
mod socket;
const EINVAL: c_int = 22;
const ENOSYS: c_int = 38;
const SIGCHLD: usize = 17;
const TCGETS: c_ulong = 0x5401;
const TCSETS: c_ulong = 0x5402;
const TIOCGWINSZ: c_ulong = 0x5413;
const AT_FDCWD: c_int = -100;
const AT_EMPTY_PATH: c_int = 0x1000;
const AT_REMOVEDIR: c_int = 0x200;
+1
View File
@@ -1,5 +1,6 @@
use core::mem;
use header::signal::{sigaction, sigset_t};
use super::super::types::*;
use super::super::PalSignal;
use super::{e, Sys};
+1
View File
@@ -1,3 +1,4 @@
use header::sys_socket::{sockaddr, socklen_t};
use super::super::types::*;
use super::super::PalSocket;
use super::{e, Sys};
+9
View File
@@ -2,6 +2,15 @@ use core::ptr;
use super::types::*;
use c_str::CStr;
use header::dirent::dirent;
use header::sys_resource::rusage;
use header::sys_select::fd_set;
use header::sys_stat::stat;
use header::sys_time::{itimerval, timeval, timezone};
use header::sys_times::tms;
use header::sys_utsname::utsname;
use header::termios::termios;
use header::time::timespec;
pub use self::signal::PalSignal;
mod signal;
+1
View File
@@ -1,3 +1,4 @@
use header::signal::{sigaction, sigset_t};
use super::super::types::*;
use super::super::Pal;
+1
View File
@@ -1,3 +1,4 @@
use header::sys_socket::{sockaddr, socklen_t};
use super::super::types::*;
use super::super::Pal;
+14 -5
View File
@@ -9,17 +9,26 @@ use syscall::data::TimeSpec as redox_timespec;
use syscall::flag::*;
use syscall::{self, Result};
use c_str::{CStr, CString};
use header::dirent::dirent;
use header::errno::{EINVAL, ENOSYS};
use header::sys_mman::MAP_ANON;
use header::sys_resource::rusage;
use header::sys_select::fd_set;
use header::sys_stat::stat;
use header::sys_time::{itimerval, timeval, timezone};
use header::sys_times::tms;
use header::sys_utsname::utsname;
use header::termios::termios;
use header::time::timespec;
use header::unistd::{F_OK, R_OK, W_OK, X_OK};
use super::types::*;
use super::{errno, FileReader, FileWriter, Pal, RawFile, Read};
use c_str::{CStr, CString};
mod signal;
mod socket;
const EINVAL: c_int = 22;
const ENOSYS: c_int = 38;
const MAP_ANON: c_int = 1;
static ANONYMOUS_MAPS: Once<Mutex<BTreeMap<usize, usize>>> = Once::new();
fn anonymous_maps() -> MutexGuard<'static, BTreeMap<usize, usize>> {
+1
View File
@@ -1,5 +1,6 @@
use syscall;
use header::signal::{sigaction, sigset_t};
use super::super::types::*;
use super::super::{Pal, PalSignal};
use super::{e, Sys};
+13 -3
View File
@@ -2,6 +2,9 @@ use core::{mem, ptr, slice};
use syscall::flag::*;
use syscall::{self, Result};
use header::netinet_in::{in_addr_t, in_port_t, sockaddr_in};
use header::sys_socket::constants::*;
use header::sys_socket::{sockaddr, socklen_t};
use super::super::types::*;
use super::super::{errno, Pal, PalSocket};
use super::{e, Sys};
@@ -23,9 +26,16 @@ macro_rules! bind_or_connect {
return -1;
}
let data = &*($address as *const sockaddr_in);
let addr = &data.sin_addr.s_addr;
let port = in_port_t::from_be(data.sin_port); // This is transmuted from bytes in BigEndian order
let path = format!(bind_or_connect!($mode "{}.{}.{}.{}:{}"), addr[0], addr[1], addr[2], addr[3], port);
let addr = data.sin_addr.s_addr;
let port = data.sin_port;
let path = format!(
bind_or_connect!($mode "{}.{}.{}.{}:{}"),
addr >> 8*3,
addr >> 8*2 & 0xFF,
addr >> 8 & 0xFF,
addr & 0xFF,
port
);
// Duplicate the socket, and then duplicate the copy back to the original fd
let fd = e(syscall::dup($socket as usize, path.as_bytes()));
-195
View File
@@ -1,6 +1,3 @@
use core::mem;
#[cfg(target_os = "redox")]
use syscall::data::TimeSpec as redox_timespec;
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
// more optimization opportunities around it recognizing things like
// malloc/free.
@@ -68,195 +65,3 @@ pub type suseconds_t = c_int;
pub type clock_t = c_long;
pub type clockid_t = c_int;
pub type timer_t = *mut c_void;
#[repr(C)]
#[derive(Default)]
pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: c_long,
}
#[repr(C)]
#[derive(Default)]
pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
}
#[repr(C)]
#[derive(Default)]
pub struct timezone {
pub tz_minuteswest: c_int,
pub tz_dsttime: c_int,
}
#[repr(C)]
#[derive(Default)]
pub struct itimerval {
pub it_interval: timeval,
pub it_value: timeval,
}
#[cfg(target_os = "redox")]
impl<'a> From<&'a timespec> for redox_timespec {
fn from(tp: &timespec) -> redox_timespec {
redox_timespec {
tv_sec: tp.tv_sec,
tv_nsec: tp.tv_nsec as i32,
}
}
}
#[repr(C)]
#[derive(Default)]
pub struct stat {
pub st_dev: dev_t,
pub st_ino: ino_t,
pub st_nlink: nlink_t,
pub st_mode: mode_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub st_size: off_t,
pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t,
pub st_atim: timespec,
pub st_mtim: timespec,
pub st_ctim: timespec,
// Compared to glibc, our struct is for some reason 24 bytes too small.
// Accessing atime works, so clearly the struct isn't incorrect...
// This works.
pub _pad: [c_char; 24],
}
pub const AF_INET: c_int = 2;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_NONBLOCK: c_int = 0o4000;
pub const SOCK_CLOEXEC: c_int = 0o2000000;
pub const SIG_BLOCK: c_int = 0;
pub const SIG_UNBLOCK: c_int = 1;
pub const SIG_SETMASK: c_int = 2;
pub type in_addr_t = [u8; 4];
pub type in_port_t = u16;
pub type sa_family_t = u16;
pub type socklen_t = u32;
#[repr(C)]
pub struct sockaddr {
pub sa_family: sa_family_t,
pub data: [c_char; 14],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct in_addr {
pub s_addr: in_addr_t,
}
#[repr(C)]
pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
}
#[repr(C)]
pub struct sigaction {
pub sa_handler: Option<extern "C" fn(c_int)>,
pub sa_flags: c_ulong,
pub sa_restorer: Option<unsafe extern "C" fn()>,
pub sa_mask: sigset_t,
}
pub type sigset_t = c_ulong;
const UTSLENGTH: usize = 65;
#[repr(C)]
pub struct utsname {
pub sysname: [c_char; UTSLENGTH],
pub nodename: [c_char; UTSLENGTH],
pub release: [c_char; UTSLENGTH],
pub version: [c_char; UTSLENGTH],
pub machine: [c_char; UTSLENGTH],
pub domainname: [c_char; UTSLENGTH],
}
#[repr(C)]
pub struct dirent {
pub d_ino: ino_t,
pub d_off: off_t,
pub d_reclen: c_ushort,
pub d_type: c_uchar,
pub d_name: [c_char; 256],
}
#[repr(C)]
#[derive(Default)]
pub struct winsize {
ws_row: c_ushort,
ws_col: c_ushort,
ws_xpixel: c_ushort,
ws_ypixel: c_ushort,
}
#[repr(C)]
pub struct rusage {
pub ru_utime: timeval,
pub ru_stime: timeval,
pub ru_maxrss: c_long,
pub ru_ixrss: c_long,
pub ru_idrss: c_long,
pub ru_isrss: c_long,
pub ru_minflt: c_long,
pub ru_majflt: c_long,
pub ru_nswap: c_long,
pub ru_inblock: c_long,
pub ru_oublock: c_long,
pub ru_msgsnd: c_long,
pub ru_msgrcv: c_long,
pub ru_nsignals: c_long,
pub ru_nvcsw: c_long,
pub ru_nivcsw: c_long,
}
#[repr(C)]
pub struct tms {
tms_utime: clock_t,
tms_stime: clock_t,
tms_cutime: clock_t,
tms_cstime: clock_t,
}
pub const FD_SETSIZE: usize = 1024;
#[repr(C)]
pub struct fd_set {
pub fds_bits: [c_ulong; FD_SETSIZE / (8 * mem::size_of::<c_ulong>())],
}
pub const F_OK: c_int = 0;
pub const R_OK: c_int = 4;
pub const W_OK: c_int = 2;
pub const X_OK: c_int = 1;
pub type cc_t = u8;
pub type speed_t = u32;
pub type tcflag_t = u32;
pub const NCCS: usize = 32;
#[repr(C)]
pub struct termios {
c_iflag: tcflag_t,
c_oflag: tcflag_t,
c_cflag: tcflag_t,
c_lflag: tcflag_t,
c_line: cc_t,
c_cc: [cc_t; NCCS],
__c_ispeed: speed_t,
__c_ospeed: speed_t,
}