mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
sort: remove nix from dep
This commit is contained in:
Generated
-1
@@ -4115,7 +4115,6 @@ dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"libc",
|
||||
"memchr",
|
||||
"nix",
|
||||
"rand 0.10.1",
|
||||
"rayon",
|
||||
"rustix",
|
||||
|
||||
Generated
-1
@@ -2012,7 +2012,6 @@ dependencies = [
|
||||
"itertools",
|
||||
"libc",
|
||||
"memchr",
|
||||
"nix",
|
||||
"rand",
|
||||
"rayon",
|
||||
"rustix",
|
||||
|
||||
@@ -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 }
|
||||
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user