Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/std/src/os/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ mod raw;
mod owned;

// Implementations for `AsRawFd` etc. for network types.
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
mod net;

#[cfg(test)]
#[cfg(all(test, not(target_os = "qurt")))]
mod tests;

// Export the types and traits for the public API.
Expand Down
32 changes: 16 additions & 16 deletions library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Drop for OwnedFd {
// the latest POSIX wording: http://austingroupbugs.net/view.php?id=529
#[cfg(not(target_os = "hermit"))]
{
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "qurt")))]
crate::sys::fs::debug_assert_fd_is_open(self.fd.as_inner());

let _ = libc::close(self.fd.as_inner());
Expand Down Expand Up @@ -344,7 +344,7 @@ impl From<OwnedFd> for fs::File {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsFd for crate::net::TcpStream {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
Expand All @@ -353,7 +353,7 @@ impl AsFd for crate::net::TcpStream {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<crate::net::TcpStream> for OwnedFd {
/// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor.
#[inline]
Expand All @@ -363,7 +363,7 @@ impl From<crate::net::TcpStream> for OwnedFd {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<OwnedFd> for crate::net::TcpStream {
#[inline]
fn from(owned_fd: OwnedFd) -> Self {
Expand All @@ -374,7 +374,7 @@ impl From<OwnedFd> for crate::net::TcpStream {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsFd for crate::net::TcpListener {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
Expand All @@ -383,7 +383,7 @@ impl AsFd for crate::net::TcpListener {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<crate::net::TcpListener> for OwnedFd {
/// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor.
#[inline]
Expand All @@ -393,7 +393,7 @@ impl From<crate::net::TcpListener> for OwnedFd {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<OwnedFd> for crate::net::TcpListener {
#[inline]
fn from(owned_fd: OwnedFd) -> Self {
Expand All @@ -404,7 +404,7 @@ impl From<OwnedFd> for crate::net::TcpListener {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsFd for crate::net::UdpSocket {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
Expand All @@ -413,7 +413,7 @@ impl AsFd for crate::net::UdpSocket {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<crate::net::UdpSocket> for OwnedFd {
/// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor.
#[inline]
Expand All @@ -423,7 +423,7 @@ impl From<crate::net::UdpSocket> for OwnedFd {
}

#[stable(feature = "io_safety", since = "1.63.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<OwnedFd> for crate::net::UdpSocket {
#[inline]
fn from(owned_fd: OwnedFd) -> Self {
Expand Down Expand Up @@ -532,47 +532,47 @@ impl<'a> AsFd for io::StderrLock<'a> {
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsFd for io::PipeReader {
fn as_fd(&self) -> BorrowedFd<'_> {
self.0.as_fd()
}
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<io::PipeReader> for OwnedFd {
fn from(pipe: io::PipeReader) -> Self {
pipe.0.into_inner()
}
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsFd for io::PipeWriter {
fn as_fd(&self) -> BorrowedFd<'_> {
self.0.as_fd()
}
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<io::PipeWriter> for OwnedFd {
fn from(pipe: io::PipeWriter) -> Self {
pipe.0.into_inner()
}
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<OwnedFd> for io::PipeReader {
fn from(owned_fd: OwnedFd) -> Self {
Self(FromInner::from_inner(owned_fd))
}
}

#[stable(feature = "anonymous_pipe", since = "1.87.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl From<OwnedFd> for io::PipeWriter {
fn from(owned_fd: OwnedFd) -> Self {
Self(FromInner::from_inner(owned_fd))
Expand Down
8 changes: 6 additions & 2 deletions library/std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl IntoRawFd for fs::File {
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl AsRawFd for io::Stdin {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -202,6 +202,7 @@ impl AsRawFd for io::Stdin {
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
#[cfg(not(target_os = "qurt"))]
impl AsRawFd for io::Stdout {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -210,6 +211,7 @@ impl AsRawFd for io::Stdout {
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
#[cfg(not(target_os = "qurt"))]
impl AsRawFd for io::Stderr {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -218,7 +220,7 @@ impl AsRawFd for io::Stderr {
}

#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "qurt")))]
impl<'a> AsRawFd for io::StdinLock<'a> {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -227,6 +229,7 @@ impl<'a> AsRawFd for io::StdinLock<'a> {
}

#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
#[cfg(not(target_os = "qurt"))]
impl<'a> AsRawFd for io::StdoutLock<'a> {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand All @@ -235,6 +238,7 @@ impl<'a> AsRawFd for io::StdoutLock<'a> {
}

#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
#[cfg(not(target_os = "qurt"))]
impl<'a> AsRawFd for io::StderrLock<'a> {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ pub mod nto;
pub mod nuttx;
#[cfg(target_os = "openbsd")]
pub mod openbsd;
#[cfg(target_os = "qurt")]
pub mod qurt;
#[cfg(target_os = "redox")]
pub mod redox;
#[cfg(target_os = "rtems")]
Expand Down
65 changes: 65 additions & 0 deletions library/std/src/os/qurt/ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//! QuRT-specific extension to the primitives in the [`std::ffi`] module.
//!
//! [`std::ffi`]: crate::ffi

#![stable(feature = "raw_ext", since = "1.1.0")]

use crate::ffi::{OsStr, OsString};
use crate::mem;
use crate::sealed::Sealed;
use crate::sys::os_str::Buf;
use crate::sys::{AsInner, FromInner, IntoInner};

/// QuRT-specific extensions to [`OsString`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
#[stable(feature = "raw_ext", since = "1.1.0")]
pub trait OsStringExt: Sealed {
/// Creates an [`OsString`] from a byte vector.
#[stable(feature = "raw_ext", since = "1.1.0")]
fn from_vec(vec: Vec<u8>) -> Self;

/// Yields the underlying byte vector of this [`OsString`].
#[stable(feature = "raw_ext", since = "1.1.0")]
fn into_vec(self) -> Vec<u8>;
}

#[stable(feature = "raw_ext", since = "1.1.0")]
impl OsStringExt for OsString {
#[inline]
fn from_vec(vec: Vec<u8>) -> OsString {
FromInner::from_inner(Buf { inner: vec })
}

#[inline]
fn into_vec(self) -> Vec<u8> {
self.into_inner().inner
}
}

/// QuRT-specific extensions to [`OsStr`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
#[stable(feature = "raw_ext", since = "1.1.0")]
pub trait OsStrExt: Sealed {
#[stable(feature = "raw_ext", since = "1.1.0")]
/// Creates an [`OsStr`] from a byte slice.
fn from_bytes(slice: &[u8]) -> &Self;

/// Gets the underlying byte view of the [`OsStr`] slice.
#[stable(feature = "raw_ext", since = "1.1.0")]
fn as_bytes(&self) -> &[u8];
}

#[stable(feature = "raw_ext", since = "1.1.0")]
impl OsStrExt for OsStr {
#[inline]
fn from_bytes(slice: &[u8]) -> &OsStr {
unsafe { mem::transmute(slice) }
}

#[inline]
fn as_bytes(&self) -> &[u8] {
&self.as_inner().inner
}
}
Loading
Loading