Xenomai  3.0.8
wrappers.h
1 /*
2  * Copyright (C) 2011 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_WRAPPERS_H
19 #define _COBALT_WRAPPERS_H
20 
21 #include <boilerplate/compiler.h>
22 
23 #define __stringify_1(x...) #x
24 #define __stringify(x...) __stringify_1(x)
25 
26 #define __WRAP(call) __wrap_ ## call
27 #define __STD(call) __real_ ## call
28 #define __COBALT(call) __cobalt_ ## call
29 #define __RT(call) __COBALT(call)
30 #define COBALT_DECL(T, P) \
31  __typeof__(T) __RT(P); \
32  __typeof__(T) __STD(P); \
33  __typeof__(T) __WRAP(P)
34 
35 /*
36  *
37  * Each "foo" Cobalt routine shadowing a POSIX service may be
38  * overriden by an external library (see --with-cobalt-override
39  * option), in which case we generate the following symbols:
40  *
41  * __real_foo() => Original POSIX implementation.
42  * __cobalt_foo() => Cobalt implementation.
43  * __wrap_foo() => Weak alias to __cobalt_foo(), may be
44  * overriden.
45  *
46  * In the latter case, the external library shall provide its own
47  * implementation of __wrap_foo(), overriding Cobalt's foo()
48  * version. The original Cobalt implementation can still be
49  * referenced as __COBALT(foo).
50  */
51 #define COBALT_IMPL(T, I, A) \
52 __typeof__(T) __wrap_ ## I A __attribute__((alias("__cobalt_" __stringify(I)), weak)); \
53 __typeof__(T) __cobalt_ ## I A
54 
55 #endif /* !_COBALT_WRAPPERS_H */