2 * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifndef _XENO_POSIX_SEMAPHORE_H
20 #define _XENO_POSIX_SEMAPHORE_H
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
24 #include <nucleus/xenomai.h>
27 #include <linux/kernel.h>
28 #include <linux/fcntl.h>
29 #endif /* __KERNEL__ */
32 #include <posix_overrides.h>
33 #endif /* __XENO_SIM__ */
35 #define SEM_VALUE_MAX (INT_MAX)
36 #define SEM_FAILED NULL
39 /* Copied from Linuxthreads semaphore.h. */
48 struct _sem_fastlock __sem_lock
;
52 #endif /* __KERNEL__ */
54 #else /* !(__KERNEL__ || __XENO_SIM__) */
56 #pragma GCC system_header
58 #include <fcntl.h> /* For sem_open flags. */
59 #include_next <semaphore.h>
61 #endif /* !(__KERNEL__ || __XENO_SIM__) */
69 struct pse51_sem
*sem
;
73 #if defined(__KERNEL__) || defined(__XENO_SIM__)
80 #define sem_init pse51_sem_init
82 int pse51_sem_init(sem_t
*sem
,
86 int sem_destroy(sem_t
*sem
);
88 int sem_post(sem_t
*sem
);
90 int sem_trywait(sem_t
*sem
);
92 int sem_wait(sem_t
*sem
);
94 int sem_timedwait(sem_t
*sem
,
95 const struct timespec
*abs_timeout
);
97 int sem_getvalue(sem_t
*sem
,
100 sem_t
*sem_open(const char *name
, int oflag
, ...);
102 int sem_close(sem_t
*sem
);
104 int sem_unlink(const char *name
);
110 #else /* !(__KERNEL__ || __XENO_SIM__) */
116 int __real_sem_init(sem_t
*sem
,
120 int __real_sem_destroy(sem_t
*sem
);
122 int __real_sem_post(sem_t
*sem
);
124 int __real_sem_wait(sem_t
*sem
);
126 int __real_sem_timedwait(sem_t
*sem
, const struct timespec
*abs_timeout
);
128 int __real_sem_trywait(sem_t
*sem
);
130 int __real_sem_getvalue(sem_t
*sem
, int *value
);
132 sem_t
*__real_sem_open(const char *name
, int oflags
, ...);
134 int __real_sem_close(sem_t
*sem
);
136 int __real_sem_unlink(const char *name
);
142 #endif /* !(__KERNEL__ || __XENO_SIM__) */
144 #endif /* _XENO_POSIX_SEMAPHORE_H */