Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mach-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ fn main() {
});

cfg.skip_fn(move |s| {
// FIXME: The return type of these functions are different in Xcode 13 or higher.
if s.starts_with("semaphore") {
return true;
}
match s {
// mac_task_self and current_tasl are not functions, but macro that map to the
// mask_task_self_ static variable:
Expand Down
2 changes: 2 additions & 0 deletions mach-test/test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use mach2::memory_object_types::*;
use mach2::message::*;
use mach2::ndr::*;
use mach2::port::*;
use mach2::semaphore::*;
use mach2::structs::*;
use mach2::sync_policy::*;
use mach2::task::*;
use mach2::task_info::*;
use mach2::thread_act::*;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub mod memory_object_types;
pub mod message;
pub mod ndr;
pub mod port;
pub mod semaphore;
pub mod structs;
pub mod sync_policy;
pub mod task;
pub mod task_info;
pub mod thread_act;
Expand Down
22 changes: 22 additions & 0 deletions src/semaphore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! This module corresponds to `mach/semaphore.h`

use clock_types::mach_timespec_t;
use kern_return::kern_return_t;
use mach_types::{semaphore_t, task_t};
use sync_policy::sync_policy_t;

extern "C" {
pub fn semaphore_create(
task: task_t,
semaphore: *mut semaphore_t,
policy: sync_policy_t,
value: libc::c_int,
) -> kern_return_t;
pub fn semaphore_signal(semaphore: *mut semaphore_t) -> kern_return_t;
pub fn semaphore_wait(semaphore: *mut semaphore_t) -> kern_return_t;
pub fn semaphore_timedwait(
semaphore: *mut semaphore_t,
timeout: mach_timespec_t,
) -> kern_return_t;
pub fn semaphore_destroy(task: task_t, semaphore: *mut semaphore_t) -> kern_return_t;
}
9 changes: 9 additions & 0 deletions src/sync_policy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! This module corresponds to `mach/sync_policy.h`

pub type sync_policy_t = libc::c_int;

pub const SYNC_POLICY_FIFO: sync_policy_t = 0x0;
pub const SYNC_POLICY_FIXED_PRIORITY: sync_policy_t = 0x1;
pub const SYNC_POLICY_REVERSED: sync_policy_t = 0x2;
pub const SYNC_POLICY_ORDER_MASK: sync_policy_t = 0x3;
pub const SYNC_POLICY_LIFO: sync_policy_t = SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED;