The OpenD Programming Language

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  */
14 module core.sys.darwin.mach.semaphore;
15 
16 version (OSX)
17     version = Darwin;
18 else version (iOS)
19     version = Darwin;
20 else version (TVOS)
21     version = Darwin;
22 else version (WatchOS)
23     version = Darwin;
24 
25 version (Darwin):
26 extern (C):
27 nothrow:
28 @nogc:
29 
30 public import core.sys.darwin.mach.kern_return;
31 public import core.sys.darwin.mach.port;
32 
33 alias mach_port_t   task_t;
34 alias mach_port_t   thread_t;
35 alias mach_port_t   semaphore_t;
36 alias int           sync_policy_t;
37 
38 alias int clock_res_t;
39 struct mach_timespec_t
40 {
41         uint        tv_sec;
42         clock_res_t     tv_nsec;
43 }
44 
45 enum
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 
55 task_t        mach_task_self();
56 kern_return_t semaphore_create(task_t, semaphore_t*, int, int);
57 kern_return_t semaphore_destroy(task_t, semaphore_t);
58 
59 kern_return_t semaphore_signal(semaphore_t);
60 kern_return_t semaphore_signal_all(semaphore_t);
61 kern_return_t semaphore_signal_thread(semaphore_t, thread_t);
62 
63 kern_return_t semaphore_wait(semaphore_t);
64 kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t);
65 
66 kern_return_t semaphore_timedwait(semaphore_t, mach_timespec_t);
67 kern_return_t semaphore_timedwait_signal(semaphore_t, semaphore_t, mach_timespec_t);