Xenomai 3.3.2
Loading...
Searching...
No Matches
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 __WRAP(call) __wrap_ ## call
24#define __STD(call) __real_ ## call
25#define __COBALT(call) __cobalt_ ## call
26#define __RT(call) __COBALT(call)
27#define COBALT_DECL(T, FN, I) \
28 __typeof__(T) __RT(FN) I; \
29 __typeof__(T) __STD(FN) I; \
30 __typeof__(T) __WRAP(FN) I
31
32#if __USE_TIME_BITS64 && __TIMESIZE == 32
33/*
34 * Make __RT() and __STD() usable in combination with time64_t related services.
35 */
36#define COBALT_IMPL_TIME64(T, FN, FN_64, I) \
37 __typeof__(T) __wrap_##FN_64 I \
38 __attribute__((alias("__cobalt_" __stringify(FN)), weak)); \
39 COBALT_IMPL(T, FN, I)
40#define COBALT_DECL_TIME64(T, FN, A, I) \
41 __typeof__(T) __STD(A) I; \
42 extern T __REDIRECT_NTH(__STD(FN), I, __real_##A); \
43 COBALT_DECL(T, FN, I)
44#else
45#define COBALT_IMPL_TIME64(T, FN, FN_64, I) COBALT_IMPL(T, FN, I)
46#define COBALT_DECL_TIME64(T, FN, FN_64, I) COBALT_DECL(T, FN, I)
47#endif
48
49/*
50 *
51 * Each "foo" Cobalt routine shadowing a POSIX service may be
52 * overriden by an external library (see --with-cobalt-override
53 * option), in which case we generate the following symbols:
54 *
55 * __real_foo() => Original POSIX implementation.
56 * __cobalt_foo() => Cobalt implementation.
57 * __wrap_foo() => Weak alias to __cobalt_foo(), may be
58 * overriden.
59 *
60 * In the latter case, the external library shall provide its own
61 * implementation of __wrap_foo(), overriding Cobalt's foo()
62 * version. The original Cobalt implementation can still be
63 * referenced as __COBALT(foo).
64 */
65#define COBALT_IMPL(T, FN, I) \
66 __typeof__(T) __wrap_##FN I \
67 __attribute__((alias("__cobalt_" __stringify(FN)), weak)); \
68 __typeof__(T) __cobalt_##FN I
69
70#endif /* !_COBALT_WRAPPERS_H */