summaryrefslogtreecommitdiff
path: root/drivers/staging/nmf-cm/cm/inc/cm_macros.h
blob: 2279c204a20d35330798f7ce662ceab7f06d0a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * Copyright (C) ST-Ericsson SA 2010. All rights reserved.
 * This code is ST-Ericsson proprietary and confidential.
 * Any use of the code for whatever purpose is subject to
 * specific written permission of ST-Ericsson SA.
 */
 
/*!
 * \brief Component Manager Macros.
 *
 * \defgroup CM_MACROS NMF Macros (ANSI C99)
 * The Component Manager Macros are provided to ease FromHost interface call and ToHost callback definition.
 * \attention <b>These macros are only ANSI C99 compliant</b> (ARM RVCT 2.x/3.x, GNU gcc 4.x, ...)
 * \ingroup CM_USER_API
 */

#ifndef __INC_CM_MACROS_H
#define __INC_CM_MACROS_H

/*
 * The next macros are supported only with C Ansi 99, so....
 */

/*
 * The Symbian environment dependency, computation which uses an old gnu cpp,
 * does not accept "..." parameters.
 * However the actual compiler (armcc) does.
 * So remove the macro definitions when computing dependencies.
 */
#if ( defined(__CC_ARM) && !defined(__STRICT_ANSI__) ) || !defined(__SYMBIAN32__)

/*
 * Only for skilled eyes ;)
 * The following macros are used to implement NMFCALL[VOID] and NMFMETH[VOID] macros in an elegant way
 */
#define WITH_PARAM(...)  __VA_ARGS__)
#define WITH_NOPARAM(...) )

/*!
 * \brief Macro to ease Host to Dsp interface calling
 *
 * \attention <b>This macro is only ANSI C99 compliant</b>
 *
 * The <i>NMFCALL</i> macro can be used to call one method of any previously FromHost bounded interface.\n
 * From Host side, today, we have no way to mask the multi-instance handling, so
 * this macro is provided to ease FromHost interface calling and to avoid any mistake into the THIS parameter passing.
 *
 * So, any fromHost interface method call like: \code
 * itf.method(itf.THIS, param1, param2, ...);
 * \endcode
 * can be replaced by: \code
 * NMFCALL(itf, method)(param1, param2, ...);
 * \endcode
 *
 * \warning Don't forget to use NMFCALLVOID macro when declaring a FromHost interface method having none application parameter,
 * else it will lead to erroneous C code expansion
 * \see NMFCALLVOID
 * \hideinitializer
 * \ingroup CM_MACROS
 */
#define NMFCALL(itfHandle, itfMethodName)  \
    (itfHandle).itfMethodName((itfHandle).THIS, WITH_PARAM

/*!
 * \brief Macro to ease Host to Dsp interface calling (method without any user parameter)
 *
 * \attention <b>This macro is only ANSI C99 compliant</b>
 *
 * The <i>NMFCALLVOID</i> macro can be used to call one method (those without any user parameter) of any previously FromHost bounded interface.\n
 * From Host side, today, we have no way to mask the multi-instance handling, so
 * this macro is provided to ease FromHost interface calling and to avoid any mistake into the THIS parameter passing.
 *
 * So, any FromHost interface method call without any application parameter like:\code
 * itf.method(itf.THIS);
 * \endcode
 * can be replaced by: \code
 * NMFCALLVOID(itf, method)();
 * \endcode
 * \see NMFCALL
 * \hideinitializer
 * \ingroup CM_MACROS
 */
#define NMFCALLVOID(itfHandle, itfMethodName)  \
    (itfHandle).itfMethodName((itfHandle).THIS WITH_NOPARAM

/*!
 * \brief Macro to ease Dsp to Host interface method declaration
 *
 * \attention <b>This macro definition is only ANSI C99 compliant</b>
 *
 * The <i>NMFMETH</i> macro can be used to ease the ToHost interface method declaration.\n
 * From Host side, today, we have no way to mask the multi-intance handling, so the user shall handle it by hand
 * by passing the "component" context as first parameter of each ToHost interface method through the void *THIS parameter.
 * This macro could avoid any mistake into the THIS parameter declaration when never used by the user code.
 *
 * So, any ToHost interface method declaration like:\code
 * void mynotify(void *THIS, mytype1 myparam1, mytype2 myparam2, ...) {
 * <body of the interface routine>
 * }
 * \endcode
 * can be replaced by: \code
 * void NMFMETH(mynotify)(mytype1 myparam1, mytype2 myparam2, ...) {
 * <body of the interface routine>
 * }
 * \endcode
 *
 * \warning Don't forget to use NMFMETHVOID macro when declaring a ToHost interface method having none application parameter,
 * else it will lead to erroneous C code expansion
 *
 * \see NMFMETHVOID
 * \hideinitializer
 * \ingroup CM_MACROS
 */
#define NMFMETH(itfMethodName) \
    itfMethodName(void *THIS, WITH_PARAM

/*!
 * \brief Macro to ease Dsp to Host interface method declaration (method without any user parameter)
 *
 * \attention <b>This macro is only ANSI C99 compliant</b>
 *
 * The <i>NMFMETHVOID</i> macro can be used to ease the ToHost interface method (those without any user parameter) declaration.\n
 * From Host side, today, we have no way to mask the multi-intance handling, so the user shall handle it by hand
 * by passing the "component" context as first parameter of each ToHost interface method through the void *THIS parameter.
 * This macro could avoid any mistake into the THIS parameter declaration when never used by the user code.
 *
 * So, any ToHost interface method declaration having none application parameter like:\code
 * void mynotify(void *THIS) {
 * <body of the interface routine>
 * }
 * \endcode
 * can be replaced by: \code
 * void NMFMETHVOID(mynotify)(void) {
 * <body of the interface routine>
 * }
 * \endcode
 *
 * \see NMFMETH
 * \hideinitializer
 * \ingroup CM_MACROS
 */
#define NMFMETHVOID(itfMethodName) \
    itfMethodName(void *THIS WITH_NOPARAM

#endif /* not Symbian environment or compiling with ARMCC and not in strict ANSI */

#endif /* __INC_CM_MACROS_H */