From 8602c054b540b52275c0311624bf432f0eb749cf Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 25 Nov 2024 19:03:57 -0800 Subject: [PATCH 1/2] Deal with libc 0.2.165's removal of array size hacks --- Cargo.toml | 2 +- src/unix/apple/macos/process.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 249e90dab..4b54787f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/unix/apple/macos/process.rs b/src/unix/apple/macos/process.rs index 08a33dd1b..e39694299 100644 --- a/src/unix/apple/macos/process.rs +++ b/src/unix/apple/macos/process.rs @@ -433,7 +433,7 @@ unsafe fn convert_node_path_info(node: &libc::vnode_info_path) -> Option Date: Mon, 25 Nov 2024 19:10:43 -0800 Subject: [PATCH 2/2] Ignore libc mach_host_self and mach_task_self deprecations for now --- src/unix/apple/cpu.rs | 5 ++++- src/unix/apple/macos/component/x86.rs | 8 +++++++- src/unix/apple/macos/system.rs | 1 + src/unix/apple/system.rs | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/unix/apple/cpu.rs b/src/unix/apple/cpu.rs index 7fd63ef84..c366cba4d 100644 --- a/src/unix/apple/cpu.rs +++ b/src/unix/apple/cpu.rs @@ -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; @@ -97,6 +99,7 @@ impl Drop for CpuData { let prev_cpu_info_size = std::mem::size_of::() 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 _, diff --git a/src/unix/apple/macos/component/x86.rs b/src/unix/apple/macos/component/x86.rs index ef34329ae..51aca60a8 100644 --- a/src/unix/apple/macos/component/x86.rs +++ b/src/unix/apple/macos/component/x86.rs @@ -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; diff --git a/src/unix/apple/macos/system.rs b/src/unix/apple/macos/system.rs index 6c182ae1f..e2c934982 100644 --- a/src/unix/apple/macos/system.rs +++ b/src/unix/apple/macos/system.rs @@ -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); diff --git a/src/unix/apple/system.rs b/src/unix/apple/system.rs index 44406f623..6062f9e0a 100644 --- a/src/unix/apple/system.rs +++ b/src/unix/apple/system.rs @@ -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 {