Comment out functions not implemented by Redox
This commit is contained in:
+3
-3
@@ -24,13 +24,13 @@ pub mod string;
|
||||
pub mod strings;
|
||||
pub mod sys_file;
|
||||
pub mod sys_ioctl;
|
||||
pub mod sys_mman;
|
||||
pub mod sys_resource;
|
||||
//pub mod sys_mman;
|
||||
//pub mod sys_resource;
|
||||
pub mod sys_select;
|
||||
pub mod sys_socket;
|
||||
pub mod sys_stat;
|
||||
pub mod sys_time;
|
||||
pub mod sys_times;
|
||||
//pub mod sys_times;
|
||||
pub mod sys_un;
|
||||
pub mod sys_utsname;
|
||||
pub mod sys_wait;
|
||||
|
||||
@@ -174,10 +174,10 @@ pub extern "C" fn sigpending(set: *mut sigset_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
|
||||
Sys::sigprocmask(how, set, oset)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
|
||||
// Sys::sigprocmask(how, set, oset)
|
||||
// }
|
||||
|
||||
// #[no_mangle]
|
||||
pub extern "C" fn sigrelse(sig: c_int) -> c_int {
|
||||
|
||||
@@ -62,21 +62,21 @@ pub unsafe extern "C" fn getsockname(
|
||||
Sys::getsockname(socket, address, address_len)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *mut c_void,
|
||||
option_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
Sys::getsockopt(socket, level, option_name, option_value, option_len)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn listen(socket: c_int, backlog: c_int) -> c_int {
|
||||
Sys::listen(socket, backlog)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn getsockopt(
|
||||
// socket: c_int,
|
||||
// level: c_int,
|
||||
// option_name: c_int,
|
||||
// option_value: *mut c_void,
|
||||
// option_len: *mut socklen_t,
|
||||
// ) -> c_int {
|
||||
// Sys::getsockopt(socket, level, option_name, option_value, option_len)
|
||||
// }
|
||||
//
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn listen(socket: c_int, backlog: c_int) -> c_int {
|
||||
// Sys::listen(socket, backlog)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn recv(
|
||||
@@ -129,33 +129,33 @@ pub unsafe extern "C" fn sendto(
|
||||
Sys::sendto(socket, message, length, flags, dest_addr, dest_len)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn setsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *const c_void,
|
||||
option_len: socklen_t,
|
||||
) -> c_int {
|
||||
Sys::setsockopt(socket, level, option_name, option_value, option_len)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn setsockopt(
|
||||
// socket: c_int,
|
||||
// level: c_int,
|
||||
// option_name: c_int,
|
||||
// option_value: *const c_void,
|
||||
// option_len: socklen_t,
|
||||
// ) -> c_int {
|
||||
// Sys::setsockopt(socket, level, option_name, option_value, option_len)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn shutdown(socket: c_int, how: c_int) -> c_int {
|
||||
Sys::shutdown(socket, how)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn shutdown(socket: c_int, how: c_int) -> c_int {
|
||||
// Sys::shutdown(socket, how)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
|
||||
Sys::socket(domain, kind, protocol)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn socketpair(
|
||||
domain: c_int,
|
||||
kind: c_int,
|
||||
protocol: c_int,
|
||||
socket_vector: *mut c_int,
|
||||
) -> c_int {
|
||||
Sys::socketpair(domain, kind, protocol, socket_vector)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn socketpair(
|
||||
// domain: c_int,
|
||||
// kind: c_int,
|
||||
// protocol: c_int,
|
||||
// socket_vector: *mut c_int,
|
||||
// ) -> c_int {
|
||||
// Sys::socketpair(domain, kind, protocol, socket_vector)
|
||||
// }
|
||||
|
||||
@@ -132,7 +132,7 @@ pub extern "C" fn stat(file: *const c_char, buf: *mut stat) -> c_int {
|
||||
res
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn umask(mask: mode_t) -> mode_t {
|
||||
Sys::umask(mask)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn umask(mask: mode_t) -> mode_t {
|
||||
// Sys::umask(mask)
|
||||
// }
|
||||
|
||||
+12
-12
@@ -33,19 +33,19 @@ pub struct fd_set {
|
||||
pub fds_bits: [c_long; 16usize],
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
|
||||
Sys::getitimer(which, value)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
|
||||
// Sys::getitimer(which, value)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn setitimer(
|
||||
which: c_int,
|
||||
value: *const itimerval,
|
||||
ovalue: *mut itimerval,
|
||||
) -> c_int {
|
||||
Sys::setitimer(which, value, ovalue)
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn setitimer(
|
||||
// which: c_int,
|
||||
// value: *const itimerval,
|
||||
// ovalue: *mut itimerval,
|
||||
// ) -> c_int {
|
||||
// Sys::setitimer(which, value, ovalue)
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! sys/wait.h implementation for Redox, following
|
||||
//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/syswait.h.html
|
||||
|
||||
use header::sys_resource::rusage;
|
||||
//use header::sys_resource::rusage;
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
@@ -24,13 +24,13 @@ pub unsafe extern "C" fn wait(stat_loc: *mut c_int) -> pid_t {
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
pub unsafe extern "C" fn wait3(
|
||||
stat_loc: *mut c_int,
|
||||
options: c_int,
|
||||
resource_usage: *mut rusage,
|
||||
) -> pid_t {
|
||||
unimplemented!();
|
||||
}
|
||||
// pub unsafe extern "C" fn wait3(
|
||||
// stat_loc: *mut c_int,
|
||||
// options: c_int,
|
||||
// resource_usage: *mut rusage,
|
||||
// ) -> pid_t {
|
||||
// unimplemented!();
|
||||
// }
|
||||
|
||||
/*
|
||||
* TODO: implement idtype_t, id_t, and siginfo_t
|
||||
|
||||
+43
-42
@@ -50,24 +50,25 @@ pub extern "C" fn access(path: *const c_char, mode: c_int) -> c_int {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn alarm(seconds: c_uint) -> c_uint {
|
||||
let mut timer = sys_time::itimerval {
|
||||
it_value: sys_time::timeval {
|
||||
tv_sec: seconds as time_t,
|
||||
tv_usec: 0,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
let errno_backup = unsafe { platform::errno };
|
||||
let secs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
|
||||
0
|
||||
} else {
|
||||
timer.it_value.tv_sec as c_uint + if timer.it_value.tv_usec > 0 { 1 } else { 0 }
|
||||
};
|
||||
unsafe {
|
||||
platform::errno = errno_backup;
|
||||
}
|
||||
|
||||
secs
|
||||
// let mut timer = sys_time::itimerval {
|
||||
// it_value: sys_time::timeval {
|
||||
// tv_sec: seconds as time_t,
|
||||
// tv_usec: 0,
|
||||
// },
|
||||
// ..Default::default()
|
||||
// };
|
||||
// let errno_backup = unsafe { platform::errno };
|
||||
// let secs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
|
||||
// 0
|
||||
// } else {
|
||||
// timer.it_value.tv_sec as c_uint + if timer.it_value.tv_usec > 0 { 1 } else { 0 }
|
||||
// };
|
||||
// unsafe {
|
||||
// platform::errno = errno_backup;
|
||||
// }
|
||||
//
|
||||
// secs
|
||||
0
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -482,30 +483,30 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t)
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ualarm(value: useconds_t, interval: useconds_t) -> useconds_t {
|
||||
let mut timer = sys_time::itimerval {
|
||||
it_value: sys_time::timeval {
|
||||
tv_sec: 0,
|
||||
tv_usec: value as suseconds_t,
|
||||
},
|
||||
it_interval: sys_time::timeval {
|
||||
tv_sec: 0,
|
||||
tv_usec: interval as suseconds_t,
|
||||
},
|
||||
};
|
||||
let errno_backup = unsafe { platform::errno };
|
||||
let usecs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
|
||||
0
|
||||
} else {
|
||||
timer.it_value.tv_sec as useconds_t * 1_000_000 + timer.it_value.tv_usec as useconds_t
|
||||
};
|
||||
unsafe {
|
||||
platform::errno = errno_backup;
|
||||
}
|
||||
|
||||
usecs
|
||||
}
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn ualarm(value: useconds_t, interval: useconds_t) -> useconds_t {
|
||||
// let mut timer = sys_time::itimerval {
|
||||
// it_value: sys_time::timeval {
|
||||
// tv_sec: 0,
|
||||
// tv_usec: value as suseconds_t,
|
||||
// },
|
||||
// it_interval: sys_time::timeval {
|
||||
// tv_sec: 0,
|
||||
// tv_usec: interval as suseconds_t,
|
||||
// },
|
||||
// };
|
||||
// let errno_backup = unsafe { platform::errno };
|
||||
// let usecs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
|
||||
// 0
|
||||
// } else {
|
||||
// timer.it_value.tv_sec as useconds_t * 1_000_000 + timer.it_value.tv_usec as useconds_t
|
||||
// };
|
||||
// unsafe {
|
||||
// platform::errno = errno_backup;
|
||||
// }
|
||||
//
|
||||
// usecs
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn unlink(path: *const c_char) -> c_int {
|
||||
|
||||
+30
-36
@@ -37,15 +37,38 @@ fn e(sys: usize) -> usize {
|
||||
|
||||
pub struct Sys;
|
||||
|
||||
impl Pal for Sys {
|
||||
fn no_pal(name: &str) -> c_int {
|
||||
let _ = writeln!(FileWriter(2), "relibc: no_pal: {}", name);
|
||||
unsafe {
|
||||
errno = ENOSYS;
|
||||
}
|
||||
-1
|
||||
impl Sys {
|
||||
fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
|
||||
e(unsafe { syscall!(GETITIMER, which, out) }) as c_int
|
||||
}
|
||||
|
||||
fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
|
||||
e(unsafe { syscall!(GETRUSAGE, who, r_usage) }) as c_int
|
||||
}
|
||||
|
||||
fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
|
||||
// TODO: Somehow support varargs to syscall??
|
||||
e(unsafe { syscall!(IOCTL, fd, request, out) }) as c_int
|
||||
}
|
||||
|
||||
fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
|
||||
e(unsafe { syscall!(SETITIMER, which, new, old) }) as c_int
|
||||
}
|
||||
|
||||
fn times(out: *mut tms) -> clock_t {
|
||||
unsafe { syscall!(TIMES, out) as clock_t }
|
||||
}
|
||||
|
||||
fn umask(mask: mode_t) -> mode_t {
|
||||
unsafe { syscall!(UMASK, mask) as mode_t }
|
||||
}
|
||||
|
||||
fn uname(utsname: *mut utsname) -> c_int {
|
||||
e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
impl Pal for Sys {
|
||||
fn access(path: &CStr, mode: c_int) -> c_int {
|
||||
e(unsafe { syscall!(ACCESS, path.as_ptr(), mode) }) as c_int
|
||||
}
|
||||
@@ -170,10 +193,6 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(GETGID) }) as gid_t
|
||||
}
|
||||
|
||||
fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
|
||||
e(unsafe { syscall!(GETRUSAGE, who, r_usage) }) as c_int
|
||||
}
|
||||
|
||||
unsafe fn gethostname(mut name: *mut c_char, len: size_t) -> c_int {
|
||||
// len only needs to be mutable on linux
|
||||
let mut len = len;
|
||||
@@ -202,10 +221,6 @@ impl Pal for Sys {
|
||||
0
|
||||
}
|
||||
|
||||
fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
|
||||
e(unsafe { syscall!(GETITIMER, which, out) }) as c_int
|
||||
}
|
||||
|
||||
fn getpgid(pid: pid_t) -> pid_t {
|
||||
e(unsafe { syscall!(GETPGID, pid) }) as pid_t
|
||||
}
|
||||
@@ -226,11 +241,6 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(GETUID) }) as uid_t
|
||||
}
|
||||
|
||||
fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
|
||||
// TODO: Somehow support varargs to syscall??
|
||||
e(unsafe { syscall!(IOCTL, fd, request, out) }) as c_int
|
||||
}
|
||||
|
||||
fn isatty(fd: c_int) -> c_int {
|
||||
let mut winsize = winsize::default();
|
||||
(Self::ioctl(fd, TIOCGWINSZ, &mut winsize as *mut _ as *mut c_void) == 0) as c_int
|
||||
@@ -310,10 +320,6 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(SELECT, nfds, readfds, writefds, exceptfds, timeout) }) as c_int
|
||||
}
|
||||
|
||||
fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
|
||||
e(unsafe { syscall!(SETITIMER, which, new, old) }) as c_int
|
||||
}
|
||||
|
||||
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
|
||||
e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
|
||||
}
|
||||
@@ -341,18 +347,6 @@ impl Pal for Sys {
|
||||
Self::ioctl(fd, TCSETS + act as c_ulong, value as *mut c_void)
|
||||
}
|
||||
|
||||
fn times(out: *mut tms) -> clock_t {
|
||||
unsafe { syscall!(TIMES, out) as clock_t }
|
||||
}
|
||||
|
||||
fn umask(mask: mode_t) -> mode_t {
|
||||
unsafe { syscall!(UMASK, mask) as mode_t }
|
||||
}
|
||||
|
||||
fn uname(utsname: *mut utsname) -> c_int {
|
||||
e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
|
||||
}
|
||||
|
||||
fn unlink(path: &CStr) -> c_int {
|
||||
e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path.as_ptr(), 0) }) as c_int
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ use super::super::PalSignal;
|
||||
use super::{e, Sys};
|
||||
use header::signal::{sigaction, sigset_t};
|
||||
|
||||
impl Sys {
|
||||
fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
|
||||
e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
impl PalSignal for Sys {
|
||||
fn kill(pid: pid_t, sig: c_int) -> c_int {
|
||||
e(unsafe { syscall!(KILL, pid, sig) }) as c_int
|
||||
@@ -34,8 +40,4 @@ impl PalSignal for Sys {
|
||||
mem::size_of::<sigset_t>()
|
||||
)) as c_int
|
||||
}
|
||||
|
||||
fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
|
||||
e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,58 @@ use super::super::PalSocket;
|
||||
use super::{e, Sys};
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
|
||||
impl Sys {
|
||||
fn getsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *mut c_void,
|
||||
option_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
e(unsafe {
|
||||
syscall!(
|
||||
GETSOCKOPT,
|
||||
socket,
|
||||
level,
|
||||
option_name,
|
||||
option_value,
|
||||
option_len
|
||||
)
|
||||
}) as c_int
|
||||
}
|
||||
|
||||
fn listen(socket: c_int, backlog: c_int) -> c_int {
|
||||
e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int
|
||||
}
|
||||
|
||||
fn setsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *const c_void,
|
||||
option_len: socklen_t,
|
||||
) -> c_int {
|
||||
e(unsafe {
|
||||
syscall!(
|
||||
SETSOCKOPT,
|
||||
socket,
|
||||
level,
|
||||
option_name,
|
||||
option_value,
|
||||
option_len
|
||||
)
|
||||
}) as c_int
|
||||
}
|
||||
|
||||
fn shutdown(socket: c_int, how: c_int) -> c_int {
|
||||
e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int
|
||||
}
|
||||
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int {
|
||||
e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
impl PalSocket for Sys {
|
||||
unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int {
|
||||
e(syscall!(ACCEPT, socket, address, address_len)) as c_int
|
||||
@@ -32,29 +84,6 @@ impl PalSocket for Sys {
|
||||
e(syscall!(GETSOCKNAME, socket, address, address_len)) as c_int
|
||||
}
|
||||
|
||||
fn getsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *mut c_void,
|
||||
option_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
e(unsafe {
|
||||
syscall!(
|
||||
GETSOCKOPT,
|
||||
socket,
|
||||
level,
|
||||
option_name,
|
||||
option_value,
|
||||
option_len
|
||||
)
|
||||
}) as c_int
|
||||
}
|
||||
|
||||
fn listen(socket: c_int, backlog: c_int) -> c_int {
|
||||
e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int
|
||||
}
|
||||
|
||||
unsafe fn recvfrom(
|
||||
socket: c_int,
|
||||
buf: *mut c_void,
|
||||
@@ -87,34 +116,7 @@ impl PalSocket for Sys {
|
||||
)) as ssize_t
|
||||
}
|
||||
|
||||
fn setsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *const c_void,
|
||||
option_len: socklen_t,
|
||||
) -> c_int {
|
||||
e(unsafe {
|
||||
syscall!(
|
||||
SETSOCKOPT,
|
||||
socket,
|
||||
level,
|
||||
option_name,
|
||||
option_value,
|
||||
option_len
|
||||
)
|
||||
}) as c_int
|
||||
}
|
||||
|
||||
fn shutdown(socket: c_int, how: c_int) -> c_int {
|
||||
e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int
|
||||
}
|
||||
|
||||
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
|
||||
e(syscall!(SOCKET, domain, kind, protocol)) as c_int
|
||||
}
|
||||
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int {
|
||||
e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, socket_vector) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
+55
-193
@@ -3,11 +3,11 @@ use core::ptr;
|
||||
use super::types::*;
|
||||
use c_str::CStr;
|
||||
use header::dirent::dirent;
|
||||
use header::sys_resource::rusage;
|
||||
//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_times::tms;
|
||||
use header::sys_utsname::utsname;
|
||||
use header::termios::termios;
|
||||
use header::time::timespec;
|
||||
@@ -19,168 +19,81 @@ pub use self::socket::PalSocket;
|
||||
mod socket;
|
||||
|
||||
pub trait Pal {
|
||||
fn no_pal(name: &str) -> c_int;
|
||||
|
||||
fn access(path: &CStr, mode: c_int) -> c_int {
|
||||
Self::no_pal("access")
|
||||
}
|
||||
fn access(path: &CStr, mode: c_int) -> c_int;
|
||||
|
||||
fn brk(addr: *mut c_void) -> *mut c_void;
|
||||
|
||||
fn chdir(path: &CStr) -> c_int {
|
||||
Self::no_pal("chdir")
|
||||
}
|
||||
fn chdir(path: &CStr) -> c_int;
|
||||
|
||||
fn chmod(path: &CStr, mode: mode_t) -> c_int {
|
||||
Self::no_pal("chmod")
|
||||
}
|
||||
fn chmod(path: &CStr, mode: mode_t) -> c_int;
|
||||
|
||||
fn chown(path: &CStr, owner: uid_t, group: gid_t) -> c_int {
|
||||
Self::no_pal("chown")
|
||||
}
|
||||
fn chown(path: &CStr, owner: uid_t, group: gid_t) -> c_int;
|
||||
|
||||
fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int {
|
||||
Self::no_pal("clock_gettime")
|
||||
}
|
||||
fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int;
|
||||
|
||||
fn close(fildes: c_int) -> c_int {
|
||||
Self::no_pal("close")
|
||||
}
|
||||
fn close(fildes: c_int) -> c_int;
|
||||
|
||||
fn dup(fildes: c_int) -> c_int {
|
||||
Self::no_pal("dup")
|
||||
}
|
||||
fn dup(fildes: c_int) -> c_int;
|
||||
|
||||
fn dup2(fildes: c_int, fildes2: c_int) -> c_int {
|
||||
Self::no_pal("dup2")
|
||||
}
|
||||
fn dup2(fildes: c_int, fildes2: c_int) -> c_int;
|
||||
|
||||
unsafe fn execve(path: &CStr, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int {
|
||||
Self::no_pal("execve")
|
||||
}
|
||||
unsafe fn execve(path: &CStr, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int;
|
||||
|
||||
fn exit(status: c_int) -> !;
|
||||
|
||||
fn fchdir(fildes: c_int) -> c_int {
|
||||
Self::no_pal("fchdir")
|
||||
}
|
||||
fn fchdir(fildes: c_int) -> c_int;
|
||||
|
||||
fn fchmod(fildes: c_int, mode: mode_t) -> c_int {
|
||||
Self::no_pal("fchmod")
|
||||
}
|
||||
fn fchmod(fildes: c_int, mode: mode_t) -> c_int;
|
||||
|
||||
fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int {
|
||||
Self::no_pal("fchown")
|
||||
}
|
||||
fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int;
|
||||
|
||||
fn flock(fd: c_int, operation: c_int) -> c_int {
|
||||
Self::no_pal("flock")
|
||||
}
|
||||
fn flock(fd: c_int, operation: c_int) -> c_int;
|
||||
|
||||
fn fstat(fildes: c_int, buf: *mut stat) -> c_int {
|
||||
Self::no_pal("fstat")
|
||||
}
|
||||
fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
|
||||
|
||||
fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
|
||||
Self::no_pal("fcntl")
|
||||
}
|
||||
fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int;
|
||||
|
||||
fn fork() -> pid_t {
|
||||
Self::no_pal("fork")
|
||||
}
|
||||
fn fork() -> pid_t;
|
||||
|
||||
fn fsync(fildes: c_int) -> c_int {
|
||||
Self::no_pal("fsync")
|
||||
}
|
||||
fn fsync(fildes: c_int) -> c_int;
|
||||
|
||||
fn ftruncate(fildes: c_int, length: off_t) -> c_int {
|
||||
Self::no_pal("ftruncate")
|
||||
}
|
||||
fn ftruncate(fildes: c_int, length: off_t) -> c_int;
|
||||
|
||||
fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
Self::no_pal("futimens")
|
||||
}
|
||||
fn futimens(fd: c_int, times: *const timespec) -> c_int;
|
||||
|
||||
fn utimens(path: &CStr, times: *const timespec) -> c_int {
|
||||
Self::no_pal("utimens")
|
||||
}
|
||||
fn utimens(path: &CStr, times: *const timespec) -> c_int;
|
||||
|
||||
fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
|
||||
Self::no_pal("getcwd");
|
||||
ptr::null_mut()
|
||||
}
|
||||
fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
|
||||
|
||||
fn getdents(fd: c_int, dirents: *mut dirent, bytes: usize) -> c_int {
|
||||
Self::no_pal("getdents")
|
||||
}
|
||||
fn getdents(fd: c_int, dirents: *mut dirent, bytes: usize) -> c_int;
|
||||
|
||||
fn getegid() -> gid_t {
|
||||
Self::no_pal("getegid")
|
||||
}
|
||||
fn getegid() -> gid_t;
|
||||
|
||||
fn geteuid() -> uid_t {
|
||||
Self::no_pal("geteuid")
|
||||
}
|
||||
fn geteuid() -> uid_t;
|
||||
|
||||
fn getgid() -> gid_t {
|
||||
Self::no_pal("getgid")
|
||||
}
|
||||
fn getgid() -> gid_t;
|
||||
|
||||
fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
|
||||
Self::no_pal("getrusage")
|
||||
}
|
||||
unsafe fn gethostname(name: *mut c_char, len: size_t) -> c_int;
|
||||
|
||||
unsafe fn gethostname(name: *mut c_char, len: size_t) -> c_int {
|
||||
Self::no_pal("gethostname")
|
||||
}
|
||||
fn getpgid(pid: pid_t) -> pid_t;
|
||||
|
||||
fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
|
||||
Self::no_pal("getitimer")
|
||||
}
|
||||
fn getpid() -> pid_t;
|
||||
|
||||
fn getpgid(pid: pid_t) -> pid_t {
|
||||
Self::no_pal("getpgid")
|
||||
}
|
||||
fn getppid() -> pid_t;
|
||||
|
||||
fn getpid() -> pid_t {
|
||||
Self::no_pal("getpid")
|
||||
}
|
||||
fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int;
|
||||
|
||||
fn getppid() -> pid_t {
|
||||
Self::no_pal("getppid")
|
||||
}
|
||||
fn getuid() -> uid_t;
|
||||
|
||||
fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int {
|
||||
Self::no_pal("gettimeofday")
|
||||
}
|
||||
fn isatty(fd: c_int) -> c_int;
|
||||
|
||||
fn getuid() -> uid_t {
|
||||
Self::no_pal("getuid")
|
||||
}
|
||||
fn link(path1: &CStr, path2: &CStr) -> c_int;
|
||||
|
||||
fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
|
||||
Self::no_pal("ioctl")
|
||||
}
|
||||
fn lseek(fildes: c_int, offset: off_t, whence: c_int) -> off_t;
|
||||
|
||||
fn isatty(fd: c_int) -> c_int {
|
||||
Self::no_pal("isatty")
|
||||
}
|
||||
fn mkdir(path: &CStr, mode: mode_t) -> c_int;
|
||||
|
||||
fn link(path1: &CStr, path2: &CStr) -> c_int {
|
||||
Self::no_pal("link")
|
||||
}
|
||||
|
||||
fn lseek(fildes: c_int, offset: off_t, whence: c_int) -> off_t {
|
||||
Self::no_pal("lseek") as off_t
|
||||
}
|
||||
|
||||
fn mkdir(path: &CStr, mode: mode_t) -> c_int {
|
||||
Self::no_pal("mkdir")
|
||||
}
|
||||
|
||||
fn mkfifo(path: &CStr, mode: mode_t) -> c_int {
|
||||
Self::no_pal("mkfifo")
|
||||
}
|
||||
fn mkfifo(path: &CStr, mode: mode_t) -> c_int;
|
||||
|
||||
unsafe fn mmap(
|
||||
addr: *mut c_void,
|
||||
@@ -189,37 +102,21 @@ pub trait Pal {
|
||||
flags: c_int,
|
||||
fildes: c_int,
|
||||
off: off_t,
|
||||
) -> *mut c_void {
|
||||
Self::no_pal("mmap") as *mut c_void
|
||||
}
|
||||
) -> *mut c_void;
|
||||
|
||||
unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int {
|
||||
Self::no_pal("munmap")
|
||||
}
|
||||
unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int;
|
||||
|
||||
fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
|
||||
Self::no_pal("nanosleep")
|
||||
}
|
||||
fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int;
|
||||
|
||||
fn open(path: &CStr, oflag: c_int, mode: mode_t) -> c_int {
|
||||
Self::no_pal("open")
|
||||
}
|
||||
fn open(path: &CStr, oflag: c_int, mode: mode_t) -> c_int;
|
||||
|
||||
fn pipe(fildes: &mut [c_int]) -> c_int {
|
||||
Self::no_pal("pipe")
|
||||
}
|
||||
fn pipe(fildes: &mut [c_int]) -> c_int;
|
||||
|
||||
fn read(fildes: c_int, buf: &mut [u8]) -> ssize_t {
|
||||
Self::no_pal("read") as ssize_t
|
||||
}
|
||||
fn read(fildes: c_int, buf: &mut [u8]) -> ssize_t;
|
||||
|
||||
fn rename(old: &CStr, new: &CStr) -> c_int {
|
||||
Self::no_pal("rename")
|
||||
}
|
||||
fn rename(old: &CStr, new: &CStr) -> c_int;
|
||||
|
||||
fn rmdir(path: &CStr) -> c_int {
|
||||
Self::no_pal("rmdir")
|
||||
}
|
||||
fn rmdir(path: &CStr) -> c_int;
|
||||
|
||||
fn select(
|
||||
nfds: c_int,
|
||||
@@ -227,56 +124,21 @@ pub trait Pal {
|
||||
writefds: *mut fd_set,
|
||||
exceptfds: *mut fd_set,
|
||||
timeout: *mut timeval,
|
||||
) -> c_int {
|
||||
Self::no_pal("select")
|
||||
}
|
||||
) -> c_int;
|
||||
|
||||
fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
|
||||
Self::no_pal("setitimer")
|
||||
}
|
||||
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
|
||||
|
||||
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
|
||||
Self::no_pal("setpgid")
|
||||
}
|
||||
fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
|
||||
|
||||
fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
|
||||
Self::no_pal("setregid")
|
||||
}
|
||||
fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
|
||||
|
||||
fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
|
||||
Self::no_pal("setreuid")
|
||||
}
|
||||
fn tcgetattr(fd: c_int, out: *mut termios) -> c_int;
|
||||
|
||||
fn tcgetattr(fd: c_int, out: *mut termios) -> c_int {
|
||||
Self::no_pal("tcgetattr")
|
||||
}
|
||||
fn tcsetattr(fd: c_int, act: c_int, value: *const termios) -> c_int;
|
||||
|
||||
fn tcsetattr(fd: c_int, act: c_int, value: *const termios) -> c_int {
|
||||
Self::no_pal("tcsetattr")
|
||||
}
|
||||
fn unlink(path: &CStr) -> c_int;
|
||||
|
||||
fn times(out: *mut tms) -> clock_t {
|
||||
Self::no_pal("times") as clock_t
|
||||
}
|
||||
fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t;
|
||||
|
||||
fn umask(mask: mode_t) -> mode_t {
|
||||
Self::no_pal("umask");
|
||||
0
|
||||
}
|
||||
|
||||
fn uname(utsname: *mut utsname) -> c_int {
|
||||
Self::no_pal("uname")
|
||||
}
|
||||
|
||||
fn unlink(path: &CStr) -> c_int {
|
||||
Self::no_pal("unlink")
|
||||
}
|
||||
|
||||
fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
|
||||
Self::no_pal("waitpid")
|
||||
}
|
||||
|
||||
fn write(fildes: c_int, buf: &[u8]) -> ssize_t {
|
||||
Self::no_pal("write") as ssize_t
|
||||
}
|
||||
fn write(fildes: c_int, buf: &[u8]) -> ssize_t;
|
||||
}
|
||||
|
||||
@@ -3,23 +3,11 @@ use super::super::Pal;
|
||||
use header::signal::{sigaction, sigset_t};
|
||||
|
||||
pub trait PalSignal: Pal {
|
||||
fn kill(pid: pid_t, sig: c_int) -> c_int {
|
||||
Self::no_pal("kill")
|
||||
}
|
||||
fn kill(pid: pid_t, sig: c_int) -> c_int;
|
||||
|
||||
fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
|
||||
Self::no_pal("killpg")
|
||||
}
|
||||
fn killpg(pgrp: pid_t, sig: c_int) -> c_int;
|
||||
|
||||
fn raise(sig: c_int) -> c_int {
|
||||
Self::no_pal("raise")
|
||||
}
|
||||
fn raise(sig: c_int) -> c_int;
|
||||
|
||||
unsafe fn sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int {
|
||||
Self::no_pal("sigaction")
|
||||
}
|
||||
|
||||
fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
|
||||
Self::no_pal("sigprocmask")
|
||||
}
|
||||
unsafe fn sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int;
|
||||
}
|
||||
|
||||
@@ -3,47 +3,23 @@ use super::super::Pal;
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
|
||||
pub trait PalSocket: Pal {
|
||||
unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int {
|
||||
Self::no_pal("accept")
|
||||
}
|
||||
unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int;
|
||||
|
||||
unsafe fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int {
|
||||
Self::no_pal("bind")
|
||||
}
|
||||
unsafe fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int;
|
||||
|
||||
unsafe fn connect(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int {
|
||||
Self::no_pal("connect")
|
||||
}
|
||||
unsafe fn connect(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int;
|
||||
|
||||
unsafe fn getpeername(
|
||||
socket: c_int,
|
||||
address: *mut sockaddr,
|
||||
address_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
Self::no_pal("getpeername")
|
||||
}
|
||||
) -> c_int;
|
||||
|
||||
unsafe fn getsockname(
|
||||
socket: c_int,
|
||||
address: *mut sockaddr,
|
||||
address_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
Self::no_pal("getsockname")
|
||||
}
|
||||
|
||||
fn getsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *mut c_void,
|
||||
option_len: *mut socklen_t,
|
||||
) -> c_int {
|
||||
Self::no_pal("getsockopt")
|
||||
}
|
||||
|
||||
fn listen(socket: c_int, backlog: c_int) -> c_int {
|
||||
Self::no_pal("listen")
|
||||
}
|
||||
) -> c_int;
|
||||
|
||||
unsafe fn recvfrom(
|
||||
socket: c_int,
|
||||
@@ -52,9 +28,7 @@ pub trait PalSocket: Pal {
|
||||
flags: c_int,
|
||||
address: *mut sockaddr,
|
||||
address_len: *mut socklen_t,
|
||||
) -> ssize_t {
|
||||
Self::no_pal("recvfrom") as ssize_t
|
||||
}
|
||||
) -> ssize_t;
|
||||
|
||||
unsafe fn sendto(
|
||||
socket: c_int,
|
||||
@@ -63,29 +37,7 @@ pub trait PalSocket: Pal {
|
||||
flags: c_int,
|
||||
dest_addr: *const sockaddr,
|
||||
dest_len: socklen_t,
|
||||
) -> ssize_t {
|
||||
Self::no_pal("sendto") as ssize_t
|
||||
}
|
||||
) -> ssize_t;
|
||||
|
||||
fn setsockopt(
|
||||
socket: c_int,
|
||||
level: c_int,
|
||||
option_name: c_int,
|
||||
option_value: *const c_void,
|
||||
option_len: socklen_t,
|
||||
) -> c_int {
|
||||
Self::no_pal("setsockopt")
|
||||
}
|
||||
|
||||
fn shutdown(socket: c_int, how: c_int) -> c_int {
|
||||
Self::no_pal("shutdown")
|
||||
}
|
||||
|
||||
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
|
||||
Self::no_pal("socket")
|
||||
}
|
||||
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, socket_vector: *mut c_int) -> c_int {
|
||||
Self::no_pal("socketpair")
|
||||
}
|
||||
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@ 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;
|
||||
const MAP_ANON: c_int = 1;
|
||||
//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_times::tms;
|
||||
use header::sys_utsname::utsname;
|
||||
use header::termios::termios;
|
||||
use header::time::timespec;
|
||||
@@ -52,14 +53,6 @@ fn e(sys: Result<usize>) -> usize {
|
||||
pub struct Sys;
|
||||
|
||||
impl Pal for Sys {
|
||||
fn no_pal(name: &str) -> c_int {
|
||||
let _ = writeln!(FileWriter(2), "relibc: no_pal: {}", name);
|
||||
unsafe {
|
||||
errno = ENOSYS;
|
||||
}
|
||||
-1
|
||||
}
|
||||
|
||||
fn access(path: &CStr, mode: c_int) -> c_int {
|
||||
let fd = match RawFile::open(path, 0, 0) {
|
||||
Ok(fd) => fd,
|
||||
|
||||
Reference in New Issue
Block a user