Skip to content

Commit

Permalink
Ignore libc mach_host_self and mach_task_self deprecations for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 26, 2024
1 parent 0862b6c commit 4ed3acb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
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
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 4ed3acb

Please sign in to comment.