Xenomai  3.1.2
types.h
1 /*
2  * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _COBALT_UAPI_KERNEL_TYPES_H
19 #define _COBALT_UAPI_KERNEL_TYPES_H
20 
21 #include <linux/types.h>
22 #include <cobalt/uapi/kernel/limits.h>
23 
24 typedef __u64 xnticks_t;
25 
26 typedef __s64 xnsticks_t;
27 
28 typedef __u32 xnhandle_t;
29 
30 #define XN_NO_HANDLE ((xnhandle_t)0)
31 #define XN_HANDLE_INDEX_MASK ((xnhandle_t)0xf0000000)
32 
33 /* Fixed bits (part of the identifier) */
34 #define XNSYNCH_PSHARED ((xnhandle_t)0x40000000)
35 
36 /* Transient bits (expressing a status) */
37 #define XNSYNCH_FLCLAIM ((xnhandle_t)0x80000000) /* Contended. */
38 #define XNSYNCH_FLCEIL ((xnhandle_t)0x20000000) /* Ceiling active. */
39 
40 #define XN_HANDLE_TRANSIENT_MASK (XNSYNCH_FLCLAIM|XNSYNCH_FLCEIL)
41 
42 /*
43  * Strip all special bits from the handle, only retaining the object
44  * index value in the registry.
45  */
46 static inline xnhandle_t xnhandle_get_index(xnhandle_t handle)
47 {
48  return handle & ~XN_HANDLE_INDEX_MASK;
49 }
50 
51 /*
52  * Strip the transient bits from the handle, only retaining the fixed
53  * part making the identifier.
54  */
55 static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
56 {
57  return handle & ~XN_HANDLE_TRANSIENT_MASK;
58 }
59 
60 #endif /* !_COBALT_UAPI_KERNEL_TYPES_H */