Skip to content

Commit

Permalink
Fixed all feature for vita
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Sep 12, 2023
1 parent 0db00f4 commit 1793c95
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
22 changes: 16 additions & 6 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ impl Socket {
/// This function sets the same flags as in done for [`Socket::new`],
/// [`Socket::pair_raw`] can be used if you don't want to set those flags.
#[doc = man_links!(unix: socketpair(2))]
#[cfg(all(feature = "all", unix))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
#[cfg(all(feature = "all", unix, not(target_os = "vita")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix, not(target_os = "vita")))))]
pub fn pair(
domain: Domain,
ty: Type,
Expand All @@ -166,8 +166,8 @@ impl Socket {
/// Creates a pair of sockets which are connected to each other.
///
/// This function corresponds to `socketpair(2)`.
#[cfg(all(feature = "all", unix))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
#[cfg(all(feature = "all", unix, not(target_os = "vita")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix, not(target_os = "vita")))))]
pub fn pair_raw(
domain: Domain,
ty: Type,
Expand Down Expand Up @@ -1826,13 +1826,23 @@ impl Socket {
/// supported Unix operating systems.
#[cfg(all(
feature = "all",
not(any(windows, target_os = "haiku", target_os = "openbsd"))
not(any(
windows,
target_os = "haiku",
target_os = "openbsd",
target_os = "vita"
))
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
feature = "all",
not(any(windows, target_os = "haiku", target_os = "openbsd"))
not(any(
windows,
target_os = "haiku",
target_os = "openbsd",
target_os = "vita"
))
)))
)]
pub fn keepalive_time(&self) -> io::Result<Duration> {
Expand Down
6 changes: 3 additions & 3 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ pub(crate) fn socket(family: c_int, ty: c_int, protocol: c_int) -> io::Result<So
syscall!(socket(family, ty, protocol))
}

#[cfg(all(feature = "all", unix))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
#[cfg(all(feature = "all", unix, not(target_os = "vita")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix, not(target_os = "vita")))))]
pub(crate) fn socketpair(family: c_int, ty: c_int, protocol: c_int) -> io::Result<[Socket; 2]> {
let mut fds = [0, 0];
syscall!(socketpair(family, ty, protocol, fds.as_mut_ptr())).map(|_| fds)
Expand Down Expand Up @@ -1416,7 +1416,7 @@ impl crate::Socket {
),
allow(rustdoc::broken_intra_doc_links)
)]
#[cfg(feature = "all")]
#[cfg(all(feature = "all", not(target_os = "vita")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
pub fn set_cloexec(&self, close_on_exec: bool) -> io::Result<()> {
self._set_cloexec(close_on_exec)
Expand Down
11 changes: 8 additions & 3 deletions tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub fn assert_nonblocking(_: &Socket, _: bool) {
// No way to get this information...
}

#[cfg(all(unix, feature = "all"))]
#[cfg(all(unix, feature = "all", not(target_os = "vita")))]
#[test]
fn set_cloexec() {
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
Expand Down Expand Up @@ -494,7 +494,7 @@ fn connect_timeout_valid() {
}

#[test]
#[cfg(all(feature = "all", unix))]
#[cfg(all(feature = "all", unix, not(target_os = "vita")))]
fn pair() {
let (mut a, mut b) = Socket::pair(Domain::UNIX, Type::STREAM, None).unwrap();
let _ = a.write(DATA).unwrap();
Expand Down Expand Up @@ -870,7 +870,12 @@ fn tcp_keepalive() {

#[cfg(all(
feature = "all",
not(any(windows, target_os = "haiku", target_os = "openbsd"))
not(any(
windows,
target_os = "haiku",
target_os = "openbsd",
target_os = "vita"
))
))]
assert_eq!(socket.keepalive_time().unwrap(), Duration::from_secs(200));

Expand Down

0 comments on commit 1793c95

Please sign in to comment.