From 13ea548fac7360a8026e168c8eda78ea6b9481c2 Mon Sep 17 00:00:00 2001 From: michaelwright235 Date: Mon, 29 May 2023 22:37:41 +0300 Subject: [PATCH] sys: mach_port: Add missing structures, funcs, etc --- core-foundation-sys/src/mach_port.rs | 50 +++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/core-foundation-sys/src/mach_port.rs b/core-foundation-sys/src/mach_port.rs index 2aece25..a25a44c 100644 --- a/core-foundation-sys/src/mach_port.rs +++ b/core-foundation-sys/src/mach_port.rs @@ -1,20 +1,54 @@ -use base::{CFAllocatorRef, CFIndex, CFTypeID}; +// Copyright 2023 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean, mach_port_t}; +use string::CFStringRef; use runloop::CFRunLoopSourceRef; use std::os::raw::c_void; #[repr(C)] pub struct __CFMachPort(c_void); -pub type CFMachPortRef = *const __CFMachPort; +pub type CFMachPortRef = *mut __CFMachPort; + +pub type CFMachPortCallBack = extern "C" fn (port: CFMachPortRef, msg: *mut c_void, size: CFIndex, info: *mut c_void); +pub type CFMachPortInvalidationCallBack = extern "C" fn (port: CFMachPortRef, info: *mut c_void); + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CFMachPortContext { + pub version: CFIndex, + pub info: *mut c_void, + pub retain: extern "C" fn (info: *const c_void) -> *const c_void, + pub release: extern "C" fn (info: *const c_void), + pub copyDescription: extern "C" fn (info: *const c_void) -> CFStringRef, +} extern "C" { /* * CFMachPort.h */ - pub fn CFMachPortCreateRunLoopSource( - allocator: CFAllocatorRef, - port: CFMachPortRef, - order: CFIndex, - ) -> CFRunLoopSourceRef; - + + /* Creating a CFMachPort Object */ + pub fn CFMachPortCreate(allocator: CFAllocatorRef, callout: CFMachPortCallBack, context: *mut CFMachPortContext, shouldFreeInfo: *mut Boolean) -> CFMachPortRef; + pub fn CFMachPortCreateWithPort(allocator: CFAllocatorRef, portNum: mach_port_t, callout: CFMachPortCallBack, context: *mut CFMachPortContext, shouldFreeInfo: *mut Boolean) -> CFMachPortRef; + + /* Configuring a CFMachPort Object */ + pub fn CFMachPortInvalidate(port: CFMachPortRef); + pub fn CFMachPortCreateRunLoopSource(allocator: CFAllocatorRef, port: CFMachPortRef, order: CFIndex) -> CFRunLoopSourceRef; + pub fn CFMachPortSetInvalidationCallBack(port: CFMachPortRef, callout: CFMachPortInvalidationCallBack); + + /* Examining a CFMachPort Object */ + pub fn CFMachPortGetContext(port: CFMachPortRef, context: *mut CFMachPortContext); + pub fn CFMachPortGetInvalidationCallBack(port: CFMachPortRef) -> CFMachPortInvalidationCallBack; + pub fn CFMachPortGetPort(port: CFMachPortRef) -> mach_port_t; + pub fn CFMachPortIsValid(port: CFMachPortRef) -> Boolean; + + /* Getting the CFMachPort Type ID */ pub fn CFMachPortGetTypeID() -> CFTypeID; }