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