Xenomai  3.1
mutex.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 
19 #ifndef _COBALT_POSIX_MUTEX_H
20 #define _COBALT_POSIX_MUTEX_H
21 
22 #include "thread.h"
23 #include <cobalt/uapi/mutex.h>
24 #include <xenomai/posix/syscall.h>
25 #include <xenomai/posix/process.h>
26 
27 struct cobalt_process;
28 
29 struct cobalt_mutex {
30  unsigned int magic;
31  struct xnsynch synchbase;
33  struct list_head conds;
34  struct cobalt_mutexattr attr;
35  struct cobalt_resnode resnode;
36 };
37 
38 int __cobalt_mutex_timedlock_break(struct cobalt_mutex_shadow __user *u_mx,
39  const void __user *u_ts,
40  int (*fetch_timeout)(struct timespec *ts,
41  const void __user *u_ts));
42 
43 int __cobalt_mutex_acquire_unchecked(struct xnthread *cur,
44  struct cobalt_mutex *mutex,
45  const struct timespec *ts);
46 
47 COBALT_SYSCALL_DECL(mutex_check_init,
48  (struct cobalt_mutex_shadow __user *u_mx));
49 
50 COBALT_SYSCALL_DECL(mutex_init,
51  (struct cobalt_mutex_shadow __user *u_mx,
52  const struct cobalt_mutexattr __user *u_attr));
53 
54 COBALT_SYSCALL_DECL(mutex_destroy,
55  (struct cobalt_mutex_shadow __user *u_mx));
56 
57 COBALT_SYSCALL_DECL(mutex_trylock,
58  (struct cobalt_mutex_shadow __user *u_mx));
59 
60 COBALT_SYSCALL_DECL(mutex_lock,
61  (struct cobalt_mutex_shadow __user *u_mx));
62 
63 COBALT_SYSCALL_DECL(mutex_timedlock,
64  (struct cobalt_mutex_shadow __user *u_mx,
65  const struct timespec __user *u_ts));
66 
67 COBALT_SYSCALL_DECL(mutex_unlock,
68  (struct cobalt_mutex_shadow __user *u_mx));
69 
70 int cobalt_mutex_release(struct xnthread *cur,
71  struct cobalt_mutex *mutex);
72 
73 void cobalt_mutex_reclaim(struct cobalt_resnode *node,
74  spl_t s);
75 
76 #endif /* !_COBALT_POSIX_MUTEX_H */