-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #107405 - hermitcore:bsd, r=bjorn3
add support of RustyHermit's BSD socket layer RustyHermit is a tier 3 platform and publishes a new kernel interface. The new version supports a common BSD socket layer. By supporting this interface, the implementation of `std` can be harmonized to other operating systems. In `sys_common/mod.rs` we remove only a special case for RustyHermit. All changes are done in the RustyHermit specific directories. To realize this socket layer, the handling of file descriptors is also harmonized to other operating systems.
- Loading branch information
Showing
16 changed files
with
594 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![stable(feature = "os_fd", since = "1.66.0")] | ||
|
||
mod net; | ||
#[path = "../../fd/owned.rs"] | ||
mod owned; | ||
#[path = "../../fd/raw.rs"] | ||
mod raw; | ||
|
||
// Export the types and traits for the public API. | ||
#[stable(feature = "os_fd", since = "1.66.0")] | ||
pub use owned::*; | ||
#[stable(feature = "os_fd", since = "1.66.0")] | ||
pub use raw::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::os::hermit::io::OwnedFd; | ||
use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; | ||
use crate::sys_common::{self, AsInner, FromInner, IntoInner}; | ||
use crate::{net, sys}; | ||
|
||
macro_rules! impl_as_raw_fd { | ||
($($t:ident)*) => {$( | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
impl AsRawFd for net::$t { | ||
#[inline] | ||
fn as_raw_fd(&self) -> RawFd { | ||
self.as_inner().socket().as_raw_fd() | ||
} | ||
} | ||
)*}; | ||
} | ||
impl_as_raw_fd! { TcpStream TcpListener UdpSocket } | ||
|
||
macro_rules! impl_from_raw_fd { | ||
($($t:ident)*) => {$( | ||
#[stable(feature = "from_raw_os", since = "1.1.0")] | ||
impl FromRawFd for net::$t { | ||
#[inline] | ||
unsafe fn from_raw_fd(fd: RawFd) -> net::$t { | ||
unsafe { | ||
let socket = sys::net::Socket::from_inner(FromInner::from_inner(OwnedFd::from_raw_fd(fd))); | ||
net::$t::from_inner(sys_common::net::$t::from_inner(socket)) | ||
} | ||
} | ||
} | ||
)*}; | ||
} | ||
impl_from_raw_fd! { TcpStream TcpListener UdpSocket } | ||
|
||
macro_rules! impl_into_raw_fd { | ||
($($t:ident)*) => {$( | ||
#[stable(feature = "into_raw_os", since = "1.4.0")] | ||
impl IntoRawFd for net::$t { | ||
#[inline] | ||
fn into_raw_fd(self) -> RawFd { | ||
self.into_inner().into_socket().into_inner().into_inner().into_raw_fd() | ||
} | ||
} | ||
)*}; | ||
} | ||
impl_into_raw_fd! { TcpStream TcpListener UdpSocket } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.