C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
Loading...
Searching...
No Matches
implementation.h
1
2
#pragma GCC diagnostic push
3
#pragma GCC diagnostic ignored "-Wundef"
4
5
/* Scary internals of how this mechanism allows for multiple
6
* interfaces being defined in one translation unit.
7
* Internally, interface counter is maintained, which is incremented
8
* each time, when "rpc/implementation.h" is included.
9
* Each new inclusion thus allows to define one additional interface.
10
* Currently the limit is to define 10 interfaces in single
11
* translation unit. It can be increseas by prolonging the code
12
* below.
13
*/
14
#if CMRX__INTERFACE__COUNTER == 9
15
#error "Too many interface implementations in one file! Split implementations of interfaces into multiple files!"
16
#elif CMRX__INTERFACE__COUNTER == 8
17
#undef CMRX__INTERFACE__COUNTER
18
#define CMRX__INTERFACE__COUNTER 9
19
#elif CMRX__INTERFACE__COUNTER == 7
20
#undef CMRX__INTERFACE__COUNTER
21
#define CMRX__INTERFACE__COUNTER 8
22
#elif CMRX__INTERFACE__COUNTER == 6
23
#undef CMRX__INTERFACE__COUNTER
24
#define CMRX__INTERFACE__COUNTER 7
25
#elif CMRX__INTERFACE__COUNTER == 5
26
#undef CMRX__INTERFACE__COUNTER
27
#define CMRX__INTERFACE__COUNTER 6
28
#elif CMRX__INTERFACE__COUNTER == 4
29
#undef CMRX__INTERFACE__COUNTER
30
#define CMRX__INTERFACE__COUNTER 5
31
#elif CMRX__INTERFACE__COUNTER == 3
32
#undef CMRX__INTERFACE__COUNTER
33
#define CMRX__INTERFACE__COUNTER 4
34
#elif CMRX__INTERFACE__COUNTER == 2
35
#undef CMRX__INTERFACE__COUNTER
36
#define CMRX__INTERFACE__COUNTER 3
37
#elif CMRX__INTERFACE__COUNTER == 1
38
#undef CMRX__INTERFACE__COUNTER
39
#define CMRX__INTERFACE__COUNTER 2
40
#elif CMRX__INTERFACE__COUNTER == 0
41
#undef CMRX__INTERFACE__COUNTER
42
#define CMRX__INTERFACE__COUNTER 1
43
#endif
44
45
#pragma GCC diagnostic pop
46
47
#ifndef CMRX__INTERFACE__COUNTER
48
# define CMRX__INTERFACE__COUNTER 0
49
#endif
50
51
#define CMRX_IMPLEMENTATION_IMPL(type, offs) extern type * __cmrx_interface_type_carrier_ ## offs
52
#define CMRX_IMPLEMENTATION_HELPER(type, offs) CMRX_IMPLEMENTATION_IMPL(type, offs)
53
54
#define CMRX_THIS_IMPL(offs) ({ _Static_assert(__builtin_types_compatible_p(typeof(__cmrx_interface_type_carrier_ ## offs), void *) == 0, "Class declaration missing before defining interface for it"); ((typeof(__cmrx_interface_type_carrier_ ## offs)) this_); })
55
#define CMRX_THIS_HELPER(offs) CMRX_THIS_IMPL(offs)
56
57
#define CMRX_IMPLEMENTATION_TYPE_IMPL(type, iface) "Service " #type " does not implement interface " #iface
58
#define CMRX_IMPLEMENTATION_TYPE_HELPER(type, iface) CMRX_IMPLEMENTATION_TYPE_IMPL(type, iface)
59
#define CMRX_CHECK_INTERFACE_MATCH(type, interface) __builtin_types_compatible_p(const interface *, typeof(((type *) 0)->vtable))
include
cmrx
rpc
internal
implementation.h
Generated by
1.9.8