Xenomai  3.0.8
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)
38 
39 #define XN_HANDLE_TRANSIENT_MASK XNSYNCH_FLCLAIM
40 
41 /*
42  * Strip all special bits from the handle, only retaining the object
43  * index value in the registry.
44  */
45 static inline xnhandle_t xnhandle_get_index(xnhandle_t handle)
46 {
47  return handle & ~XN_HANDLE_INDEX_MASK;
48 }
49 
50 /*
51  * Strip the transient bits from the handle, only retaining the fixed
52  * part making the identifier.
53  */
54 static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
55 {
56  return handle & ~XN_HANDLE_TRANSIENT_MASK;
57 }
58 
59 #endif /* !_COBALT_UAPI_KERNEL_TYPES_H */