Comment out functions not implemented by Redox

This commit is contained in:
Jeremy Soller
2018-09-15 12:31:40 -06:00
parent f661d5d1c0
commit dfb07e473a
14 changed files with 271 additions and 477 deletions
+30 -36
View File
@@ -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
}
+6 -4
View File
@@ -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
}
}
+52 -50
View File
@@ -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
}
}