Skip to content

Commit 0a44d22

Browse files
committed
Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patch
1 parent 2069305 commit 0a44d22

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

@@ -89,7 +92,7 @@ impl OwnedFd {
8992
impl BorrowedFd<'_> {
9093
/// Creates a new `OwnedFd` instance that shares the same underlying file
9194
/// description as the existing `BorrowedFd` instance.
92-
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit")))]
95+
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))]
9396
#[stable(feature = "io_safety", since = "1.63.0")]
9497
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
9598
// We want to atomically duplicate this file descriptor and set the
@@ -112,7 +115,7 @@ impl BorrowedFd<'_> {
112115

113116
/// Creates a new `OwnedFd` instance that shares the same underlying file
114117
/// description as the existing `BorrowedFd` instance.
115-
#[cfg(any(target_arch = "wasm32", target_os = "hermit"))]
118+
#[cfg(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty"))]
116119
#[stable(feature = "io_safety", since = "1.63.0")]
117120
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
118121
Err(crate::io::Error::UNSUPPORTED_PLATFORM)
@@ -284,6 +287,7 @@ impl AsFd for OwnedFd {
284287
}
285288

286289
#[stable(feature = "io_safety", since = "1.63.0")]
290+
#[cfg(not(target_os = "trusty"))]
287291
impl AsFd for fs::File {
288292
#[inline]
289293
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -292,6 +296,7 @@ impl AsFd for fs::File {
292296
}
293297

294298
#[stable(feature = "io_safety", since = "1.63.0")]
299+
#[cfg(not(target_os = "trusty"))]
295300
impl From<fs::File> for OwnedFd {
296301
/// Takes ownership of a [`File`](fs::File)'s underlying file descriptor.
297302
#[inline]
@@ -301,6 +306,7 @@ impl From<fs::File> for OwnedFd {
301306
}
302307

303308
#[stable(feature = "io_safety", since = "1.63.0")]
309+
#[cfg(not(target_os = "trusty"))]
304310
impl From<OwnedFd> for fs::File {
305311
/// Returns a [`File`](fs::File) that takes ownership of the given
306312
/// file descriptor.
@@ -311,6 +317,7 @@ impl From<OwnedFd> for fs::File {
311317
}
312318

313319
#[stable(feature = "io_safety", since = "1.63.0")]
320+
#[cfg(not(target_os = "trusty"))]
314321
impl AsFd for crate::net::TcpStream {
315322
#[inline]
316323
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -319,6 +326,7 @@ impl AsFd for crate::net::TcpStream {
319326
}
320327

321328
#[stable(feature = "io_safety", since = "1.63.0")]
329+
#[cfg(not(target_os = "trusty"))]
322330
impl From<crate::net::TcpStream> for OwnedFd {
323331
/// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor.
324332
#[inline]
@@ -328,6 +336,7 @@ impl From<crate::net::TcpStream> for OwnedFd {
328336
}
329337

330338
#[stable(feature = "io_safety", since = "1.63.0")]
339+
#[cfg(not(target_os = "trusty"))]
331340
impl From<OwnedFd> for crate::net::TcpStream {
332341
#[inline]
333342
fn from(owned_fd: OwnedFd) -> Self {
@@ -338,6 +347,7 @@ impl From<OwnedFd> for crate::net::TcpStream {
338347
}
339348

340349
#[stable(feature = "io_safety", since = "1.63.0")]
350+
#[cfg(not(target_os = "trusty"))]
341351
impl AsFd for crate::net::TcpListener {
342352
#[inline]
343353
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -346,6 +356,7 @@ impl AsFd for crate::net::TcpListener {
346356
}
347357

348358
#[stable(feature = "io_safety", since = "1.63.0")]
359+
#[cfg(not(target_os = "trusty"))]
349360
impl From<crate::net::TcpListener> for OwnedFd {
350361
/// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor.
351362
#[inline]
@@ -355,6 +366,7 @@ impl From<crate::net::TcpListener> for OwnedFd {
355366
}
356367

357368
#[stable(feature = "io_safety", since = "1.63.0")]
369+
#[cfg(not(target_os = "trusty"))]
358370
impl From<OwnedFd> for crate::net::TcpListener {
359371
#[inline]
360372
fn from(owned_fd: OwnedFd) -> Self {
@@ -365,6 +377,7 @@ impl From<OwnedFd> for crate::net::TcpListener {
365377
}
366378

367379
#[stable(feature = "io_safety", since = "1.63.0")]
380+
#[cfg(not(target_os = "trusty"))]
368381
impl AsFd for crate::net::UdpSocket {
369382
#[inline]
370383
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -373,6 +386,7 @@ impl AsFd for crate::net::UdpSocket {
373386
}
374387

375388
#[stable(feature = "io_safety", since = "1.63.0")]
389+
#[cfg(not(target_os = "trusty"))]
376390
impl From<crate::net::UdpSocket> for OwnedFd {
377391
/// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor.
378392
#[inline]
@@ -382,6 +396,7 @@ impl From<crate::net::UdpSocket> for OwnedFd {
382396
}
383397

384398
#[stable(feature = "io_safety", since = "1.63.0")]
399+
#[cfg(not(target_os = "trusty"))]
385400
impl From<OwnedFd> for crate::net::UdpSocket {
386401
#[inline]
387402
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)