Xenomai 3.3.2
Loading...
Searching...
No Matches
sem.h
1/*
2 * Written by Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>.
3 *
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.
8 *
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.
13 *
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.
17 */
18#ifndef _COBALT_POSIX_SEM_H
19#define _COBALT_POSIX_SEM_H
20
21#include <linux/kernel.h>
22#include <linux/fcntl.h>
23#include <cobalt/kernel/thread.h>
24#include <cobalt/kernel/registry.h>
25#include <xenomai/posix/syscall.h>
26#include <xenomai/posix/process.h>
27
28struct cobalt_process;
29struct filename;
30
31struct cobalt_sem {
32 unsigned int magic;
33 struct xnsynch synchbase;
34 struct cobalt_sem_state *state;
35 int flags;
36 unsigned int refs;
37 struct filename *pathname;
38 struct cobalt_resnode resnode;
39};
40
41/* Copied from Linuxthreads semaphore.h. */
42struct _sem_fastlock
43{
44 long int __status;
45 int __spinlock;
46};
47
48typedef struct
49{
50 struct _sem_fastlock __sem_lock;
51 int __sem_value;
52 long __sem_waiting;
53} sem_t;
54
55#include <cobalt/uapi/sem.h>
56
57#define SEM_VALUE_MAX (INT_MAX)
58#define SEM_FAILED NULL
59#define SEM_NAMED 0x80000000
60
61struct cobalt_sem_shadow __user *
62__cobalt_sem_open(struct cobalt_sem_shadow __user *usm,
63 const char __user *u_name,
64 int oflags, mode_t mode, unsigned int value);
65
66int __cobalt_sem_timedwait(struct cobalt_sem_shadow __user *u_sem,
67 const struct timespec64 *ts);
68
69int __cobalt_sem_destroy(xnhandle_t handle);
70
71void cobalt_nsem_reclaim(struct cobalt_process *process);
72
73struct cobalt_sem *
74__cobalt_sem_init(const char *name, struct cobalt_sem_shadow *sem,
75 int flags, unsigned value);
76
77void __cobalt_sem_shadow_init(struct cobalt_sem *sem, __u32 magic,
78 struct cobalt_sem_shadow *sm);
79
80COBALT_SYSCALL_DECL(sem_init,
81 (struct cobalt_sem_shadow __user *u_sem,
82 int flags, unsigned value));
83
84COBALT_SYSCALL_DECL(sem_post,
85 (struct cobalt_sem_shadow __user *u_sem));
86
87COBALT_SYSCALL_DECL(sem_wait,
88 (struct cobalt_sem_shadow __user *u_sem));
89
90COBALT_SYSCALL_DECL(sem_timedwait,
91 (struct cobalt_sem_shadow __user *u_sem,
92 const struct __kernel_old_timespec __user *u_ts));
93
94COBALT_SYSCALL_DECL(sem_timedwait64,
95 (struct cobalt_sem_shadow __user *u_sem,
96 const struct __kernel_timespec __user *u_ts));
97
98COBALT_SYSCALL_DECL(sem_trywait,
99 (struct cobalt_sem_shadow __user *u_sem));
100
101COBALT_SYSCALL_DECL(sem_getvalue,
102 (struct cobalt_sem_shadow __user *u_sem,
103 int __user *u_sval));
104
105COBALT_SYSCALL_DECL(sem_destroy,
106 (struct cobalt_sem_shadow __user *u_sem));
107
108COBALT_SYSCALL_DECL(sem_open,
109 (struct cobalt_sem_shadow __user *__user *u_addrp,
110 const char __user *u_name,
111 int oflags, mode_t mode, unsigned int value));
112
113COBALT_SYSCALL_DECL(sem_close,
114 (struct cobalt_sem_shadow __user *usm));
115
116COBALT_SYSCALL_DECL(sem_unlink, (const char __user *u_name));
117
118COBALT_SYSCALL_DECL(sem_broadcast_np,
119 (struct cobalt_sem_shadow __user *u_sem));
120
121COBALT_SYSCALL_DECL(sem_inquire,
122 (struct cobalt_sem_shadow __user *u_sem,
123 struct cobalt_sem_info __user *u_info,
124 pid_t __user *u_waitlist,
125 size_t waitsz));
126
127void cobalt_sem_reclaim(struct cobalt_resnode *node,
128 spl_t s);
129
130#endif /* !_COBALT_POSIX_SEM_H */
int sem_post(sem_t *sem))
Post a semaphore.
Definition semaphore.c:184
int sem_trywait(sem_t *sem))
Attempt to decrement a semaphore.
Definition semaphore.c:246
int sem_close(sem_t *sem))
Close a named semaphore.
Definition semaphore.c:553
int sem_init(sem_t *sem, int pshared, unsigned int value))
Initialize an unnamed semaphore.
Definition semaphore.c:86
int sem_destroy(sem_t *sem))
Destroy an unnamed semaphore.
Definition semaphore.c:138
int sem_unlink(const char *name))
Unlink a named semaphore.
Definition semaphore.c:600
int sem_wait(sem_t *sem))
Decrement a semaphore.
Definition semaphore.c:309