diff --git a/Cargo.toml b/Cargo.toml index 806bfe520..a70092d0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,7 +106,7 @@ windows = { version = ">=0.54, <=0.57", optional = true } libc = "^0.2.153" [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] -core-foundation-sys = "0.8" +core-foundation-sys = "0.8.7" [target.'cfg(all(target_os = "linux", not(target_os = "android")))'.dev-dependencies] tempfile = "3.9" diff --git a/src/unix/apple/macos/cpu.rs b/src/unix/apple/macos/cpu.rs index e96c2972f..974f4d0b7 100644 --- a/src/unix/apple/macos/cpu.rs +++ b/src/unix/apple/macos/cpu.rs @@ -10,6 +10,7 @@ pub(crate) unsafe fn get_cpu_frequency() -> u64 { use crate::sys::ffi; use crate::sys::macos::utils::IOReleaser; use crate::sys::utils::CFReleaser; + use core_foundation_sys::string::CFStringCreateWithCStringNoCopy; let matching = ffi::IOServiceMatching(b"AppleARMIODevice\0".as_ptr() as *const _); if matching.is_null() { @@ -54,7 +55,7 @@ pub(crate) unsafe fn get_cpu_frequency() -> u64 { } }; - let node_name = match CFReleaser::new(ffi::CFStringCreateWithCStringNoCopy( + let node_name = match CFReleaser::new(CFStringCreateWithCStringNoCopy( std::ptr::null(), b"voltage-states5-sram\0".as_ptr() as *const _, core_foundation_sys::string::kCFStringEncodingUTF8, diff --git a/src/unix/apple/macos/ffi.rs b/src/unix/apple/macos/ffi.rs index 3e0dfc6e0..d62339be4 100644 --- a/src/unix/apple/macos/ffi.rs +++ b/src/unix/apple/macos/ffi.rs @@ -1,5 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(any(feature = "system", feature = "disk"))] use core_foundation_sys::base::CFAllocatorRef; #[cfg(any( feature = "system", @@ -15,6 +16,7 @@ use core_foundation_sys::dictionary::CFDictionaryRef; all(feature = "component", any(target_arch = "x86", target_arch = "x86_64")), ))] use core_foundation_sys::dictionary::CFMutableDictionaryRef; +#[cfg(any(feature = "system", feature = "disk"))] use core_foundation_sys::string::CFStringRef; use libc::c_char; @@ -144,17 +146,6 @@ extern "C" { ))] pub const KIO_RETURN_SUCCESS: i32 = 0; -extern "C" { - // FIXME: to be removed once higher version than core_foundation_sys 0.8.4 is released. - #[allow(dead_code)] - pub fn CFStringCreateWithCStringNoCopy( - alloc: CFAllocatorRef, - cStr: *const c_char, - encoding: core_foundation_sys::string::CFStringEncoding, - contentsDeallocator: CFAllocatorRef, - ) -> CFStringRef; -} - #[cfg(all( not(feature = "apple-sandbox"), all( @@ -262,7 +253,6 @@ pub use io_service::*; mod io_service { use std::ptr::null; - use super::CFStringCreateWithCStringNoCopy; use core_foundation_sys::array::CFArrayRef; use core_foundation_sys::base::{CFAllocatorRef, CFRelease}; use core_foundation_sys::dictionary::{ @@ -270,7 +260,7 @@ mod io_service { CFDictionaryRef, }; use core_foundation_sys::number::{kCFNumberSInt32Type, CFNumberCreate}; - use core_foundation_sys::string::CFStringRef; + use core_foundation_sys::string::{CFStringCreateWithCStringNoCopy, CFStringRef}; #[repr(C)] pub struct __IOHIDServiceClient(libc::c_void);