Xenomai  3.0-rc7
scope.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 _BOILERPLATE_SCOPE_H
19 #define _BOILERPLATE_SCOPE_H
20 
21 #include <sys/types.h>
22 #include <stddef.h>
23 #include <stdint.h>
24 #include <xeno_config.h>
25 
26 typedef uintptr_t memoff_t;
27 
28 #ifdef CONFIG_XENO_PSHARED
29 
30 extern void *__main_heap;
31 
32 int pshared_check(void *heap, void *addr);
33 
34 #define dref_type(t) memoff_t
35 
36 #define __memoff(__base, __addr) ((memoff_t)((caddr_t)(__addr) - (caddr_t)(__base)))
37 #define __memptr(__base, __off) ((void *)((caddr_t)(__base) + (__off)))
38 #define __memchk(__base, __addr) pshared_check(__base, __addr)
39 
40 #define __moff(__p) __memoff(__main_heap, __p)
41 #define __mptr(__off) __memptr(__main_heap, __off)
42 #define __mchk(__p) __memchk(__main_heap, __p)
43 
44 #define mutex_scope_attribute PTHREAD_PROCESS_SHARED
45 #define sem_scope_attribute 1
46 #ifdef CONFIG_XENO_COBALT
47 #define monitor_scope_attribute COBALT_MONITOR_SHARED
48 #define event_scope_attribute COBALT_EVENT_SHARED
49 #endif
50 
51 #else /* !CONFIG_XENO_PSHARED */
52 
53 #define __main_heap NULL
54 
55 #define dref_type(t) __typeof__(t)
56 
57 #define __memoff(__base, __addr) (__addr)
58 #define __memptr(__base, __off) (__off)
59 #define __memchk(__base, __addr) 1
60 
61 #define __moff(__p) (__p)
62 #define __mptr(__off) (__off)
63 #define __mchk(__p) 1
64 
65 #define mutex_scope_attribute PTHREAD_PROCESS_PRIVATE
66 #define sem_scope_attribute 0
67 #ifdef CONFIG_XENO_COBALT
68 #define monitor_scope_attribute 0
69 #define event_scope_attribute 0
70 #endif
71 
72 #endif /* !CONFIG_XENO_PSHARED */
73 
74 #endif /* _BOILERPLATE_SCOPE_H */