mirror of
https://github.com/uutils/procps.git
synced 2026-05-06 06:06:43 -04:00
Merge pull request #571 from Krysztal112233/chore/remove_libc
chore: remove `libc` use `uucore::libc` instead
This commit is contained in:
Generated
+222
-224
File diff suppressed because it is too large
Load Diff
+6
-3
@@ -61,7 +61,6 @@ crossterm = "0.29.0"
|
||||
ctor = "0.6.0"
|
||||
dirs = "6.0.0"
|
||||
jiff = "0.2.15"
|
||||
libc = "0.2.154"
|
||||
nix = { version = "0.30", default-features = false, features = ["process"] }
|
||||
phf = "0.13.1"
|
||||
phf_codegen = "0.13.0"
|
||||
@@ -115,12 +114,16 @@ watch = { optional = true, version = "0.0.1", package = "uu_watch", path = "src/
|
||||
[dev-dependencies]
|
||||
chrono = { workspace = true }
|
||||
ctor = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
pretty_assertions = "1.4.0"
|
||||
rand = { workspace = true }
|
||||
regex = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
uucore = { workspace = true, features = ["entries", "process", "signals"] }
|
||||
uucore = { workspace = true, features = [
|
||||
"entries",
|
||||
"libc",
|
||||
"process",
|
||||
"signals",
|
||||
] }
|
||||
uutests = { workspace = true }
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
|
||||
@@ -14,10 +14,9 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true, features = ["utmpx"] }
|
||||
uucore = { workspace = true, features = ["utmpx", "libc"] }
|
||||
clap = { workspace = true }
|
||||
chrono = { workspace = true, default-features = false, features = ["clock"] }
|
||||
libc = { workspace = true }
|
||||
prettytable-rs = { workspace = true }
|
||||
nix = { workspace = true }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use nix::errno::Errno;
|
||||
#[cfg(target_family = "unix")]
|
||||
fn getsid(pid: i32) -> Option<i32> {
|
||||
unsafe {
|
||||
let result = libc::getsid(pid);
|
||||
let result = uucore::libc::getsid(pid);
|
||||
if Errno::last() == Errno::UnknownErrno {
|
||||
Some(result)
|
||||
} else {
|
||||
|
||||
@@ -14,9 +14,8 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true, features = ["signals"] }
|
||||
uucore = { workspace = true, features = ["signals", "libc"] }
|
||||
clap = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
nix = { workspace = true }
|
||||
prettytable-rs = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -113,8 +113,8 @@ impl Display for ActionResult {
|
||||
/// But we don't know if the process of pid are exist, if [None], the process doesn't exist
|
||||
#[cfg(target_os = "linux")]
|
||||
fn set_priority(pid: u32, prio: &Priority, take_action: bool) -> Option<ActionResult> {
|
||||
use libc::{getpriority, setpriority, PRIO_PROCESS};
|
||||
use nix::errno::Errno;
|
||||
use uucore::libc::{getpriority, setpriority, PRIO_PROCESS};
|
||||
|
||||
// Very dirty.
|
||||
let current_priority = {
|
||||
|
||||
@@ -14,10 +14,9 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true, features = ["utmpx", "uptime", "signals"] }
|
||||
uucore = { workspace = true, features = ["utmpx", "uptime", "signals", "libc"] }
|
||||
clap = { workspace = true }
|
||||
crossterm = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
nix = { workspace = true }
|
||||
ratatui = { workspace = true, features = ["crossterm"] }
|
||||
sysinfo = { workspace = true }
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) fn renice(pid: u32, nice_value: i32) -> uucore::error::UResult<()> {
|
||||
use libc::{setpriority, PRIO_PROCESS};
|
||||
use uucore::error::USimpleError;
|
||||
use uucore::libc::{setpriority, PRIO_PROCESS};
|
||||
|
||||
let result = unsafe { setpriority(PRIO_PROCESS, pid, nice_value) };
|
||||
if result == -1 {
|
||||
|
||||
@@ -317,8 +317,8 @@ fn pr(_pid: u32, _stat: Stat) -> Box<dyn Column> {
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn get_nice(pid: u32) -> i32 {
|
||||
use libc::{getpriority, PRIO_PROCESS};
|
||||
use nix::errno::Errno;
|
||||
use uucore::libc::{getpriority, PRIO_PROCESS};
|
||||
|
||||
// this is nice value, not priority value
|
||||
let result = unsafe { getpriority(PRIO_PROCESS, pid) };
|
||||
@@ -381,7 +381,7 @@ fn shr(pid: u32, _stat: Stat) -> Box<dyn Column> {
|
||||
let content = read_to_string(file).unwrap();
|
||||
let values = content.split_whitespace();
|
||||
if let Some(shared) = values.collect::<Vec<_>>().get(2) {
|
||||
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) };
|
||||
let page_size = unsafe { uucore::libc::sysconf(uucore::libc::_SC_PAGESIZE) };
|
||||
MemValue::new_boxed(shared.parse::<u64>().unwrap() * page_size as u64)
|
||||
} else {
|
||||
MemValue::new_boxed(0)
|
||||
|
||||
@@ -8,12 +8,12 @@ use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
extern "C" {
|
||||
pub fn sd_booted() -> libc::c_int;
|
||||
pub fn sd_get_sessions(sessions: *mut *mut *mut libc::c_char) -> libc::c_int;
|
||||
pub fn sd_booted() -> uucore::libc::c_int;
|
||||
pub fn sd_get_sessions(sessions: *mut *mut *mut uucore::libc::c_char) -> uucore::libc::c_int;
|
||||
pub fn sd_session_get_class(
|
||||
session: *const libc::c_char,
|
||||
class: *mut *mut libc::c_char,
|
||||
) -> libc::c_int;
|
||||
session: *const uucore::libc::c_char,
|
||||
class: *mut *mut uucore::libc::c_char,
|
||||
) -> uucore::libc::c_int;
|
||||
}
|
||||
|
||||
pub fn get_nusers_systemd() -> uucore::error::UResult<usize> {
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn get_cpu_loads() -> Vec<uu_vmstat::CpuLoadRaw> {
|
||||
let status = unsafe {
|
||||
NtQuerySystemInformation(
|
||||
windows_sys::Wdk::System::SystemInformation::SystemProcessorPerformanceInformation,
|
||||
data.as_mut_ptr() as *mut libc::c_void,
|
||||
data.as_mut_ptr() as *mut uucore::libc::c_void,
|
||||
(n_cpu * size_of::<SystemProcessorPerformanceInformation>()) as u32,
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
|
||||
+2
-5
@@ -14,12 +14,9 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true, features = ["utmpx", "uptime"] }
|
||||
uucore = { workspace = true, features = ["utmpx", "uptime", "libc"] }
|
||||
clap = { workspace = true }
|
||||
chrono = { workspace = true, default-features = false, features = [
|
||||
"clock",
|
||||
] }
|
||||
libc = { workspace = true }
|
||||
chrono = { workspace = true, default-features = false, features = ["clock"] }
|
||||
|
||||
[lib]
|
||||
path = "src/w.rs"
|
||||
|
||||
+2
-2
@@ -8,10 +8,10 @@ use chrono::{Datelike, Local};
|
||||
use clap::crate_version;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
#[cfg(target_os = "linux")]
|
||||
use libc::{sysconf, _SC_CLK_TCK};
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::{collections::HashMap, fs, path::Path, time::SystemTime};
|
||||
use std::{process, time::Duration};
|
||||
#[cfg(target_os = "linux")]
|
||||
use uucore::libc::{sysconf, _SC_CLK_TCK};
|
||||
use uucore::uptime::{
|
||||
get_formatted_loadavg, get_formatted_nusers, get_formatted_time, get_uptime, UptimeError,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user