Delete duplicate types
Now that we use cbindgen differently :D
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use header::time::sigevent;
|
||||
use header::time::{timespec, sigevent};
|
||||
use platform::types::*;
|
||||
|
||||
pub struct aiocb {
|
||||
|
||||
@@ -4,10 +4,12 @@ use core::str::FromStr;
|
||||
use core::{ptr, slice, str};
|
||||
|
||||
use header::errno::*;
|
||||
use header::netinet_in::in_addr;
|
||||
use platform;
|
||||
use header::netinet_in::{in_addr, in_addr_t};
|
||||
use header::sys_socket::constants::*;
|
||||
use header::sys_socket::socklen_t;
|
||||
use platform::c_str;
|
||||
use platform::types::*;
|
||||
use platform;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn htonl(hostlong: u32) -> u32 {
|
||||
|
||||
@@ -68,7 +68,7 @@ pub unsafe extern "C" fn readdir(dir: *mut DIR) -> *mut dirent {
|
||||
if (*dir).index >= (*dir).len {
|
||||
let read = Sys::getdents(
|
||||
(*dir).fd,
|
||||
(*dir).buf.as_mut_ptr() as *mut platform::types::dirent,
|
||||
(*dir).buf.as_mut_ptr() as *mut dirent,
|
||||
(*dir).buf.len(),
|
||||
);
|
||||
if read <= 0 {
|
||||
|
||||
@@ -21,15 +21,16 @@ use platform::c_str;
|
||||
|
||||
use self::dns::{Dns, DnsQuery};
|
||||
|
||||
use header::arpa_inet::{htons, ntohs, inet_aton};
|
||||
use header::arpa_inet::{htons, inet_aton};
|
||||
use header::errno::*;
|
||||
use header::fcntl::O_RDONLY;
|
||||
use header::netinet_in::{in_addr, IPPROTO_UDP, sockaddr_in};
|
||||
use header::stdlib::atoi;
|
||||
use header::strings::strcasecmp;
|
||||
use header::sys_socket;
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
use header::sys_socket::constants::{SOCK_DGRAM, AF_INET};
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
use header::sys_socket;
|
||||
use header::time::timespec;
|
||||
use header::time;
|
||||
use header::unistd::SEEK_SET;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! pwd implementation for relibc
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::ptr;
|
||||
|
||||
use c_str::CStr;
|
||||
@@ -8,7 +7,7 @@ use header::{errno, fcntl};
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Line, RawFile, RawLineBuffer};
|
||||
use platform::{Pal, Sys};
|
||||
use platform::Sys;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct passwd {
|
||||
|
||||
@@ -23,7 +23,6 @@ pub const SIG_BLOCK: c_int = 0;
|
||||
pub const SIG_UNBLOCK: c_int = 1;
|
||||
pub const SIG_SETMASK: c_int = 2;
|
||||
|
||||
// Need both here and in platform because cbindgen :(
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
pub struct sigaction {
|
||||
@@ -66,11 +65,11 @@ pub unsafe extern "C" fn sigaction(
|
||||
let ptr = if !act.is_null() {
|
||||
_sigaction = Some((*act).clone());
|
||||
_sigaction.as_mut().unwrap().sa_flags |= SA_RESTORER as c_ulong;
|
||||
_sigaction.as_mut().unwrap() as *mut _ as *mut platform::types::sigaction
|
||||
_sigaction.as_mut().unwrap() as *mut _
|
||||
} else {
|
||||
ptr::null_mut()
|
||||
};
|
||||
Sys::sigaction(sig, ptr, oact as *mut platform::types::sigaction)
|
||||
Sys::sigaction(sig, ptr, oact)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -11,6 +11,7 @@ use header::errno::*;
|
||||
use header::fcntl::*;
|
||||
use header::string::*;
|
||||
use header::time::constants::CLOCK_MONOTONIC;
|
||||
use header::time::timespec;
|
||||
use header::wchar::*;
|
||||
use header::{ctype, errno, unistd};
|
||||
use platform;
|
||||
|
||||
@@ -12,19 +12,20 @@ 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,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod inner {
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct winsize {
|
||||
ws_row: c_ushort,
|
||||
ws_col: c_ushort,
|
||||
ws_xpixel: c_ushort,
|
||||
ws_ypixel: c_ushort,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
|
||||
// TODO: Somehow support varargs to syscall??
|
||||
|
||||
@@ -52,7 +52,7 @@ pub unsafe extern "C" fn getrlimit(resource: c_int, rlp: *mut rlimit) -> c_int {
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
|
||||
Sys::getrusage(who, r_usage as *mut platform::types::rusage)
|
||||
Sys::getrusage(who, r_usage)
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
|
||||
@@ -5,3 +5,8 @@ style = "Tag"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
[export]
|
||||
# fd_set is also defined in C because cbindgen is incompatible with mem::size_of booo
|
||||
|
||||
exclude = ["FD_SETSIZE", "fd_set"]
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
//! sys/select.h implementation
|
||||
|
||||
use core::mem;
|
||||
use header::sys_time::timeval;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
// fd_set is defined in C because cbindgen is incompatible with mem::size_of booo
|
||||
// fd_set is also defined in C because cbindgen is incompatible with mem::size_of booo
|
||||
|
||||
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>())],
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn select(
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
use core::ptr;
|
||||
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{PalSocket, Sys};
|
||||
|
||||
pub mod constants;
|
||||
|
||||
pub type in_addr_t = [u8; 4];
|
||||
pub type in_port_t = u16;
|
||||
pub type sa_family_t = u16;
|
||||
pub type socklen_t = u32;
|
||||
|
||||
@@ -17,7 +14,7 @@ pub type socklen_t = u32;
|
||||
#[derive(Default)]
|
||||
pub struct sockaddr {
|
||||
pub sa_family: sa_family_t,
|
||||
data: [c_char; 14],
|
||||
pub data: [c_char; 14],
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -28,7 +25,7 @@ pub unsafe extern "C" fn accept(
|
||||
) -> c_int {
|
||||
Sys::accept(
|
||||
socket,
|
||||
address as *mut platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -41,7 +38,7 @@ pub unsafe extern "C" fn bind(
|
||||
) -> c_int {
|
||||
Sys::bind(
|
||||
socket,
|
||||
address as *const platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -54,7 +51,7 @@ pub unsafe extern "C" fn connect(
|
||||
) -> c_int {
|
||||
Sys::connect(
|
||||
socket,
|
||||
address as *const platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -67,7 +64,7 @@ pub unsafe extern "C" fn getpeername(
|
||||
) -> c_int {
|
||||
Sys::getpeername(
|
||||
socket,
|
||||
address as *mut platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -80,7 +77,7 @@ pub unsafe extern "C" fn getsockname(
|
||||
) -> c_int {
|
||||
Sys::getsockname(
|
||||
socket,
|
||||
address as *mut platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -132,7 +129,7 @@ pub unsafe extern "C" fn recvfrom(
|
||||
buffer,
|
||||
length,
|
||||
flags,
|
||||
address as *mut platform::types::sockaddr,
|
||||
address,
|
||||
address_len,
|
||||
)
|
||||
}
|
||||
@@ -161,7 +158,7 @@ pub unsafe extern "C" fn sendto(
|
||||
message,
|
||||
length,
|
||||
flags,
|
||||
dest_addr as *const platform::types::sockaddr,
|
||||
dest_addr,
|
||||
dest_len,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use c_str::CStr;
|
||||
use header::fcntl::{O_NOFOLLOW, O_PATH};
|
||||
use header::time::timespec;
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
@@ -35,6 +36,7 @@ pub const S_ISGID: c_int = 0o2000;
|
||||
pub const S_ISVTX: c_int = 0o1000;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_ino: ino_t,
|
||||
@@ -69,12 +71,12 @@ pub extern "C" fn fchmod(fildes: c_int, mode: mode_t) -> c_int {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn fstat(fildes: c_int, buf: *mut platform::types::stat) -> c_int {
|
||||
pub extern "C" fn fstat(fildes: c_int, buf: *mut stat) -> c_int {
|
||||
Sys::fstat(fildes, buf)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __fxstat(_ver: c_int, fildes: c_int, buf: *mut platform::types::stat) -> c_int {
|
||||
pub extern "C" fn __fxstat(_ver: c_int, fildes: c_int, buf: *mut stat) -> c_int {
|
||||
fstat(fildes, buf)
|
||||
}
|
||||
|
||||
@@ -84,7 +86,7 @@ pub extern "C" fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn lstat(path: *const c_char, buf: *mut platform::types::stat) -> c_int {
|
||||
pub extern "C" fn lstat(path: *const c_char, buf: *mut stat) -> c_int {
|
||||
let path = unsafe { CStr::from_ptr(path) };
|
||||
let fd = Sys::open(path, O_PATH | O_NOFOLLOW, 0);
|
||||
if fd < 0 {
|
||||
@@ -116,7 +118,7 @@ pub extern "C" fn mknod(path: *const c_char, mode: mode_t, dev: dev_t) -> c_int
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn stat(file: *const c_char, buf: *mut platform::types::stat) -> c_int {
|
||||
pub extern "C" fn stat(file: *const c_char, buf: *mut stat) -> c_int {
|
||||
let file = unsafe { CStr::from_ptr(file) };
|
||||
let fd = Sys::open(file, O_PATH, 0);
|
||||
if fd < 0 {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html
|
||||
|
||||
use c_str::CStr;
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
use header::time::timespec;
|
||||
|
||||
pub const ITIMER_REAL: c_int = 0;
|
||||
pub const ITIMER_VIRTUAL: c_int = 1;
|
||||
@@ -35,7 +35,7 @@ pub struct fd_set {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
|
||||
Sys::getitimer(which, value as *mut platform::types::itimerval)
|
||||
Sys::getitimer(which, value)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -46,16 +46,16 @@ pub extern "C" fn setitimer(
|
||||
) -> c_int {
|
||||
Sys::setitimer(
|
||||
which,
|
||||
value as *const platform::types::itimerval,
|
||||
ovalue as *mut platform::types::itimerval,
|
||||
value,
|
||||
ovalue,
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int {
|
||||
Sys::gettimeofday(
|
||||
tp as *mut platform::types::timeval,
|
||||
tzp as *mut platform::types::timezone,
|
||||
tp,
|
||||
tzp,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ pub struct tms {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn times(out: *mut tms) -> clock_t {
|
||||
Sys::times(out as *mut platform::types::tms)
|
||||
Sys::times(out)
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
//! sys/utsname implementation for linux, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
pub 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],
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod inner {
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
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],
|
||||
}
|
||||
use super::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int {
|
||||
Sys::uname(uts as *mut platform::types::utsname)
|
||||
Sys::uname(uts)
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! termios implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html
|
||||
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
@@ -24,12 +23,12 @@ pub struct termios {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn tcgetattr(fd: c_int, out: *mut termios) -> c_int {
|
||||
Sys::tcgetattr(fd, out as *mut platform::types::termios)
|
||||
Sys::tcgetattr(fd, out)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *mut termios) -> c_int {
|
||||
Sys::tcsetattr(fd, act, value as *mut platform::types::termios)
|
||||
Sys::tcsetattr(fd, act, value)
|
||||
}
|
||||
|
||||
pub const VINTR: usize = 0;
|
||||
|
||||
+15
-4
@@ -15,11 +15,22 @@ mod helpers;
|
||||
mod strftime;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
impl<'a> From<&'a timespec> for syscall::TimeSpec {
|
||||
fn from(tp: ×pec) -> Self {
|
||||
Self {
|
||||
tv_sec: tp.tv_sec,
|
||||
tv_nsec: tp.tv_nsec as i32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct tm {
|
||||
pub tm_sec: c_int,
|
||||
@@ -118,7 +129,7 @@ pub extern "C" fn clock_getres(clock_id: clockid_t, res: *mut timespec) -> c_int
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int {
|
||||
Sys::clock_gettime(clock_id, tp as *mut platform::types::timespec)
|
||||
Sys::clock_gettime(clock_id, tp)
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
@@ -326,8 +337,8 @@ pub unsafe extern "C" fn mktime(t: *mut tm) -> time_t {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
|
||||
Sys::nanosleep(
|
||||
rqtp as *const platform::types::timespec,
|
||||
rmtp as *mut platform::types::timespec,
|
||||
rqtp,
|
||||
rmtp,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -357,7 +368,7 @@ pub extern "C" fn strptime(buf: *const c_char, format: *const c_char, tm: *mut t
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn time(tloc: *mut time_t) -> time_t {
|
||||
let mut ts: platform::types::timespec = Default::default();
|
||||
let mut ts = timespec::default();
|
||||
Sys::clock_gettime(CLOCK_REALTIME, &mut ts);
|
||||
unsafe {
|
||||
if !tloc.is_null() {
|
||||
|
||||
@@ -7,6 +7,7 @@ use header::sys_time;
|
||||
use platform;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
use header::time::timespec;
|
||||
|
||||
pub use self::brk::*;
|
||||
pub use self::getopt::*;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! utime implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/utime.h.html
|
||||
|
||||
use c_str::CStr;
|
||||
use header::time::timespec;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user