From da0d506ace5dc5ec36cd1eafa37a0657fa61442e Mon Sep 17 00:00:00 2001 From: Tomoaki Kawada Date: Fri, 28 Jan 2022 14:53:54 +0900 Subject: [PATCH] kmc-solid: Implement `FileDesc::duplicate` --- library/std/src/sys/solid/abi/sockets.rs | 3 +++ library/std/src/sys/solid/net.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/solid/abi/sockets.rs b/library/std/src/sys/solid/abi/sockets.rs index 7c21d0dd25e03..eb06a6dd927e6 100644 --- a/library/std/src/sys/solid/abi/sockets.rs +++ b/library/std/src/sys/solid/abi/sockets.rs @@ -175,6 +175,9 @@ extern "C" { #[link_name = "SOLID_NET_Close"] pub fn close(s: c_int) -> c_int; + #[link_name = "SOLID_NET_Dup"] + pub fn dup(s: c_int) -> c_int; + #[link_name = "SOLID_NET_GetPeerName"] pub fn getpeername(s: c_int, name: *mut sockaddr, namelen: *mut socklen_t) -> c_int; diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index 63ba6341c796c..c91ecce4d728b 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -107,7 +107,7 @@ impl FileDesc { } fn duplicate(&self) -> io::Result { - super::unsupported() + cvt(unsafe { netc::dup(self.fd) }).map(Self::new) } }