Skip to content

Commit 3a4de96

Browse files
oech3cakebaker
authored andcommitted
sort: remove nix from dep
1 parent a9cf501 commit 3a4de96

4 files changed

Lines changed: 8 additions & 38 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fuzz/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/sort/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,11 @@ fluent = { workspace = true }
4848
foldhash = { workspace = true }
4949

5050
[target.'cfg(all(unix, not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku", target_os = "solaris", target_os = "illumos"))))'.dependencies]
51-
rustix = { workspace = true, features = ["process"] }
51+
rustix = { workspace = true, features = ["system", "process"] }
5252

5353
[target.'cfg(not(any(target_os = "redox", target_os = "wasi")))'.dependencies]
5454
ctrlc = { workspace = true }
5555

56-
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
57-
nix = { workspace = true }
58-
5956
[target.'cfg(unix)'.dependencies]
6057
libc = { workspace = true }
6158

src/uu/sort/src/buffer_hint.rs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,48 +83,23 @@ fn desired_file_buffer_bytes(total_bytes: u128) -> u128 {
8383
quarter.max(max)
8484
}
8585

86+
#[allow(
87+
clippy::unnecessary_wraps,
88+
reason = "fn sig must match on all platforms"
89+
)]
8690
fn physical_memory_bytes() -> Option<u128> {
87-
#[cfg(all(
88-
target_family = "unix",
89-
not(target_os = "redox"),
90-
any(target_os = "linux", target_os = "android")
91-
))]
91+
#[cfg(any(target_os = "linux", target_os = "android"))]
9292
{
93-
physical_memory_bytes_unix()
93+
Some(rustix::system::sysinfo().totalram as u128)
9494
}
9595

96-
#[cfg(any(
97-
not(target_family = "unix"),
98-
target_os = "redox",
99-
not(any(target_os = "linux", target_os = "android"))
100-
))]
96+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10197
{
10298
// No portable or safe API is available here to detect total physical memory.
10399
None
104100
}
105101
}
106102

107-
#[cfg(all(
108-
target_family = "unix",
109-
not(target_os = "redox"),
110-
any(target_os = "linux", target_os = "android")
111-
))]
112-
fn physical_memory_bytes_unix() -> Option<u128> {
113-
use nix::unistd::{SysconfVar, sysconf};
114-
115-
let pages = match sysconf(SysconfVar::_PHYS_PAGES) {
116-
Ok(Some(pages)) if pages > 0 => u128::try_from(pages).ok()?,
117-
_ => return None,
118-
};
119-
120-
let page_size = match sysconf(SysconfVar::PAGE_SIZE) {
121-
Ok(Some(page_size)) if page_size > 0 => u128::try_from(page_size).ok()?,
122-
_ => return None,
123-
};
124-
125-
Some(pages.saturating_mul(page_size))
126-
}
127-
128103
#[cfg(test)]
129104
mod tests {
130105
use super::*;

0 commit comments

Comments
 (0)