Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and use PF_KTHREAD from libc #1201

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 31 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ windows = { version = "0.52", features = [
]}

[target.'cfg(not(any(target_os = "unknown", target_arch = "wasm32")))'.dependencies]
libc = "^0.2.150"
libc = "^0.2.153"

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
core-foundation-sys = "0.8"
Expand Down
4 changes: 4 additions & 0 deletions src/unix/apple/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::sys::utils::{get_sys_value, get_sys_value_by_name};

use crate::{Cpu, CpuRefreshKind, LoadAvg, MemoryRefreshKind, Pid, Process, ProcessRefreshKind};

#[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))]
use std::cell::UnsafeCell;
use std::collections::HashMap;
use std::ffi::CStr;
Expand Down Expand Up @@ -34,9 +35,12 @@ pub(crate) struct SystemInner {
cpus: CpusWrapper,
}

#[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))]
pub(crate) struct Wrap<'a>(pub UnsafeCell<&'a mut HashMap<Pid, Process>>);

#[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))]
unsafe impl<'a> Send for Wrap<'a> {}
#[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))]
unsafe impl<'a> Sync for Wrap<'a> {}

fn boot_time() -> u64 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ enum TermalSensorType {
IntelPECI,
/// Not all types are supported by all chips so we keep space for
/// unknown sensors.
#[allow(dead_code)]
Unknown(u8),
}

Expand Down
5 changes: 1 addition & 4 deletions src/unix/linux/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ enum ProcIndex {
// More exist but we only use the listed ones. For more, take a look at `man proc`.
}

/* Not exposed yet. Defined at include/linux/sched.h */
const PF_KTHREAD: c_ulong = 0x00200000;

pub(crate) struct ProcessInner {
pub(crate) name: String,
pub(crate) cmd: Vec<String>,
Expand Down Expand Up @@ -461,7 +458,7 @@ fn retrieve_all_new_process_info(

p.name = name.into();
if c_ulong::from_str(parts[ProcIndex::Flags as usize])
.map(|flags| flags & PF_KTHREAD != 0)
.map(|flags| flags & libc::PF_KTHREAD as c_ulong != 0)
.unwrap_or(false)
{
p.thread_kind = Some(ThreadKind::Kernel);
Expand Down
Loading