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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn target() -> Target {
exe_suffix: ".elf".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
families: cvs![],
has_thread_local: true,
has_rpath: false,
crt_static_default: false,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/io/io_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::mem::take;
use crate::ops::{Deref, DerefMut};

cfg_select! {
any(target_family = "unix", target_os = "hermit", target_os = "solid_asp3", target_os = "trusty", target_os = "wasi") => {
any(target_family = "unix", target_os = "hermit", target_os = "solid_asp3", target_os = "trusty", target_os = "wasi", target_os = "qurt") => {
#[path = "io_slice/repr_iovec.rs"]
mod repr;
}
Expand Down
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,13 +13,13 @@ 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;

// Implementation of stdio file descriptor constants.
mod stdio;

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

// Export the types and traits for the public API.
Expand Down
30 changes: 15 additions & 15 deletions library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,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 @@ -350,7 +350,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 @@ -360,7 +360,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 @@ -371,7 +371,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 @@ -380,7 +380,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 @@ -390,7 +390,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 @@ -401,7 +401,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 @@ -410,7 +410,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 @@ -420,7 +420,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 @@ -529,47 +529,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
2 changes: 2 additions & 0 deletions library/std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::fs;
use crate::io;
#[cfg(target_os = "hermit")]
use crate::os::hermit::io::OwnedFd;
#[cfg(target_os = "qurt")]
use crate::os::qurt::io::OwnedFd;
#[cfg(all(not(target_os = "hermit"), not(target_os = "motor")))]
use crate::os::raw;
#[cfg(all(doc, not(any(target_arch = "wasm32", target_env = "sgx"))))]
Expand Down
3 changes: 3 additions & 0 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cfg_select! {
target_os = "trusty",
target_os = "wasi",
target_os = "motor",
target_os = "qurt",
doc
))]
pub mod fd;
Expand Down Expand Up @@ -127,6 +128,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
64 changes: 64 additions & 0 deletions library/std/src/os/qurt/ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! 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::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 impl(self) trait OsStringExt {
/// 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 impl(self) trait OsStrExt {
#[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
}
}
122 changes: 122 additions & 0 deletions library/std/src/os/qurt/fs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//! QuRT-specific extensions to primitives in the [`std::fs`] module.
//!
//! [`std::fs`]: crate::fs
//!
//! Note: QuRT has a minimal stat structure without uid/gid/blksize/blocks/nsec fields.
//! The accessor methods for these fields return stub values (0).

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

use crate::fs::Metadata;
use crate::sys::AsInner;

/// OS-specific extensions to [`fs::Metadata`].
///
/// [`fs::Metadata`]: crate::fs::Metadata
///
/// Note: QuRT has a minimal stat structure. The following fields are not available
/// and return stub values:
/// - `st_uid`, `st_gid`: QuRT doesn't have user/group ownership (returns 0)
/// - `st_blksize`, `st_blocks`: QuRT doesn't track block information (returns 0)
/// - `st_atime_nsec`, `st_mtime_nsec`, `st_ctime_nsec`: QuRT only has second-level precision (returns 0)
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_dev(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ino(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mode(&self) -> u32;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_nlink(&self) -> u64;
/// Returns 0 on QuRT (user ownership not supported).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_uid(&self) -> u32;
/// Returns 0 on QuRT (group ownership not supported).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_gid(&self) -> u32;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_rdev(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_size(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_atime(&self) -> i64;
/// Returns 0 on QuRT (nanosecond precision not supported).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_atime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mtime(&self) -> i64;
/// Returns 0 on QuRT (nanosecond precision not supported).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mtime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ctime(&self) -> i64;
/// Returns 0 on QuRT (nanosecond precision not supported).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ctime_nsec(&self) -> i64;
/// Returns 0 on QuRT (block size not tracked).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_blksize(&self) -> u64;
/// Returns 0 on QuRT (block count not tracked).
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_blocks(&self) -> u64;
}

#[stable(feature = "metadata_ext", since = "1.1.0")]
impl MetadataExt for Metadata {
fn st_dev(&self) -> u64 {
self.as_inner().as_inner().st_dev as u64
}
fn st_ino(&self) -> u64 {
self.as_inner().as_inner().st_ino as u64
}
fn st_mode(&self) -> u32 {
self.as_inner().as_inner().st_mode as u32
}
fn st_nlink(&self) -> u64 {
self.as_inner().as_inner().st_nlink as u64
}
fn st_uid(&self) -> u32 {
// QuRT doesn't have user ownership
0
}
fn st_gid(&self) -> u32 {
// QuRT doesn't have group ownership
0
}
fn st_rdev(&self) -> u64 {
self.as_inner().as_inner().st_rdev as u64
}
fn st_size(&self) -> u64 {
self.as_inner().as_inner().st_size as u64
}
fn st_atime(&self) -> i64 {
self.as_inner().as_inner().st_atime as i64
}
fn st_atime_nsec(&self) -> i64 {
// QuRT only has second-level precision
0
}
fn st_mtime(&self) -> i64 {
self.as_inner().as_inner().st_mtime as i64
}
fn st_mtime_nsec(&self) -> i64 {
// QuRT only has second-level precision
0
}
fn st_ctime(&self) -> i64 {
self.as_inner().as_inner().st_ctime as i64
}
fn st_ctime_nsec(&self) -> i64 {
// QuRT only has second-level precision
0
}
fn st_blksize(&self) -> u64 {
// QuRT doesn't track block size
0
}
fn st_blocks(&self) -> u64 {
// QuRT doesn't track block count
0
}
}
8 changes: 8 additions & 0 deletions library/std/src/os/qurt/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! QuRT-specific I/O functionality.
//!
//! QuRT supports Unix-like file descriptors through its POSIX compatibility layer.

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

#[stable(feature = "rust1", since = "1.0.0")]
pub use crate::os::fd::*;
Loading
Loading