1/**
2 * D header file for Darwin.
3 *
4 * Copyright: Copyright Sean Kelly 2008 - 2009.
5 * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors:   Sean Kelly
7 */
8
9/*          Copyright Sean Kelly 2008 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 *    (See accompanying file LICENSE or copy at
12 *          http://www.boost.org/LICENSE_1_0.txt)
13 */
14module core.sys.darwin.mach.semaphore;
15
16version (OSX)
17    version = Darwin;
18else version (iOS)
19    version = Darwin;
20else version (TVOS)
21    version = Darwin;
22else version (WatchOS)
23    version = Darwin;
24
25version (Darwin):
26extern (C):
27nothrow:
28@nogc:
29
30public import core.sys.darwin.mach.kern_return;
31public import core.sys.darwin.mach.port;
32
33alias mach_port_t   task_t;
34alias mach_port_t   thread_t;
35alias mach_port_t   semaphore_t;
36alias int           sync_policy_t;
37
38alias int clock_res_t;
39struct mach_timespec_t
40{
41        uint        tv_sec;
42        clock_res_t     tv_nsec;
43}
44
45enum
46{
47    SYNC_POLICY_FIFO            = 0x0,
48    SYNC_POLICY_FIXED_PRIORITY  = 0x1,
49    SYNC_POLICY_REVERSED        = 0x2,
50    SYNC_POLICY_ORDER_MASK      = 0x3,
51    SYNC_POLICY_LIFO            = (SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED),
52    SYNC_POLICY_MAX                         = 0x7,
53}
54
55task_t        mach_task_self();
56kern_return_t semaphore_create(task_t, semaphore_t*, int, int);
57kern_return_t semaphore_destroy(task_t, semaphore_t);
58
59kern_return_t semaphore_signal(semaphore_t);
60kern_return_t semaphore_signal_all(semaphore_t);
61kern_return_t semaphore_signal_thread(semaphore_t, thread_t);
62
63kern_return_t semaphore_wait(semaphore_t);
64kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t);
65
66kern_return_t semaphore_timedwait(semaphore_t, mach_timespec_t);
67kern_return_t semaphore_timedwait_signal(semaphore_t, semaphore_t, mach_timespec_t);
68