diff --git a/src/header/sys_socket/mod.rs b/src/header/sys_socket/mod.rs index 53a27f5163..3a6f187325 100644 --- a/src/header/sys_socket/mod.rs +++ b/src/header/sys_socket/mod.rs @@ -111,10 +111,10 @@ pub unsafe extern "C" fn getsockopt( ) } -// #[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 listen(socket: c_int, backlog: c_int) -> c_int { + Sys::listen(socket, backlog) +} #[no_mangle] pub unsafe extern "C" fn recv( @@ -204,10 +204,10 @@ pub unsafe extern "C" fn setsockopt( ) } -// #[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 { diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 7b764b4ba9..eda8565556 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -321,9 +321,9 @@ pub extern "C" fn getlogin_r(name: *mut c_char, namesize: size_t) -> c_int { unimplemented!(); } -// #[no_mangle] +#[no_mangle] pub extern "C" fn getpagesize() -> c_int { - unimplemented!(); + Sys::getpagesize() } // #[no_mangle] diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 56cb816dc8..0cde29c9ad 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -239,6 +239,10 @@ impl Pal for Sys { e(unsafe { syscall!(GETGID) }) as gid_t } + fn getpagesize() -> c_int { + e(unsafe { syscall!(GETPAGESIZE) }) as c_int + } + fn getpgid(pid: pid_t) -> pid_t { e(unsafe { syscall!(GETPGID, pid) }) as pid_t } diff --git a/src/platform/linux/socket.rs b/src/platform/linux/socket.rs index f38089523d..6c598ab4c0 100644 --- a/src/platform/linux/socket.rs +++ b/src/platform/linux/socket.rs @@ -4,14 +4,6 @@ use super::{e, Sys}; use header::sys_socket::{sockaddr, socklen_t}; impl Sys { - fn listen(socket: c_int, backlog: c_int) -> c_int { - e(unsafe { syscall!(LISTEN, socket, backlog) }) 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 } @@ -65,6 +57,10 @@ impl PalSocket for Sys { }) 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, @@ -116,6 +112,10 @@ impl PalSocket for Sys { }) 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 } diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 262fa9fb2b..b85bf0ed87 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -75,6 +75,8 @@ pub trait Pal { fn getgid() -> gid_t; + fn getpagesize() -> c_int; + fn getpgid(pid: pid_t) -> pid_t; fn getpid() -> pid_t; diff --git a/src/platform/pal/socket.rs b/src/platform/pal/socket.rs index e77945ce9b..1c352d1b2d 100644 --- a/src/platform/pal/socket.rs +++ b/src/platform/pal/socket.rs @@ -29,6 +29,8 @@ pub trait PalSocket: Pal { option_len: *mut socklen_t, ) -> c_int; + fn listen(socket: c_int, backlog: c_int) -> c_int; + unsafe fn recvfrom( socket: c_int, buf: *mut c_void, @@ -55,5 +57,7 @@ pub trait PalSocket: Pal { option_len: socklen_t, ) -> c_int; + fn shutdown(socket: c_int, how: c_int) -> c_int; + unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int; } diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index b8b049f11a..1624000473 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -545,6 +545,10 @@ impl Pal for Sys { e(syscall::getgid()) as gid_t } + fn getpagesize() -> c_int { + 4096 + } + fn getpgid(pid: pid_t) -> pid_t { e(syscall::getpgid(pid as usize)) as pid_t } diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index 95dca51a69..7a1b61031d 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -144,6 +144,11 @@ impl PalSocket for Sys { e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int } + fn listen(socket: c_int, backlog: c_int) -> c_int { + // Redox has no need to listen + 0 + } + unsafe fn recvfrom( socket: c_int, buf: *mut c_void, @@ -206,6 +211,10 @@ impl PalSocket for Sys { e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int } + fn shutdown(socket: c_int, how: c_int) -> c_int { + e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int + } + unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int { if domain != AF_INET { errno = syscall::EAFNOSUPPORT;