core_foundation_sys/
mach_port.rs1use crate::base::{mach_port_t, Boolean};
11pub use crate::base::{CFAllocatorRef, CFIndex, CFTypeID};
12use crate::runloop::CFRunLoopSourceRef;
13use crate::string::CFStringRef;
14use std::os::raw::c_void;
15
16#[repr(C)]
17pub struct __CFMachPort(c_void);
18pub type CFMachPortRef = *mut __CFMachPort;
19
20pub type CFMachPortCallBack =
21 extern "C" fn(port: CFMachPortRef, msg: *mut c_void, size: CFIndex, info: *mut c_void);
22pub type CFMachPortInvalidationCallBack = extern "C" fn(port: CFMachPortRef, info: *mut c_void);
23
24#[repr(C)]
25#[derive(Clone, Copy)]
26pub struct CFMachPortContext {
27 pub version: CFIndex,
28 pub info: *mut c_void,
29 pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
30 pub release: extern "C" fn(info: *const c_void),
31 pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
32}
33
34extern "C" {
35 pub fn CFMachPortCreate(
41 allocator: CFAllocatorRef,
42 callout: CFMachPortCallBack,
43 context: *mut CFMachPortContext,
44 shouldFreeInfo: *mut Boolean,
45 ) -> CFMachPortRef;
46 pub fn CFMachPortCreateWithPort(
47 allocator: CFAllocatorRef,
48 portNum: mach_port_t,
49 callout: CFMachPortCallBack,
50 context: *mut CFMachPortContext,
51 shouldFreeInfo: *mut Boolean,
52 ) -> CFMachPortRef;
53
54 pub fn CFMachPortInvalidate(port: CFMachPortRef);
56 pub fn CFMachPortCreateRunLoopSource(
57 allocator: CFAllocatorRef,
58 port: CFMachPortRef,
59 order: CFIndex,
60 ) -> CFRunLoopSourceRef;
61 pub fn CFMachPortSetInvalidationCallBack(
62 port: CFMachPortRef,
63 callout: CFMachPortInvalidationCallBack,
64 );
65
66 pub fn CFMachPortGetContext(port: CFMachPortRef, context: *mut CFMachPortContext);
68 pub fn CFMachPortGetInvalidationCallBack(port: CFMachPortRef)
69 -> CFMachPortInvalidationCallBack;
70 pub fn CFMachPortGetPort(port: CFMachPortRef) -> mach_port_t;
71 pub fn CFMachPortIsValid(port: CFMachPortRef) -> Boolean;
72
73 pub fn CFMachPortGetTypeID() -> CFTypeID;
75}