1 | /* semaphore.h |
---|
2 | * |
---|
3 | * $Id$ |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef __POSIX_SEMAPHORE_h |
---|
7 | #define __POSIX_SEMAPHORE_h |
---|
8 | |
---|
9 | #ifdef __cplusplus |
---|
10 | extern "C" { |
---|
11 | #endif |
---|
12 | |
---|
13 | #include <sys/features.h> |
---|
14 | |
---|
15 | #if defined(_POSIX_SEMAPHORES) |
---|
16 | |
---|
17 | #include <sys/time.h> |
---|
18 | |
---|
19 | /* |
---|
20 | * 11.1 Semaphore Characteristics, P1003.1b-1993, p.219 |
---|
21 | */ |
---|
22 | |
---|
23 | typedef int sem_t; |
---|
24 | |
---|
25 | /* |
---|
26 | * 11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219 |
---|
27 | */ |
---|
28 | |
---|
29 | int sem_init( |
---|
30 | sem_t *sem, |
---|
31 | int pshared, |
---|
32 | unsigned int value |
---|
33 | ); |
---|
34 | |
---|
35 | /* |
---|
36 | * 11.2.2 Destroy an Unnamed Semaphore, P1003.1b-1993, p.220 |
---|
37 | */ |
---|
38 | |
---|
39 | int sem_destroy( |
---|
40 | sem_t *sem |
---|
41 | ); |
---|
42 | |
---|
43 | /* |
---|
44 | * 11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221 |
---|
45 | * |
---|
46 | * NOTE: Follows open() calling conventions. |
---|
47 | */ |
---|
48 | |
---|
49 | sem_t *sem_open( |
---|
50 | const char *name, |
---|
51 | int oflag, |
---|
52 | ... |
---|
53 | ); |
---|
54 | |
---|
55 | /* |
---|
56 | * 11.2.4 Close a Named Semaphore, P1003.1b-1993, p.224 |
---|
57 | */ |
---|
58 | |
---|
59 | int sem_close( |
---|
60 | sem_t *sem |
---|
61 | ); |
---|
62 | |
---|
63 | /* |
---|
64 | * 11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225 |
---|
65 | */ |
---|
66 | |
---|
67 | int sem_unlink( |
---|
68 | const char *name |
---|
69 | ); |
---|
70 | |
---|
71 | /* |
---|
72 | * 11.2.6 Lock a Semaphore, P1003.1b-1993, p.226 |
---|
73 | * |
---|
74 | * NOTE: P1003.4b/D8 adds sem_timedwait(), p. 27 |
---|
75 | */ |
---|
76 | |
---|
77 | int sem_wait( |
---|
78 | sem_t *sem |
---|
79 | ); |
---|
80 | |
---|
81 | int sem_trywait( |
---|
82 | sem_t *sem |
---|
83 | ); |
---|
84 | |
---|
85 | #if defined(_POSIX_TIMEOUTS) |
---|
86 | int sem_timedwait( |
---|
87 | sem_t *sem, |
---|
88 | const struct timespec *timeout |
---|
89 | ); |
---|
90 | #endif |
---|
91 | |
---|
92 | /* |
---|
93 | * 11.2.7 Unlock a Semaphore, P1003.1b-1993, p.227 |
---|
94 | */ |
---|
95 | |
---|
96 | int sem_post( |
---|
97 | sem_t *sem |
---|
98 | ); |
---|
99 | |
---|
100 | /* |
---|
101 | * 11.2.8 Get the Value of a Semaphore, P1003.1b-1993, p.229 |
---|
102 | */ |
---|
103 | |
---|
104 | int sem_getvalue( |
---|
105 | sem_t *sem, |
---|
106 | int *sval |
---|
107 | ); |
---|
108 | |
---|
109 | #endif /* _POSIX_SEMAPHORES */ |
---|
110 | |
---|
111 | #ifdef __cplusplus |
---|
112 | } |
---|
113 | #endif |
---|
114 | |
---|
115 | #endif |
---|
116 | /* end of include file */ |
---|