comparison druntime/import/core/sys/posix/semaphore.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.sys.posix.semaphore;
15
16 private import core.sys.posix.config;
17 private import core.sys.posix.time;
18
19 extern (C):
20
21 //
22 // Required
23 //
24 /*
25 sem_t
26 SEM_FAILED
27
28 int sem_close(sem_t*);
29 int sem_destroy(sem_t*);
30 int sem_getvalue(sem_t*, int*);
31 int sem_init(sem_t*, int, uint);
32 sem_t* sem_open(in char*, int, ...);
33 int sem_post(sem_t*);
34 int sem_trywait(sem_t*);
35 int sem_unlink(in char*);
36 int sem_wait(sem_t*);
37 */
38
39 version( linux )
40 {
41 private alias int __atomic_lock_t;
42
43 private struct _pthread_fastlock
44 {
45 c_long __status;
46 __atomic_lock_t __spinlock;
47 }
48
49 struct sem_t
50 {
51 _pthread_fastlock __sem_lock;
52 int __sem_value;
53 void* __sem_waiting;
54 }
55
56 enum SEM_FAILED = cast(sem_t*) null;
57 }
58 else version( OSX )
59 {
60 alias int sem_t;
61
62 enum SEM_FAILED = cast(sem_t*) null;
63 }
64 else version( freebsd )
65 {
66 enum SEM_MAGIC = 0x09fa4012;
67 enum SEM_USER = 0;
68
69 alias void* sem_t;
70
71 enum SEM_FAILED = cast(sem_t*) null;
72 }
73
74 int sem_close(sem_t*);
75 int sem_destroy(sem_t*);
76 int sem_getvalue(sem_t*, int*);
77 int sem_init(sem_t*, int, uint);
78 sem_t* sem_open(in char*, int, ...);
79 int sem_post(sem_t*);
80 int sem_trywait(sem_t*);
81 int sem_unlink(in char*);
82 int sem_wait(sem_t*);
83
84 //
85 // Timeouts (TMO)
86 //
87 /*
88 int sem_timedwait(sem_t*, in timespec*);
89 */
90
91 version( linux )
92 {
93 int sem_timedwait(sem_t*, in timespec*);
94 }
95 else version( OSX )
96 {
97 int sem_timedwait(sem_t*, in timespec*);
98 }
99 else version( freebsd )
100 {
101 int sem_timedwait(sem_t*, in timespec*);
102 }