Skip to content

Commit 4085af0

Browse files
committed
Move fd into sys
1 parent 5cc6072 commit 4085af0

File tree

16 files changed

+43
-25
lines changed

16 files changed

+43
-25
lines changed

Diff for: library/std/src/sys/pal/hermit/fd.rs renamed to library/std/src/sys/fd/hermit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![unstable(reason = "not public", issue = "none", feature = "fd")]
22

3-
use super::hermit_abi;
43
use crate::cmp;
54
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read, SeekFrom};
5+
use crate::os::hermit::hermit_abi;
66
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
77
use crate::sys::{cvt, unsupported};
88
use crate::sys_common::{AsInner, FromInner, IntoInner};

Diff for: library/std/src/sys/fd/mod.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Platform-dependent file descriptor abstraction.
2+
3+
#![deny(unsafe_op_in_unsafe_fn)]
4+
5+
cfg_if::cfg_if! {
6+
if #[cfg(target_family = "unix")] {
7+
mod unix;
8+
pub use unix::*;
9+
} else if #[cfg(target_os = "hermit")] {
10+
mod hermit;
11+
pub use hermit::*;
12+
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
13+
mod sgx;
14+
pub use sgx::*;
15+
} else if #[cfg(target_os = "wasi")] {
16+
mod wasi;
17+
pub use wasi::*;
18+
}
19+
}

Diff for: library/std/src/sys/pal/sgx/fd.rs renamed to library/std/src/sys/fd/sgx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use fortanix_sgx_abi::Fd;
22

3-
use super::abi::usercalls;
43
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
54
use crate::mem::ManuallyDrop;
5+
use crate::sys::pal::abi::usercalls;
66
use crate::sys::{AsInner, FromInner, IntoInner};
77

88
#[derive(Debug)]

Diff for: library/std/src/sys/pal/unix/fd.rs renamed to library/std/src/sys/fd/unix.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![unstable(reason = "not public", issue = "none", feature = "fd")]
2+
#![allow(unsafe_op_in_unsafe_fn)]
23

34
#[cfg(test)]
45
mod tests;
@@ -22,6 +23,10 @@ use crate::cmp;
2223
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read};
2324
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
2425
use crate::sys::cvt;
26+
#[cfg(all(target_os = "android", target_pointer_width = "64"))]
27+
use crate::sys::pal::weak::syscall;
28+
#[cfg(any(all(target_os = "android", target_pointer_width = "32"), target_vendor = "apple"))]
29+
use crate::sys::pal::weak::weak;
2530
use crate::sys_common::{AsInner, FromInner, IntoInner};
2631

2732
#[derive(Debug)]
@@ -232,7 +237,7 @@ impl FileDesc {
232237
// implementation if `preadv` is not available.
233238
#[cfg(all(target_os = "android", target_pointer_width = "64"))]
234239
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
235-
super::weak::syscall!(
240+
syscall!(
236241
fn preadv(
237242
fd: libc::c_int,
238243
iovec: *const libc::iovec,
@@ -257,7 +262,7 @@ impl FileDesc {
257262
// and its metadata from LLVM IR.
258263
#[no_sanitize(cfi)]
259264
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
260-
super::weak::weak!(
265+
weak!(
261266
fn preadv64(
262267
fd: libc::c_int,
263268
iovec: *const libc::iovec,
@@ -293,7 +298,7 @@ impl FileDesc {
293298
// use "weak" linking.
294299
#[cfg(target_vendor = "apple")]
295300
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
296-
super::weak::weak!(
301+
weak!(
297302
fn preadv(
298303
fd: libc::c_int,
299304
iovec: *const libc::iovec,
@@ -442,7 +447,7 @@ impl FileDesc {
442447
// implementation if `pwritev` is not available.
443448
#[cfg(all(target_os = "android", target_pointer_width = "64"))]
444449
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
445-
super::weak::syscall!(
450+
syscall!(
446451
fn pwritev(
447452
fd: libc::c_int,
448453
iovec: *const libc::iovec,
@@ -464,7 +469,7 @@ impl FileDesc {
464469

465470
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
466471
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
467-
super::weak::weak!(
472+
weak!(
468473
fn pwritev64(
469474
fd: libc::c_int,
470475
iovec: *const libc::iovec,
@@ -500,7 +505,7 @@ impl FileDesc {
500505
// use "weak" linking.
501506
#[cfg(target_vendor = "apple")]
502507
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
503-
super::weak::weak!(
508+
weak!(
504509
fn pwritev(
505510
fd: libc::c_int,
506511
iovec: *const libc::iovec,

Diff for: library/std/src/sys/pal/unix/fd/tests.rs renamed to library/std/src/sys/fd/unix/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::mem::ManuallyDrop;
22

3-
use super::{FileDesc, IoSlice};
3+
use super::FileDesc;
4+
use crate::io::IoSlice;
45
use crate::os::unix::io::FromRawFd;
56

67
#[test]

Diff for: library/std/src/sys/pal/wasi/fd.rs renamed to library/std/src/sys/fd/wasi.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#![forbid(unsafe_op_in_unsafe_fn)]
2-
#![allow(dead_code)]
1+
#![expect(dead_code)]
32

4-
use super::err2io;
53
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
64
use crate::mem;
75
use crate::net::Shutdown;
86
use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
7+
use crate::sys::pal::err2io;
98
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
109

1110
#[derive(Debug)]

Diff for: library/std/src/sys/fs/hermit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, Raw
99
use crate::path::{Path, PathBuf};
1010
use crate::sync::Arc;
1111
use crate::sys::common::small_c_string::run_path_with_cstr;
12+
use crate::sys::fd::FileDesc;
1213
pub use crate::sys::fs::common::{copy, exists};
13-
use crate::sys::pal::fd::FileDesc;
1414
use crate::sys::time::SystemTime;
1515
use crate::sys::{cvt, unsupported};
1616
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};

Diff for: library/std/src/sys/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod anonymous_pipe;
1212
pub mod backtrace;
1313
pub mod cmath;
1414
pub mod exit_guard;
15+
pub mod fd;
1516
pub mod fs;
1617
pub mod io;
1718
pub mod net;

Diff for: library/std/src/sys/pal/hermit/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::os::raw::c_char;
2020

2121
pub mod args;
2222
pub mod env;
23-
pub mod fd;
2423
pub mod futex;
2524
pub mod os;
2625
#[path = "../unsupported/pipe.rs"]

Diff for: library/std/src/sys/pal/sgx/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::sync::atomic::{AtomicBool, Ordering};
1111
pub mod abi;
1212
pub mod args;
1313
pub mod env;
14-
pub mod fd;
1514
mod libunwind_integration;
1615
pub mod os;
1716
#[path = "../unsupported/pipe.rs"]

Diff for: library/std/src/sys/pal/unix/linux/pidfd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::io;
22
use crate::os::fd::{AsRawFd, FromRawFd, RawFd};
33
use crate::sys::cvt;
4-
use crate::sys::pal::unix::fd::FileDesc;
4+
use crate::sys::fd::FileDesc;
55
use crate::sys::process::ExitStatus;
66
use crate::sys_common::{AsInner, FromInner, IntoInner};
77

Diff for: library/std/src/sys/pal/unix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub mod weak;
88

99
pub mod args;
1010
pub mod env;
11-
pub mod fd;
1211
#[cfg(target_os = "fuchsia")]
1312
pub mod fuchsia;
1413
pub mod futex;

Diff for: library/std/src/sys/pal/wasi/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
1616
pub mod args;
1717
pub mod env;
18-
pub mod fd;
1918
#[allow(unused)]
2019
#[path = "../wasm/atomics/futex.rs"]
2120
pub mod futex;

Diff for: library/std/src/sys/pal/wasip2/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
pub mod args;
1111
#[path = "../wasi/env.rs"]
1212
pub mod env;
13-
#[path = "../wasi/fd.rs"]
14-
pub mod fd;
1513
#[allow(unused)]
1614
#[path = "../wasm/atomics/futex.rs"]
1715
pub mod futex;
@@ -39,7 +37,6 @@ mod helpers;
3937
// import conflict rules. If we glob export `helpers` and `common` together,
4038
// then the compiler complains about conflicts.
4139

42-
use helpers::err2io;
43-
pub use helpers::{abort_internal, decode_error_kind, is_interrupted};
40+
pub(crate) use helpers::{abort_internal, decode_error_kind, err2io, is_interrupted};
4441

4542
mod cabi_realloc;

Diff for: library/std/src/sys/stdio/wasi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
44
use crate::mem::ManuallyDrop;
55
use crate::os::raw;
66
use crate::os::wasi::io::{AsRawFd, FromRawFd};
7-
use crate::sys::pal::fd::WasiFd;
7+
use crate::sys::fd::WasiFd;
88

99
pub struct Stdin;
1010
pub struct Stdout;

Diff for: src/bootstrap/mk/Makefile.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ check-aux:
7373
$(BOOTSTRAP) miri --stage 2 library/std \
7474
$(BOOTSTRAP_ARGS) \
7575
--no-doc -- \
76-
--skip fs:: --skip net:: --skip process:: --skip sys::pal::
76+
--skip fs:: --skip net:: --skip process:: --skip sys::fd:: --skip sys::pal::
7777
$(Q)MIRIFLAGS="-Zmiri-disable-isolation" \
7878
$(BOOTSTRAP) miri --stage 2 library/std \
7979
$(BOOTSTRAP_ARGS) \
8080
--doc -- \
81-
--skip fs:: --skip net:: --skip process:: --skip sys::pal::
81+
--skip fs:: --skip net:: --skip process:: --skip sys::fd:: --skip sys::pal::
8282
# Also test some very target-specific modules on other targets
8383
# (making sure to cover an i686 target as well).
8484
$(Q)MIRIFLAGS="-Zmiri-disable-isolation" BOOTSTRAP_SKIP_TARGET_SANITY=1 \

0 commit comments

Comments
 (0)