2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Sean Kelly, Alex Rønne Petersen
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
15 module core.sys.posix.semaphore;
17 import core.sys.posix.config;
18 import core.sys.posix.time;
26 else version (WatchOS)
42 int sem_close(sem_t*);
43 int sem_destroy(sem_t*);
44 int sem_getvalue(sem_t*, int*);
45 int sem_init(sem_t*, int, uint);
46 sem_t* sem_open(const scope char*, int, ...);
48 int sem_trywait(sem_t*);
49 int sem_unlink(const scope char*);
53 version (CRuntime_Glibc)
55 private alias int __atomic_lock_t;
57 private struct _pthread_fastlock
60 __atomic_lock_t __spinlock;
65 _pthread_fastlock __sem_lock;
70 enum SEM_FAILED = cast(sem_t*) null;
76 enum SEM_FAILED = cast(sem_t*) null;
78 else version (FreeBSD)
80 // FBSD-9.0 definition
86 shared uint _has_waiters;
92 enum SEM_FAILED = cast(sem_t*) null;
98 enum SEM_FAILED = cast(sem_t*) null;
100 else version (OpenBSD)
103 alias sem_t = __sem*;
105 enum SEM_FAILED = cast(sem_t*) null;
107 else version (DragonFlyBSD)
114 shared uint _has_waiters;
120 enum SEM_FAILED = cast(sem_t*) null;
122 else version (Solaris)
133 enum SEM_FAILED = cast(sem_t*)-1;
135 else version (CRuntime_Bionic)
139 uint count; //volatile
142 enum SEM_FAILED = null;
144 else version (CRuntime_Musl)
147 int[4*c_long.sizeof/int.sizeof] __val;
150 enum SEM_FAILED = (sem_t*).init;
152 else version (CRuntime_UClibc)
154 enum __SIZEOF_SEM_T = 16;
158 byte[__SIZEOF_SEM_T] __size;
162 enum SEM_FAILED = cast(sem_t*) null;
166 static assert(false, "Unsupported platform");
169 int sem_close(sem_t*);
170 int sem_destroy(sem_t*);
171 int sem_getvalue(sem_t*, int*);
172 int sem_init(sem_t*, int, uint);
173 sem_t* sem_open(const scope char*, int, ...);
174 int sem_post(sem_t*);
175 int sem_trywait(sem_t*);
176 int sem_unlink(const scope char*);
177 int sem_wait(sem_t*);
183 int sem_timedwait(sem_t*, const scope timespec*);
186 version (CRuntime_Glibc)
188 int sem_timedwait(sem_t*, const scope timespec*);
190 else version (Darwin)
192 int sem_timedwait(sem_t*, const scope timespec*);
194 else version (FreeBSD)
196 int sem_timedwait(sem_t*, const scope timespec*);
198 else version (NetBSD)
200 int sem_timedwait(sem_t*, const scope timespec*);
202 else version (OpenBSD)
204 int sem_timedwait(sem_t*, const scope timespec*);
206 else version (DragonFlyBSD)
208 int sem_timedwait(sem_t*, const scope timespec*);
210 else version (Solaris)
212 int sem_timedwait(sem_t*, const scope timespec*);
214 else version (CRuntime_Bionic)
216 int sem_timedwait(sem_t*, const scope timespec*);
218 else version (CRuntime_Musl)
220 int sem_timedwait(sem_t*, const scope timespec*);
222 else version (CRuntime_UClibc)
224 int sem_timedwait(sem_t*, const scope timespec*);
228 static assert(false, "Unsupported platform");