Skip to content

Commit

Permalink
Merge pull request #1201 from GuillaumeGomez/update-deps
Browse files Browse the repository at this point in the history
Update dependencies and use PF_KTHREAD from libc
  • Loading branch information
GuillaumeGomez committed Jan 31, 2024
2 parents 43a1246 + 790273a commit 31665aa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 58 deletions.
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

0 comments on commit 31665aa

Please sign in to comment.