Add socketpair on Linux with stub on Redox
This commit is contained in:
@@ -220,12 +220,19 @@ pub unsafe extern "C" fn socket(domain: c_int, kind: c_int, protocol: c_int) ->
|
||||
)
|
||||
}
|
||||
|
||||
// #[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,
|
||||
sv: *mut c_int,
|
||||
) -> c_int {
|
||||
trace_expr!(
|
||||
Sys::socketpair(domain, kind, protocol, &mut *(sv as *mut [c_int; 2])),
|
||||
"socketpair({}, {}, {}, {:p})",
|
||||
domain,
|
||||
kind,
|
||||
protocol,
|
||||
sv
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,12 +3,6 @@ use super::super::PalSocket;
|
||||
use super::{e, Sys};
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
|
||||
//impl Sys {
|
||||
// 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
|
||||
@@ -119,4 +113,8 @@ impl PalSocket for Sys {
|
||||
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, sv: &mut [c_int; 2]) -> c_int {
|
||||
e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, sv.as_mut_ptr()) }) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ pub trait PalSocket: Pal {
|
||||
fn shutdown(socket: c_int, how: c_int) -> c_int;
|
||||
|
||||
unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int;
|
||||
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, sv: &mut [c_int; 2]) -> c_int;
|
||||
}
|
||||
|
||||
@@ -248,4 +248,9 @@ impl PalSocket for Sys {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn socketpair(domain: c_int, kind: c_int, protocol: c_int, sv: &mut [c_int; 2]) -> c_int {
|
||||
unsafe { errno = syscall::ENOSYS };
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user