RTEMS CPU Kit with SuperCore  4.11.3
semaphore.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2011.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _SEMAPHORE_H
20 #define _SEMAPHORE_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
34 #include <unistd.h>
35 
36 #if defined(_POSIX_SEMAPHORES)
37 
38 #include <sys/time.h>
39 
40 /*
41  * 11.1 Semaphore Characteristics, P1003.1b-1993, p.219
42  */
43 typedef uint32_t sem_t;
44 
45 /*
46  * Bad semaphore Id
47  */
48 #define SEM_FAILED ((sem_t *)0)
49 
50 /*
51  * 11.2.1 Initialize an Unnamed Semaphore, P1003.1b-1993, p.219
52  */
53 int sem_init(
54  sem_t *sem,
55  int pshared,
56  unsigned int value
57 );
58 
64 int sem_destroy(
65  sem_t *sem
66 );
67 
68 /*
69  * 11.2.3 Initialize/Open a Named Semaphore, P1003.1b-1993, p.221
70  *
71  * NOTE: Follows open() calling conventions.
72  */
73 sem_t *sem_open(
74  const char *name,
75  int oflag,
76  ...
77 );
78 
86 int sem_close(
87  sem_t *sem
88 );
89 
98 int sem_unlink(
99  const char *name
100 );
101 
109 int sem_wait(
110  sem_t *sem
111 );
112 
118 int sem_trywait(
119  sem_t *sem
120 );
121 
122 #if defined(_POSIX_TIMEOUTS)
123 
126 int sem_timedwait(
127  sem_t *__restrict sem,
128  const struct timespec *__restrict timeout
129 );
130 #endif
131 
137 int sem_post(
138  sem_t *sem
139 );
140 
146 int sem_getvalue(
147  sem_t *__restrict sem,
148  int *__restrict sval
149 );
150 
151 #endif /* _POSIX_SEMAPHORES */
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif
158 /* end of include file */