aboutsummaryrefslogtreecommitdiffstats
path: root/code/platform_mac/mac_semaphore_wrapper.h
blob: 9404cda9ca79f01007bc218f0e5e79f7682c936b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Mr. 4th Dimention - Allen Webster
 *
 * 07.11.2017
 *
 * Mac semaphore wrapper
 *
 */

// TOP

union Semaphore{
    semaphore_t s;
    FixSize(SEMAPHORE_TYPE_SIZE);
};

internal void
system_init_semaphore(Semaphore *s, u32 count){
    task_t task = mach_task_self();
    semaphore_create(task, &s->s, SYNC_POLICY_FIFO, 0);
}

internal void
system_wait_on_semaphore(Semaphore *s){
    semaphore_wait(s->s);
}

internal void
system_release_semaphore(Semaphore *s){
    semaphore_signal(s->s);
}

// BOTTOM