bfin: remove inline keyword
[xenomai-head.git] / include / posix / semaphore.h
blob9f30058b55ef1cb559d56d6aeea0d20e6e82e7b6
1 /*
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>
26 #ifdef __KERNEL__
27 #include <linux/kernel.h>
28 #include <linux/fcntl.h>
29 #endif /* __KERNEL__ */
31 #ifdef __XENO_SIM__
32 #include <posix_overrides.h>
33 #endif /* __XENO_SIM__ */
35 #define SEM_VALUE_MAX (INT_MAX)
36 #define SEM_FAILED NULL
38 #ifdef __KERNEL__
39 /* Copied from Linuxthreads semaphore.h. */
40 struct _sem_fastlock
42 long int __status;
43 int __spinlock;
46 typedef struct
48 struct _sem_fastlock __sem_lock;
49 int __sem_value;
50 long __sem_waiting;
51 } sem_t;
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__) */
63 struct pse51_sem;
65 union __xeno_sem {
66 sem_t native_sem;
67 struct __shadow_sem {
68 unsigned magic;
69 struct pse51_sem *sem;
70 } shadow_sem;
73 #if defined(__KERNEL__) || defined(__XENO_SIM__)
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
79 #undef sem_init
80 #define sem_init pse51_sem_init
82 int pse51_sem_init(sem_t *sem,
83 int pshared,
84 unsigned int value);
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,
98 int *value);
100 sem_t *sem_open(const char *name, int oflag, ...);
102 int sem_close(sem_t *sem);
104 int sem_unlink(const char *name);
106 #ifdef __cplusplus
108 #endif
110 #else /* !(__KERNEL__ || __XENO_SIM__) */
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
116 int __real_sem_init(sem_t *sem,
117 int pshared,
118 unsigned value);
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);
138 #ifdef __cplusplus
140 #endif
142 #endif /* !(__KERNEL__ || __XENO_SIM__) */
144 #endif /* _XENO_POSIX_SEMAPHORE_H */