1 | /** |
---|
2 | * @file semaphore.h |
---|
3 | * |
---|
4 | * This file contains definitions that are internal to the RTEMS |
---|
5 | * implementation of POSIX Semaphores. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _SEMAPHORE_H |
---|
20 | #define _SEMAPHORE_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <unistd.h> |
---|
27 | |
---|
28 | #if defined(_POSIX_SEMAPHORES) |
---|
29 | |
---|
30 | #include <sys/time.h> |
---|
31 | |
---|
32 | /* |
---|
33 | * 11.1 Semaphore Characteristics, P1003.1b-1993, p.219 |
---|
34 | */ |
---|
35 | typedef int sem_t; |
---|
36 | |
---|
37 | /* |
---|
38 | * Bad semaphore Id |
---|
39 | */ |
---|
40 | #define SEM_FAILED (sem_t *) -1 |
---|
41 | |
---|
42 | /* |
---|
43 | * 11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219 |
---|
44 | */ |
---|
45 | int sem_init( |
---|
46 | sem_t *sem, |
---|
47 | int pshared, |
---|
48 | unsigned int value |
---|
49 | ); |
---|
50 | |
---|
51 | /* |
---|
52 | * 11.2.2 Destroy an Unnamed Semaphore, P1003.1b-1993, p.220 |
---|
53 | */ |
---|
54 | int sem_destroy( |
---|
55 | sem_t *sem |
---|
56 | ); |
---|
57 | |
---|
58 | /* |
---|
59 | * 11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221 |
---|
60 | * |
---|
61 | * NOTE: Follows open() calling conventions. |
---|
62 | */ |
---|
63 | sem_t *sem_open( |
---|
64 | const char *name, |
---|
65 | int oflag, |
---|
66 | ... |
---|
67 | ); |
---|
68 | |
---|
69 | /* |
---|
70 | * 11.2.4 Close a Named Semaphore, P1003.1b-1993, p.224 |
---|
71 | */ |
---|
72 | int sem_close( |
---|
73 | sem_t *sem |
---|
74 | ); |
---|
75 | |
---|
76 | /* |
---|
77 | * 11.2.5 Remove a Named Semaphore, P1003.1b-1993, p.225 |
---|
78 | */ |
---|
79 | int sem_unlink( |
---|
80 | const char *name |
---|
81 | ); |
---|
82 | |
---|
83 | /* |
---|
84 | * 11.2.6 Lock a Semaphore, P1003.1b-1993, p.226 |
---|
85 | * |
---|
86 | * NOTE: P1003.4b/D8 adds sem_timedwait(), p. 27 |
---|
87 | */ |
---|
88 | int sem_wait( |
---|
89 | sem_t *sem |
---|
90 | ); |
---|
91 | |
---|
92 | int sem_trywait( |
---|
93 | sem_t *sem |
---|
94 | ); |
---|
95 | |
---|
96 | #if defined(_POSIX_TIMEOUTS) |
---|
97 | int sem_timedwait( |
---|
98 | sem_t *sem, |
---|
99 | const struct timespec *timeout |
---|
100 | ); |
---|
101 | #endif |
---|
102 | |
---|
103 | /* |
---|
104 | * 11.2.7 Unlock a Semaphore, P1003.1b-1993, p.227 |
---|
105 | */ |
---|
106 | |
---|
107 | int sem_post( |
---|
108 | sem_t *sem |
---|
109 | ); |
---|
110 | |
---|
111 | /* |
---|
112 | * 11.2.8 Get the Value of a Semaphore, P1003.1b-1993, p.229 |
---|
113 | */ |
---|
114 | |
---|
115 | int sem_getvalue( |
---|
116 | sem_t *sem, |
---|
117 | int *sval |
---|
118 | ); |
---|
119 | |
---|
120 | #endif /* _POSIX_SEMAPHORES */ |
---|
121 | |
---|
122 | #ifdef __cplusplus |
---|
123 | } |
---|
124 | #endif |
---|
125 | |
---|
126 | #endif |
---|
127 | /* end of include file */ |
---|