@@ -20,9 +20,20 @@ cfg_if! {
2020 use io_kit_sys:: serial:: keys:: * ;
2121 use io_kit_sys:: types:: * ;
2222 use io_kit_sys:: usb:: lib:: * ;
23- use nix:: libc:: { c_char, c_void} ;
24- use std:: ffi:: CStr ;
25- use std:: mem:: MaybeUninit ;
23+ use core:: ffi:: { c_char, c_int, c_uint, c_void, CStr } ;
24+ use core:: mem:: MaybeUninit ;
25+
26+ // NOTE: Do not use `mach` nor `mach2` crates, they're unmaintained,
27+ // and don't work on tvOS/watchOS/visionOS.
28+ //
29+ // Instead, define the types ourselves, we use sufficiently little
30+ // that this is not a very hard task.
31+ #[ allow( non_camel_case_types) ]
32+ type kern_return_t = c_int;
33+ #[ allow( non_camel_case_types) ]
34+ type mach_port_t = c_uint;
35+ const KERN_SUCCESS : kern_return_t = 0 ;
36+ const MACH_PORT_NULL : mach_port_t = 0 ;
2637 }
2738}
2839
@@ -265,7 +276,6 @@ fn get_parent_device_by_type(
265276 parent_type : * const c_char ,
266277) -> Option < io_registry_entry_t > {
267278 let parent_type = unsafe { CStr :: from_ptr ( parent_type) } ;
268- use mach2:: kern_return:: KERN_SUCCESS ;
269279 let mut device = device;
270280 loop {
271281 let mut class_name = MaybeUninit :: < [ c_char ; 128 ] > :: uninit ( ) ;
@@ -379,9 +389,6 @@ cfg_if! {
379389 /// Scans the system for serial ports and returns a list of them.
380390 /// The `SerialPortInfo` struct contains the name of the port which can be used for opening it.
381391 pub fn available_ports( ) -> Result <Vec <SerialPortInfo >> {
382- use mach2:: kern_return:: KERN_SUCCESS ;
383- use mach2:: port:: { mach_port_t, MACH_PORT_NULL } ;
384-
385392 let mut vec = Vec :: new( ) ;
386393 unsafe {
387394 // Create a dictionary for specifying the search terms against the IOService
0 commit comments