Skip to content

Commit

Permalink
Merge pull request #1394 from GuillaumeGomez/update-0.32
Browse files Browse the repository at this point in the history
Backport libc fix on 0.32
  • Loading branch information
GuillaumeGomez authored Nov 26, 2024
2 parents e022ae4 + d2d2ebd commit 2542e1e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ntapi = { version = "0.4", optional = true }
windows = { version = ">=0.54, <=0.57", optional = true }

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

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

use libc::{c_char, c_void, host_processor_info, mach_port_t, mach_task_self};
#[allow(deprecated)]
use libc::mach_task_self;
use libc::{c_char, c_void, host_processor_info, mach_port_t};
use std::mem;
use std::ops::Deref;
use std::sync::Arc;
Expand Down Expand Up @@ -97,6 +99,7 @@ impl Drop for CpuData {
let prev_cpu_info_size = std::mem::size_of::<i32>() as u32 * self.num_cpu_info;
unsafe {
libc::vm_deallocate(
#[allow(deprecated)]
mach_task_self(),
self.cpu_info.0 as _,
prev_cpu_info_size as _,
Expand Down
8 changes: 7 additions & 1 deletion src/unix/apple/macos/component/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,13 @@ impl IoService {
};

let mut conn = 0;
let result = ffi::IOServiceOpen(device.inner(), libc::mach_task_self(), 0, &mut conn);
let result = ffi::IOServiceOpen(
device.inner(),
#[allow(deprecated)]
libc::mach_task_self(),
0,
&mut conn,
);
if result != ffi::KIO_RETURN_SUCCESS {
sysinfo_debug!("Error: IOServiceOpen() = {}", result);
return None;
Expand Down
2 changes: 1 addition & 1 deletion src/unix/apple/macos/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ unsafe fn convert_node_path_info(node: &libc::vnode_info_path) -> Option<PathBuf
}
cstr_to_rust_with_size(
node.vip_path.as_ptr() as _,
Some(node.vip_path.len() * node.vip_path[0].len()),
Some(mem::size_of_val(&node.vip_path)),
)
.map(PathBuf::from)
}
Expand Down
1 change: 1 addition & 0 deletions src/unix/apple/macos/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ mod test {
return;
}

#[allow(deprecated)]
let port = unsafe { libc::mach_host_self() };
let mut info = SystemTimeInfo::new(port).unwrap();
info.get_time_interval(port);
Expand Down
1 change: 1 addition & 0 deletions src/unix/apple/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn get_now() -> u64 {
impl SystemInner {
pub(crate) fn new() -> Self {
unsafe {
#[allow(deprecated)]
let port = libc::mach_host_self();

Self {
Expand Down

0 comments on commit 2542e1e

Please sign in to comment.