Auto merge of #84200 - CDirkx:os, r=m-ou-se
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038. `@rustbot` label: +T-libs-impl
This commit is contained in:
commit
342db70ae4
47 changed files with 172 additions and 201 deletions
|
|
@ -3,7 +3,7 @@
|
|||
//! This includes functions to deal with memory isolation, usercalls, and the
|
||||
//! SGX instruction set.
|
||||
|
||||
#![deny(missing_docs, missing_debug_implementations)]
|
||||
#![deny(missing_docs)]
|
||||
#![unstable(feature = "sgx_platform", issue = "56975")]
|
||||
|
||||
/// Low-level interfaces to usercalls. See the [ABI documentation] for more
|
||||
|
|
@ -43,7 +43,9 @@ pub mod mem {
|
|||
pub use crate::sys::abi::mem::*;
|
||||
}
|
||||
|
||||
pub use crate::sys::ext::{arch, ffi, io};
|
||||
pub mod arch;
|
||||
pub mod ffi;
|
||||
pub mod io;
|
||||
|
||||
/// Functions for querying thread-related information.
|
||||
pub mod thread {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub mod ffi;
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
//! Linux-specific definitions.
|
||||
|
||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
||||
#![doc(cfg(target_os = "linux"))]
|
||||
|
||||
pub mod fs;
|
||||
pub mod raw;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
definitions"
|
||||
)]
|
||||
#![allow(deprecated)]
|
||||
#![allow(missing_debug_implementations)]
|
||||
|
||||
use crate::os::raw::c_ulong;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,78 +3,119 @@
|
|||
#![stable(feature = "os", since = "1.0.0")]
|
||||
#![allow(missing_docs, nonstandard_style, missing_debug_implementations)]
|
||||
|
||||
// When documenting libstd we want to show unix/windows/linux/wasi modules as these are the "main
|
||||
// modules" that are used across platforms, so all modules are enabled when `cfg(doc)` is set.
|
||||
// This should help show platform-specific functionality in a hopefully cross-platform way in the
|
||||
// documentation.
|
||||
// Note that we deliberately avoid `cfg_if!` here to work around a rust-analyzer bug that would make
|
||||
// `std::os` submodules unusable: https://github.com/rust-analyzer/rust-analyzer/issues/6038
|
||||
|
||||
#[cfg(doc)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use crate::sys::unix_ext as unix;
|
||||
|
||||
#[cfg(doc)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use crate::sys::windows_ext as windows;
|
||||
|
||||
#[cfg(doc)]
|
||||
#[doc(cfg(target_os = "linux"))]
|
||||
pub mod linux;
|
||||
|
||||
#[cfg(doc)]
|
||||
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
|
||||
pub use crate::sys::wasi_ext as wasi;
|
||||
|
||||
// If we're not documenting libstd then we just expose the main modules as we otherwise would.
|
||||
|
||||
#[cfg(not(doc))]
|
||||
#[cfg(any(unix, target_os = "hermit"))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use crate::sys::ext as unix;
|
||||
|
||||
#[cfg(not(doc))]
|
||||
#[cfg(windows)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use crate::sys::ext as windows;
|
||||
|
||||
#[cfg(not(doc))]
|
||||
#[cfg(any(target_os = "linux", target_os = "l4re"))]
|
||||
pub mod linux;
|
||||
|
||||
#[cfg(not(doc))]
|
||||
#[cfg(target_os = "wasi")]
|
||||
pub mod wasi;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod android;
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
pub mod dragonfly;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
pub mod emscripten;
|
||||
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
|
||||
pub mod fortanix_sgx;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod freebsd;
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
pub mod fuchsia;
|
||||
#[cfg(target_os = "haiku")]
|
||||
pub mod haiku;
|
||||
#[cfg(target_os = "illumos")]
|
||||
pub mod illumos;
|
||||
#[cfg(target_os = "ios")]
|
||||
pub mod ios;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
#[cfg(target_os = "netbsd")]
|
||||
pub mod netbsd;
|
||||
#[cfg(target_os = "openbsd")]
|
||||
pub mod openbsd;
|
||||
#[cfg(target_os = "redox")]
|
||||
pub mod redox;
|
||||
#[cfg(target_os = "solaris")]
|
||||
pub mod solaris;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
pub mod vxworks;
|
||||
|
||||
pub mod raw;
|
||||
|
||||
// The code below could be written clearer using `cfg_if!`. However, the items below are
|
||||
// publicly exported by `std` and external tools can have trouble analysing them because of the use
|
||||
// of a macro that is not vendored by Rust and included in the toolchain.
|
||||
// See https://github.com/rust-analyzer/rust-analyzer/issues/6038.
|
||||
|
||||
#[cfg(all(
|
||||
doc,
|
||||
not(any(
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
all(target_vendor = "fortanix", target_env = "sgx")
|
||||
))
|
||||
))]
|
||||
#[path = "."]
|
||||
mod doc {
|
||||
// When documenting std we want to show the `unix`, `windows`, `linux` and `wasi`
|
||||
// modules as these are the "main modules" that are used across platforms,
|
||||
// so these modules are enabled when `cfg(doc)` is set.
|
||||
// This should help show platform-specific functionality in a hopefully cross-platform
|
||||
// way in the documentation.
|
||||
|
||||
pub mod unix;
|
||||
|
||||
pub mod linux;
|
||||
|
||||
pub mod wasi;
|
||||
|
||||
pub mod windows;
|
||||
}
|
||||
#[cfg(all(
|
||||
doc,
|
||||
any(
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
all(target_vendor = "fortanix", target_env = "sgx")
|
||||
)
|
||||
))]
|
||||
mod doc {
|
||||
// On certain platforms right now the "main modules" modules that are
|
||||
// documented don't compile (missing things in `libc` which is empty),
|
||||
// so just omit them with an empty module.
|
||||
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
pub mod unix {}
|
||||
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
pub mod linux {}
|
||||
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
pub mod wasi {}
|
||||
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
pub mod windows {}
|
||||
}
|
||||
#[cfg(doc)]
|
||||
#[stable(feature = "os", since = "1.0.0")]
|
||||
pub use doc::*;
|
||||
|
||||
#[cfg(not(doc))]
|
||||
#[path = "."]
|
||||
mod imp {
|
||||
// If we're not documenting std then we only expose modules appropriate for the
|
||||
// current platform.
|
||||
|
||||
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
|
||||
pub mod fortanix_sgx;
|
||||
|
||||
#[cfg(target_os = "hermit")]
|
||||
#[path = "hermit/mod.rs"]
|
||||
pub mod unix;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod android;
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
pub mod dragonfly;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
pub mod emscripten;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod freebsd;
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
pub mod fuchsia;
|
||||
#[cfg(target_os = "haiku")]
|
||||
pub mod haiku;
|
||||
#[cfg(target_os = "illumos")]
|
||||
pub mod illumos;
|
||||
#[cfg(target_os = "ios")]
|
||||
pub mod ios;
|
||||
#[cfg(target_os = "l4re")]
|
||||
pub mod linux;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
#[cfg(target_os = "netbsd")]
|
||||
pub mod netbsd;
|
||||
#[cfg(target_os = "openbsd")]
|
||||
pub mod openbsd;
|
||||
#[cfg(target_os = "redox")]
|
||||
pub mod redox;
|
||||
#[cfg(target_os = "solaris")]
|
||||
pub mod solaris;
|
||||
#[cfg(unix)]
|
||||
pub mod unix;
|
||||
|
||||
#[cfg(target_os = "vxworks")]
|
||||
pub mod vxworks;
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
pub mod wasi;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub mod windows;
|
||||
}
|
||||
#[cfg(not(doc))]
|
||||
#[stable(feature = "os", since = "1.0.0")]
|
||||
pub use imp::*;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
definitions"
|
||||
)]
|
||||
#![allow(deprecated)]
|
||||
#![allow(missing_debug_implementations)]
|
||||
|
||||
use crate::os::raw::{c_char, c_int, c_long, c_ulong, c_void};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,44 +27,43 @@
|
|||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
#![doc(cfg(unix))]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(doc)] {
|
||||
// Use linux as the default platform when documenting on other platforms like Windows
|
||||
use crate::os::linux as platform;
|
||||
} else {
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::os::android as platform;
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
use crate::os::dragonfly as platform;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
use crate::os::emscripten as platform;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
use crate::os::freebsd as platform;
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
use crate::os::fuchsia as platform;
|
||||
#[cfg(target_os = "haiku")]
|
||||
use crate::os::haiku as platform;
|
||||
#[cfg(target_os = "illumos")]
|
||||
use crate::os::illumos as platform;
|
||||
#[cfg(target_os = "ios")]
|
||||
use crate::os::ios as platform;
|
||||
#[cfg(any(target_os = "linux", target_os = "l4re"))]
|
||||
use crate::os::linux as platform;
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::os::macos as platform;
|
||||
#[cfg(target_os = "netbsd")]
|
||||
use crate::os::netbsd as platform;
|
||||
#[cfg(target_os = "openbsd")]
|
||||
use crate::os::openbsd as platform;
|
||||
#[cfg(target_os = "redox")]
|
||||
use crate::os::redox as platform;
|
||||
#[cfg(target_os = "solaris")]
|
||||
use crate::os::solaris as platform;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
use crate::os::vxworks as platform;
|
||||
}
|
||||
// Use linux as the default platform when documenting on other platforms like Windows
|
||||
#[cfg(doc)]
|
||||
use crate::os::linux as platform;
|
||||
|
||||
#[cfg(not(doc))]
|
||||
mod platform {
|
||||
#[cfg(target_os = "android")]
|
||||
pub use crate::os::android::*;
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
pub use crate::os::dragonfly::*;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
pub use crate::os::emscripten::*;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub use crate::os::freebsd::*;
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
pub use crate::os::fuchsia::*;
|
||||
#[cfg(target_os = "haiku")]
|
||||
pub use crate::os::haiku::*;
|
||||
#[cfg(target_os = "illumos")]
|
||||
pub use crate::os::illumos::*;
|
||||
#[cfg(target_os = "ios")]
|
||||
pub use crate::os::ios::*;
|
||||
#[cfg(any(target_os = "linux", target_os = "l4re"))]
|
||||
pub use crate::os::linux::*;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use crate::os::macos::*;
|
||||
#[cfg(target_os = "netbsd")]
|
||||
pub use crate::os::netbsd::*;
|
||||
#[cfg(target_os = "openbsd")]
|
||||
pub use crate::os::openbsd::*;
|
||||
#[cfg(target_os = "redox")]
|
||||
pub use crate::os::redox::*;
|
||||
#[cfg(target_os = "solaris")]
|
||||
pub use crate::os::solaris::*;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
pub use crate::os::vxworks::*;
|
||||
}
|
||||
|
||||
pub mod ffi;
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
//! WASI-specific definitions
|
||||
|
||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use crate::sys::ext::*;
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
//! }
|
||||
//! ```
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
#![doc(cfg(target_os = "wasi"))]
|
||||
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
#![doc(cfg(windows))]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub mod ffi;
|
||||
pub mod fs;
|
||||
|
|
@ -24,7 +24,6 @@ pub mod args;
|
|||
pub mod cmath;
|
||||
pub mod condvar;
|
||||
pub mod env;
|
||||
pub mod ext;
|
||||
pub mod fd;
|
||||
pub mod fs;
|
||||
#[path = "../unsupported/io.rs"]
|
||||
|
|
|
|||
|
|
@ -49,80 +49,27 @@ cfg_if::cfg_if! {
|
|||
}
|
||||
}
|
||||
|
||||
// Import essential modules from both platforms when documenting. These are
|
||||
// then later used in the `std::os` module when documenting, for example,
|
||||
// Windows when we're compiling for Linux.
|
||||
// Import essential modules from platforms used in `std::os` when documenting.
|
||||
//
|
||||
// Note that on some platforms those modules don't compile
|
||||
// (missing things in `libc` which is empty), so they are not included in `std::os` and can be
|
||||
// omitted here as well.
|
||||
|
||||
#[cfg(doc)]
|
||||
#[cfg(not(any(
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
all(target_vendor = "fortanix", target_env = "sgx")
|
||||
)))]
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
// On unix we'll document what's already available
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::ext as unix_ext;
|
||||
} else if #[cfg(any(target_os = "hermit",
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
all(target_vendor = "fortanix", target_env = "sgx")))] {
|
||||
// On non-WASI wasm right now the module below doesn't compile
|
||||
// (missing things in `libc` which is empty) so just omit everything
|
||||
// with an empty module
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
#[allow(missing_docs)]
|
||||
pub mod unix_ext {}
|
||||
} else {
|
||||
#[path = "unix/ext/mod.rs"]
|
||||
pub mod unix_ext;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(doc)]
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
// On windows we'll just be documenting what's already available
|
||||
#[allow(missing_docs)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::ext as windows_ext;
|
||||
} else if #[cfg(any(target_os = "hermit",
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
all(target_vendor = "fortanix", target_env = "sgx")))] {
|
||||
// On non-WASI wasm right now the shim below doesn't compile, so
|
||||
// just omit it
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
#[allow(missing_docs)]
|
||||
pub mod windows_ext {}
|
||||
} else {
|
||||
// On all other platforms (aka linux/osx/etc) then pull in a "minimal"
|
||||
if #[cfg(not(windows))] {
|
||||
// On non-Windows platforms (aka linux/osx/etc) pull in a "minimal"
|
||||
// amount of windows goop which ends up compiling
|
||||
|
||||
#[macro_use]
|
||||
#[path = "windows/compat.rs"]
|
||||
mod compat;
|
||||
pub mod compat;
|
||||
|
||||
#[path = "windows/c.rs"]
|
||||
mod c;
|
||||
|
||||
#[path = "windows/ext/mod.rs"]
|
||||
pub mod windows_ext;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(doc)]
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_os = "wasi")] {
|
||||
// On WASI we'll document what's already available
|
||||
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
|
||||
pub use self::ext as wasi_ext;
|
||||
} else if #[cfg(any(target_os = "hermit",
|
||||
target_arch = "wasm32",
|
||||
all(target_vendor = "fortanix", target_env = "sgx")))] {
|
||||
// On non-WASI wasm right now the module below doesn't compile
|
||||
// (missing things in `libc` which is empty) so just omit everything
|
||||
// with an empty module
|
||||
#[unstable(issue = "none", feature = "std_internals")]
|
||||
#[allow(missing_docs)]
|
||||
pub mod wasi_ext {}
|
||||
} else {
|
||||
// On other platforms like Windows document the bare bones of WASI
|
||||
#[path = "wasi/ext/mod.rs"]
|
||||
#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
|
||||
pub mod wasi_ext;
|
||||
pub mod c;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
#![unstable(feature = "sgx_platform", issue = "56975")]
|
||||
|
||||
pub mod arch;
|
||||
pub mod ffi;
|
||||
pub mod io;
|
||||
|
|
@ -17,7 +17,6 @@ pub mod args;
|
|||
pub mod cmath;
|
||||
pub mod condvar;
|
||||
pub mod env;
|
||||
pub mod ext;
|
||||
pub mod fd;
|
||||
#[path = "../unsupported/fs.rs"]
|
||||
pub mod fs;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub mod args;
|
|||
pub mod cmath;
|
||||
pub mod condvar;
|
||||
pub mod env;
|
||||
pub mod ext;
|
||||
pub mod fd;
|
||||
pub mod fs;
|
||||
pub mod futex;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ pub mod mutex;
|
|||
pub mod net;
|
||||
pub mod os;
|
||||
pub use crate::sys_common::os_str_bytes as os_str;
|
||||
pub mod ext;
|
||||
#[path = "../unix/path.rs"]
|
||||
pub mod path;
|
||||
#[path = "../unsupported/pipe.rs"]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ pub mod c;
|
|||
pub mod cmath;
|
||||
pub mod condvar;
|
||||
pub mod env;
|
||||
pub mod ext;
|
||||
pub mod fs;
|
||||
pub mod handle;
|
||||
pub mod io;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWri
|
|||
pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];
|
||||
pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
|
||||
pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"];
|
||||
pub const PERMISSIONS_FROM_MODE: [&str; 7] = ["std", "sys", "unix", "ext", "fs", "PermissionsExt", "from_mode"];
|
||||
pub const PERMISSIONS_FROM_MODE: [&str; 7] = ["std", "os", "imp", "unix", "fs", "PermissionsExt", "from_mode"];
|
||||
pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"];
|
||||
pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"];
|
||||
pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue