Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7f6ee12

Browse files
committed
Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patch
1 parent 87ca2db commit 7f6ee12

File tree

7 files changed

+43
-6
lines changed

7 files changed

+43
-6
lines changed

library/std/src/os/fd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod raw;
1313
mod owned;
1414

1515
// Implementations for `AsRawFd` etc. for network types.
16+
#[cfg(not(target_os = "trusty"))]
1617
mod net;
1718

1819
#[cfg(test)]

library/std/src/os/fd/owned.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
77
use crate::marker::PhantomData;
88
use crate::mem::ManuallyDrop;
9-
#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))]
9+
#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit", target_os = "trusty")))]
1010
use crate::sys::cvt;
11+
#[cfg(not(target_os = "trusty"))]
1112
use crate::sys_common::{AsInner, FromInner, IntoInner};
12-
use crate::{fmt, fs, io};
13+
use crate::{fmt, io};
14+
#[cfg(not(target_os = "trusty"))]
15+
use crate::fs;
1316

1417
type ValidRawFd = core::num::niche_types::NotAllOnes<RawFd>;
1518

@@ -87,7 +90,7 @@ impl OwnedFd {
8790
impl BorrowedFd<'_> {
8891
/// Creates a new `OwnedFd` instance that shares the same underlying file
8992
/// description as the existing `BorrowedFd` instance.
90-
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit")))]
93+
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))]
9194
#[stable(feature = "io_safety", since = "1.63.0")]
9295
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
9396
// We want to atomically duplicate this file descriptor and set the
@@ -110,7 +113,7 @@ impl BorrowedFd<'_> {
110113

111114
/// Creates a new `OwnedFd` instance that shares the same underlying file
112115
/// description as the existing `BorrowedFd` instance.
113-
#[cfg(any(target_arch = "wasm32", target_os = "hermit"))]
116+
#[cfg(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty"))]
114117
#[stable(feature = "io_safety", since = "1.63.0")]
115118
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
116119
Err(crate::io::Error::UNSUPPORTED_PLATFORM)
@@ -280,6 +283,7 @@ impl AsFd for OwnedFd {
280283
}
281284

282285
#[stable(feature = "io_safety", since = "1.63.0")]
286+
#[cfg(not(target_os = "trusty"))]
283287
impl AsFd for fs::File {
284288
#[inline]
285289
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -288,6 +292,7 @@ impl AsFd for fs::File {
288292
}
289293

290294
#[stable(feature = "io_safety", since = "1.63.0")]
295+
#[cfg(not(target_os = "trusty"))]
291296
impl From<fs::File> for OwnedFd {
292297
/// Takes ownership of a [`File`](fs::File)'s underlying file descriptor.
293298
#[inline]
@@ -297,6 +302,7 @@ impl From<fs::File> for OwnedFd {
297302
}
298303

299304
#[stable(feature = "io_safety", since = "1.63.0")]
305+
#[cfg(not(target_os = "trusty"))]
300306
impl From<OwnedFd> for fs::File {
301307
/// Returns a [`File`](fs::File) that takes ownership of the given
302308
/// file descriptor.
@@ -307,6 +313,7 @@ impl From<OwnedFd> for fs::File {
307313
}
308314

309315
#[stable(feature = "io_safety", since = "1.63.0")]
316+
#[cfg(not(target_os = "trusty"))]
310317
impl AsFd for crate::net::TcpStream {
311318
#[inline]
312319
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -315,6 +322,7 @@ impl AsFd for crate::net::TcpStream {
315322
}
316323

317324
#[stable(feature = "io_safety", since = "1.63.0")]
325+
#[cfg(not(target_os = "trusty"))]
318326
impl From<crate::net::TcpStream> for OwnedFd {
319327
/// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor.
320328
#[inline]
@@ -324,6 +332,7 @@ impl From<crate::net::TcpStream> for OwnedFd {
324332
}
325333

326334
#[stable(feature = "io_safety", since = "1.63.0")]
335+
#[cfg(not(target_os = "trusty"))]
327336
impl From<OwnedFd> for crate::net::TcpStream {
328337
#[inline]
329338
fn from(owned_fd: OwnedFd) -> Self {
@@ -334,6 +343,7 @@ impl From<OwnedFd> for crate::net::TcpStream {
334343
}
335344

336345
#[stable(feature = "io_safety", since = "1.63.0")]
346+
#[cfg(not(target_os = "trusty"))]
337347
impl AsFd for crate::net::TcpListener {
338348
#[inline]
339349
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -342,6 +352,7 @@ impl AsFd for crate::net::TcpListener {
342352
}
343353

344354
#[stable(feature = "io_safety", since = "1.63.0")]
355+
#[cfg(not(target_os = "trusty"))]
345356
impl From<crate::net::TcpListener> for OwnedFd {
346357
/// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor.
347358
#[inline]
@@ -351,6 +362,7 @@ impl From<crate::net::TcpListener> for OwnedFd {
351362
}
352363

353364
#[stable(feature = "io_safety", since = "1.63.0")]
365+
#[cfg(not(target_os = "trusty"))]
354366
impl From<OwnedFd> for crate::net::TcpListener {
355367
#[inline]
356368
fn from(owned_fd: OwnedFd) -> Self {
@@ -361,6 +373,7 @@ impl From<OwnedFd> for crate::net::TcpListener {
361373
}
362374

363375
#[stable(feature = "io_safety", since = "1.63.0")]
376+
#[cfg(not(target_os = "trusty"))]
364377
impl AsFd for crate::net::UdpSocket {
365378
#[inline]
366379
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -369,6 +382,7 @@ impl AsFd for crate::net::UdpSocket {
369382
}
370383

371384
#[stable(feature = "io_safety", since = "1.63.0")]
385+
#[cfg(not(target_os = "trusty"))]
372386
impl From<crate::net::UdpSocket> for OwnedFd {
373387
/// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor.
374388
#[inline]
@@ -378,6 +392,7 @@ impl From<crate::net::UdpSocket> for OwnedFd {
378392
}
379393

380394
#[stable(feature = "io_safety", since = "1.63.0")]
395+
#[cfg(not(target_os = "trusty"))]
381396
impl From<OwnedFd> for crate::net::UdpSocket {
382397
#[inline]
383398
fn from(owned_fd: OwnedFd) -> Self {

library/std/src/os/fd/raw.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ use crate::os::unix::io::AsFd;
1515
use crate::os::unix::io::OwnedFd;
1616
#[cfg(target_os = "wasi")]
1717
use crate::os::wasi::io::OwnedFd;
18+
#[cfg(not(target_os = "trusty"))]
1819
use crate::sys_common::{AsInner, IntoInner};
19-
use crate::{fs, io};
20+
#[cfg(not(target_os = "trusty"))]
21+
use crate::fs;
22+
use crate::io;
2023

2124
/// Raw file descriptors.
2225
#[stable(feature = "rust1", since = "1.0.0")]
@@ -161,20 +164,23 @@ impl FromRawFd for RawFd {
161164
}
162165

163166
#[stable(feature = "rust1", since = "1.0.0")]
167+
#[cfg(not(target_os = "trusty"))]
164168
impl AsRawFd for fs::File {
165169
#[inline]
166170
fn as_raw_fd(&self) -> RawFd {
167171
self.as_inner().as_raw_fd()
168172
}
169173
}
170174
#[stable(feature = "from_raw_os", since = "1.1.0")]
175+
#[cfg(not(target_os = "trusty"))]
171176
impl FromRawFd for fs::File {
172177
#[inline]
173178
unsafe fn from_raw_fd(fd: RawFd) -> fs::File {
174179
unsafe { fs::File::from(OwnedFd::from_raw_fd(fd)) }
175180
}
176181
}
177182
#[stable(feature = "into_raw_os", since = "1.4.0")]
183+
#[cfg(not(target_os = "trusty"))]
178184
impl IntoRawFd for fs::File {
179185
#[inline]
180186
fn into_raw_fd(self) -> RawFd {
@@ -183,6 +189,7 @@ impl IntoRawFd for fs::File {
183189
}
184190

185191
#[stable(feature = "asraw_stdio", since = "1.21.0")]
192+
#[cfg(not(target_os = "trusty"))]
186193
impl AsRawFd for io::Stdin {
187194
#[inline]
188195
fn as_raw_fd(&self) -> RawFd {
@@ -207,6 +214,7 @@ impl AsRawFd for io::Stderr {
207214
}
208215

209216
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
217+
#[cfg(not(target_os = "trusty"))]
210218
impl<'a> AsRawFd for io::StdinLock<'a> {
211219
#[inline]
212220
fn as_raw_fd(&self) -> RawFd {

library/std/src/os/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ pub mod rtems;
169169
pub mod solaris;
170170
#[cfg(target_os = "solid_asp3")]
171171
pub mod solid;
172+
#[cfg(target_os = "trusty")]
173+
pub mod trusty;
172174
#[cfg(target_os = "uefi")]
173175
pub mod uefi;
174176
#[cfg(target_os = "vita")]
@@ -178,7 +180,7 @@ pub mod vxworks;
178180
#[cfg(target_os = "xous")]
179181
pub mod xous;
180182

181-
#[cfg(any(unix, target_os = "hermit", target_os = "wasi", doc))]
183+
#[cfg(any(unix, target_os = "hermit", target_os = "trusty", target_os = "wasi", doc))]
182184
pub mod fd;
183185

184186
#[cfg(any(target_os = "linux", target_os = "android", doc))]

library/std/src/os/trusty/io/fd.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Owned and borrowed file descriptors.
2+
#![stable(feature = "os_fd", since = "1.66.0")]
3+
4+
pub use crate::os::fd::owned::*;

library/std/src/os/trusty/io/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![stable(feature = "os_fd", since = "1.66.0")]
2+
3+
#[stable(feature = "os_fd", since = "1.66.0")]
4+
pub use crate::os::fd::*;

library/std/src/os/trusty/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![stable(feature = "rust1", since = "1.0.0")]
2+
3+
pub mod io;

0 commit comments

Comments
 (0)