Xenomai 3.3.2
Loading...
Searching...
No Matches
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
26typedef uintptr_t memoff_t;
27
28#ifdef CONFIG_XENO_PSHARED
29
30extern void *__main_heap;
31
32int 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 __moff_nullable(__p) (__p ? __memoff(__main_heap, __p) : 0)
42#define __mptr(__off) __memptr(__main_heap, __off)
43#define __mptr_nullable(__off) (__off ? __memptr(__main_heap, __off) : NULL)
44#define __mchk(__p) __memchk(__main_heap, __p)
45
46#define mutex_scope_attribute PTHREAD_PROCESS_SHARED
47#define sem_scope_attribute 1
48#ifdef CONFIG_XENO_COBALT
49#define monitor_scope_attribute COBALT_MONITOR_SHARED
50#define event_scope_attribute COBALT_EVENT_SHARED
51#endif
52
53#else /* !CONFIG_XENO_PSHARED */
54
55#define __main_heap NULL
56
57#define dref_type(t) __typeof__(t)
58
59#define __memoff(__base, __addr) (__addr)
60#define __memptr(__base, __off) (__off)
61#define __memchk(__base, __addr) 1
62
63#define __moff(__p) (__p)
64#define __moff_nullable(__p) (__p)
65#define __mptr(__off) (__off)
66#define __mptr_nullable(__off) (__off)
67#define __mchk(__p) 1
68
69#define mutex_scope_attribute PTHREAD_PROCESS_PRIVATE
70#define sem_scope_attribute 0
71#ifdef CONFIG_XENO_COBALT
72#define monitor_scope_attribute 0
73#define event_scope_attribute 0
74#endif
75
76#endif /* !CONFIG_XENO_PSHARED */
77
78#endif /* _BOILERPLATE_SCOPE_H */