Xenomai  3.0.5
semaphore.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #pragma GCC system_header
19 #include_next <semaphore.h>
20 
21 #ifndef _COBALT_SEMAPHORE_H
22 #define _COBALT_SEMAPHORE_H
23 
24 #include <boilerplate/atomic.h>
25 #include <cobalt/wrappers.h>
26 #include <cobalt/uapi/sem.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 COBALT_DECL(int, sem_init(sem_t *sem,
33  int pshared,
34  unsigned int value));
35 
36 COBALT_DECL(int, sem_destroy(sem_t *sem));
37 
38 COBALT_DECL(int, sem_post(sem_t *sem));
39 
40 COBALT_DECL(int, sem_wait(sem_t *sem));
41 
42 COBALT_DECL(int, sem_timedwait(sem_t *sem,
43  const struct timespec *abs_timeout));
44 
45 COBALT_DECL(int, sem_trywait(sem_t *sem));
46 
47 COBALT_DECL(int, sem_getvalue(sem_t *sem, int *value));
48 
49 COBALT_DECL(sem_t *, sem_open(const char *name, int oflags, ...));
50 
51 COBALT_DECL(int, sem_close(sem_t *sem));
52 
53 COBALT_DECL(int, sem_unlink(const char *name));
54 
55 int sem_init_np(sem_t *sem,
56  int flags,
57  unsigned int value);
58 
59 int sem_broadcast_np(sem_t *sem);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* !_COBALT_SEMAPHORE_H */
int sem_wait(sem_t *sem)
Decrement a semaphore.
Definition: semaphore.c:310
int sem_trywait(sem_t *sem)
Attempt to decrement a semaphore.
Definition: semaphore.c:247
int sem_unlink(const char *name)
Unlink a named semaphore.
Definition: semaphore.c:595
int sem_close(sem_t *sem)
Close a named semaphore.
Definition: semaphore.c:548
int sem_destroy(sem_t *sem)
Destroy an unnamed semaphore.
Definition: semaphore.c:139
int sem_init(sem_t *sem, int pshared, unsigned int value)
Initialize an unnamed semaphore.
Definition: semaphore.c:87
int sem_post(sem_t *sem)
Post a semaphore.
Definition: semaphore.c:185
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
Attempt to decrement a semaphore with a time limit.
Definition: semaphore.c:365