sort: remove nix from dep

This commit is contained in:
oech3
2026-05-19 09:13:00 +02:00
committed by Daniel Hofstetter
parent a9cf501870
commit 3a4de968d7
4 changed files with 8 additions and 38 deletions
Generated
-1
View File
@@ -4115,7 +4115,6 @@ dependencies = [
"itertools 0.14.0",
"libc",
"memchr",
"nix",
"rand 0.10.1",
"rayon",
"rustix",
-1
View File
@@ -2012,7 +2012,6 @@ dependencies = [
"itertools",
"libc",
"memchr",
"nix",
"rand",
"rayon",
"rustix",
+1 -4
View File
@@ -48,14 +48,11 @@ fluent = { workspace = true }
foldhash = { workspace = true }
[target.'cfg(all(unix, not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku", target_os = "solaris", target_os = "illumos"))))'.dependencies]
rustix = { workspace = true, features = ["process"] }
rustix = { workspace = true, features = ["system", "process"] }
[target.'cfg(not(any(target_os = "redox", target_os = "wasi")))'.dependencies]
ctrlc = { workspace = true }
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
nix = { workspace = true }
[target.'cfg(unix)'.dependencies]
libc = { workspace = true }
+7 -32
View File
@@ -83,48 +83,23 @@ fn desired_file_buffer_bytes(total_bytes: u128) -> u128 {
quarter.max(max)
}
#[allow(
clippy::unnecessary_wraps,
reason = "fn sig must match on all platforms"
)]
fn physical_memory_bytes() -> Option<u128> {
#[cfg(all(
target_family = "unix",
not(target_os = "redox"),
any(target_os = "linux", target_os = "android")
))]
#[cfg(any(target_os = "linux", target_os = "android"))]
{
physical_memory_bytes_unix()
Some(rustix::system::sysinfo().totalram as u128)
}
#[cfg(any(
not(target_family = "unix"),
target_os = "redox",
not(any(target_os = "linux", target_os = "android"))
))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
{
// No portable or safe API is available here to detect total physical memory.
None
}
}
#[cfg(all(
target_family = "unix",
not(target_os = "redox"),
any(target_os = "linux", target_os = "android")
))]
fn physical_memory_bytes_unix() -> Option<u128> {
use nix::unistd::{SysconfVar, sysconf};
let pages = match sysconf(SysconfVar::_PHYS_PAGES) {
Ok(Some(pages)) if pages > 0 => u128::try_from(pages).ok()?,
_ => return None,
};
let page_size = match sysconf(SysconfVar::PAGE_SIZE) {
Ok(Some(page_size)) if page_size > 0 => u128::try_from(page_size).ok()?,
_ => return None,
};
Some(pages.saturating_mul(page_size))
}
#[cfg(test)]
mod tests {
use super::*;