Xenomai  3.0-rc3
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 
26 struct cobalt_mutex {
27  unsigned int magic;
28  struct xnsynch synchbase;
30  struct list_head link;
31  struct list_head conds;
32  struct cobalt_mutexattr attr;
33  struct cobalt_kqueues *owningq;
34  xnhandle_t handle;
35 };
36 
37 int __cobalt_mutex_timedlock_break(struct cobalt_mutex_shadow __user *u_mx,
38  const void __user *u_ts,
39  int (*fetch_timeout)(struct timespec *ts,
40  const void __user *u_ts));
41 
42 int __cobalt_mutex_acquire_unchecked(struct xnthread *cur,
43  struct cobalt_mutex *mutex,
44  const struct timespec *ts);
45 
46 COBALT_SYSCALL_DECL(mutex_check_init,
47  (struct cobalt_mutex_shadow __user *u_mx));
48 
49 COBALT_SYSCALL_DECL(mutex_init,
50  (struct cobalt_mutex_shadow __user *u_mx,
51  const struct cobalt_mutexattr __user *u_attr));
52 
53 COBALT_SYSCALL_DECL(mutex_destroy,
54  (struct cobalt_mutex_shadow __user *u_mx));
55 
56 COBALT_SYSCALL_DECL(mutex_trylock,
57  (struct cobalt_mutex_shadow __user *u_mx));
58 
59 COBALT_SYSCALL_DECL(mutex_lock,
60  (struct cobalt_mutex_shadow __user *u_mx));
61 
62 COBALT_SYSCALL_DECL(mutex_timedlock,
63  (struct cobalt_mutex_shadow __user *u_mx,
64  const struct timespec __user *u_ts));
65 
66 COBALT_SYSCALL_DECL(mutex_unlock,
67  (struct cobalt_mutex_shadow __user *u_mx));
68 
69 int cobalt_mutex_release(struct xnthread *cur,
70  struct cobalt_mutex *mutex);
71 
72 void cobalt_mutexq_cleanup(struct cobalt_kqueues *q);
73 
74 void cobalt_mutex_pkg_init(void);
75 
76 void cobalt_mutex_pkg_cleanup(void);
77 
78 #endif /* !_COBALT_POSIX_MUTEX_H */