EM-ODP  3.7.0
Event Machine on ODP
event_machine_config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Nokia Siemens Networks
3  * Copyright (c) 2015, Nokia Solutions and Networks
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /**
33  * @file
34  *
35  * Event Machine configuration options
36  */
37 
38 #ifndef EVENT_MACHINE_CONFIG_H
39 #define EVENT_MACHINE_CONFIG_H
40 
41 #pragma GCC visibility push(default)
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #ifdef EM_64_BIT
48 /**
49  * @page page_version 64-bit version
50  * This documentation represent the 64-bit version of Event Machine API.
51  * Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit versions.
52  */
53 #elif defined(EM_32_BIT)
54 /**
55  * @page page_version 32-bit version
56  * This documentation represent the 32-bit version of Event Machine API.
57  * Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit versions.
58  */
59 #else
60 #error Missing architecture definition. Define EM_64_BIT or EM_32_BIT!
61 /**
62  * @page page_version 64/32-bit version not selected
63  * This documentation has not selected between 64/32-bit version of
64  * the Event Machine API. Some types might be missing.
65  * Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit
66  * versions.
67  */
68 #endif
69 
70 /**
71  * @def EM_HANDLE_T
72  * Define 'type_t' as a struct ptr to improve type safety
73  */
74 #define EM_HANDLE_T(type_t) \
75  typedef struct _##type_t { \
76  void *unused; \
77  } *(type_t)
78 
79 /**
80  * @def EM_STATIC_CAST
81  * Support C++ static casts in EM API files
82  */
83 #ifndef __cplusplus
84 #define EM_STATIC_CAST(type, value) ((type)(value))
85 #else
86 #define EM_STATIC_CAST(type, value) (static_cast < type > (value))
87 #endif
88 
89 /**
90  * @def EM_REINTERPRET_CAST
91  * Support C++ reinterpret casts in EM API files
92  */
93 #ifndef __cplusplus
94 #define EM_REINTERPRET_CAST(type, value) ((type)(value))
95 #else
96 #define EM_REINTERPRET_CAST(type, value) (reinterpret_cast < type > (value))
97 #endif
98 
99 /**
100  * @def EM_HDL_UNDEF
101  * Undefined EM-handle
102  */
103 #ifndef __cplusplus
104 #define EM_HDL_UNDEF NULL
105 #else
106 #define EM_HDL_UNDEF nullptr
107 #endif
108 
109 /**
110  * @def PRI_HDL
111  * EM-handle printf format
112  */
113 #define PRI_HDL "p"
114 
115 /**
116  * @def EM_CONFIG_POOLS
117  * Maximum number of EM pools
118  */
119 #define EM_CONFIG_POOLS 16
120 
121 /**
122  * @def EM_QUEUE_NAME_LEN
123  * Maximum queue name string length
124  */
125 #define EM_QUEUE_NAME_LEN 32
126 
127 /**
128  * @def EM_MAX_OUTPUT_QUEUES
129  * Maximum number of output queues
130  */
131 #define EM_MAX_OUTPUT_QUEUES 64
132 
133 /**
134  * @def EM_MAX_ATOMIC_GROUPS
135  * Maximum number of EM atomic groups
136  */
137 #define EM_MAX_ATOMIC_GROUPS 128
138 
139 /**
140  * @def EM_ATOMIC_GROUP_NAME_LEN
141  * Max atomic group name length
142  */
143 #define EM_ATOMIC_GROUP_NAME_LEN 32
144 
145 /**
146  * @def EM_MAX_EOS
147  * Maximum total number of EOs
148  */
149 #define EM_MAX_EOS 512
150 
151 /**
152  * @def EM_EO_NAME_LEN
153  * Maximum EO name string length
154  */
155 #define EM_EO_NAME_LEN 32
156 
157 /**
158  * @def EM_MAX_EVENT_GROUPS
159  * Maximum number of event groups
160  */
161 #define EM_MAX_EVENT_GROUPS 1024
162 
163 /**
164  * @def EM_EVENT_GROUP_MAX_NOTIF
165  * Maximum number of notifications
166  */
167 #define EM_EVENT_GROUP_MAX_NOTIF 6
168 
169 /*
170  * @def EM_DISPATCH_CALLBACKS_ENABLE
171  * Enable dispatcher callback functions
172  */
173 #define EM_DISPATCH_CALLBACKS_ENABLE 1
174 
175 /**
176  * @def EM_API_HOOKS_ENABLE
177  * Enable the usage of EM API hooks
178  *
179  * User provided API hook functions can be provided via em_init(). EM will
180  * call the given hooks each time the corresponding API function is called.
181  */
182 #define EM_API_HOOKS_ENABLE 1
183 
184 /**
185  * @def EM_IDLE_HOOKS_ENABLE
186  * Enable the usage of EM idle hooks
187  *
188  * User provided idle hook functions can be provided via em_conf_t::idle_hooks
189  * when calling em_init() or via their register functions. EM will call the
190  * given hooks in the dispatcher depending on whether there are events to be
191  * processed by the core.
192  *
193  * @note em-odp: the 'EM_IDLE_HOOKS_ENABLE' value can be overridden by a
194  * command-line option to the 'configure' script, e.g.:
195  * $build> ../configure ... --enable-idle-hooks
196  * The overridden value will be made available to the application
197  * via a pkgconfig set define.
198  */
199 #ifndef EM_IDLE_HOOKS_ENABLE
200 #define EM_IDLE_HOOKS_ENABLE 0
201 #endif
202 
203 /**
204  * @def EM_SCHED_WAIT_ENABLE
205  * Enable the EM dispatcher/scheduler to start waiting for events if none are
206  * immediately available. Waiting for events, rather than busy-waiting, might
207  * save power.
208  * The EM dispatch loop will call odp_schedule_multi(..., sched_wait_ns, ...)
209  * when EM_SCHED_WAIT_ENABLE=1.
210  * The EM dispatch loop will call odp_schedule_multi_no_wait()
211  * when EM_SCHED_WAIT_ENABLE=0.
212  * The 'sched_wait_ns' value can be set via the EM config file (config/em-odp.conf)
213  * variable 'dispatch.sched_wait_ns = value'
214  *
215  * @note em-odp: the 'EM_SCHED_WAIT_ENABLE' value can be overridden by a
216  * command-line option to the 'configure' script, e.g.:
217  * $build> ../configure ... --enable-sched-wait
218  * The overridden value will be made available to the application
219  * via a pkgconfig set define.
220  */
221 #ifndef EM_SCHED_WAIT_ENABLE
222 #define EM_SCHED_WAIT_ENABLE 0
223 #endif
224 
225 /**
226  * @def EM_CALLBACKS_MAX
227  * Maximum number of EM callbacks/hooks that can be registered.
228  *
229  * The user may register up to the number 'EM_CALLBACKS_MAX' of each
230  * callback/hook. API-hooks, such as the alloc-, free- and send-hook, or
231  * dispatcher callbacks, such as the enter- and exit-callbacks as well as
232  * idle-hooks can be registered each up to this limit.
233  */
234 #define EM_CALLBACKS_MAX 8
235 
236 /**
237  * @def EM_CHECK_LEVEL
238  * Error check level
239  *
240  * Conditionally compiled error checking level, range 0...3
241  * Level 0 does not do any runtime argument checking (be careful!)
242  * Level 1 adds minimum checks
243  * Level 2 adds most checks except the slowest ones
244  * Level 3 adds all checks and gives lowest performance
245  *
246  * @note em-odp: the 'EM_CHECK_LEVEL' value can be overridden by a command-line
247  * option to the 'configure' script, e.g.:
248  * $build> ../configure ... --enable-check-level=3
249  * The overridden value will be made available to the application
250  * via a pkgconfig set define.
251  */
252 #ifndef EM_CHECK_LEVEL
253 #define EM_CHECK_LEVEL 1
254 #endif
255 
256 /**
257  * @def EM_ESV_ENABLE
258  * Event State Verification (ESV)
259  *
260  * '0': disabled
261  * '1': enabled - event state is verified when the event is passed from EM to
262  * the user (e.g. dispatch) and from the user to EM (e.g. send)
263  * to catch illegal usage patterns like double-send, double-free,
264  * usage-after-send etc.
265  *
266  * Also see the config/em-odp.conf file for ESV runtime options!
267  *
268  * @note em-odp: the 'EM_ESV_ENABLE' value can be overridden by a command-line
269  * option to the 'configure' script, e.g.:
270  * $build> ../configure ... --enable-esv
271  * The overridden value will be made available to the application
272  * via a pkgconfig set define.
273  */
274 #ifndef EM_ESV_ENABLE
275 #define EM_ESV_ENABLE 0
276 #endif
277 
278 /**
279  * @def EM_DEBUG_PRINT
280  * Event Machine Debug Printouts
281  *
282  * '0': disabled
283  * '1': enabled
284  *
285  * @note em-odp: the 'EM_DEBUG_PRINT' value can be overridden by a command-line
286  * option to the 'configure' script, e.g.:
287  * $build> ../configure ... --enable-debug-print
288  * The overridden value will be made available to the application
289  * via a pkgconfig set define.
290  */
291 #ifndef EM_DEBUG_PRINT
292 #define EM_DEBUG_PRINT 0
293 #endif
294 
295 /**
296  * @def EM_EVENT_GROUP_SAFE_MODE
297  * Guards event groups in undefined and error situations
298  *
299  * Excess and aborted group events don't belong to a valid group when received.
300  * Most event group APIs check if the core local event group has expired during
301  * receive function. Impacts performance when event groups are used.
302  */
303 #define EM_EVENT_GROUP_SAFE_MODE 1
304 
305 /**
306  * @def EM_DEBUG_TIMESTAMP_ENABLE
307  * Enable Debug Timestamps for timing analysis. This may reduce performance
308  * but allows to trace dispatcher timings. Timestamps are per dispatcher (thread
309  * local).
310  *
311  * '0': disabled (default)
312  * '1': enabled, lower overhead but potentially inaccurate (no HW barriers)
313  * '2': enabled, strict version with full HW barriers
314  *
315  * @note em-odp: the 'EM_DEBUG_TIMESTAMP_ENABLE' value can be overridden by a command-line
316  * option to the 'configure' script, e.g.:
317  * $build> ../configure ... --enable-debug-timestamps=N
318  * The overridden value will be made available to the application
319  * via a pkgconfig set define. Use value 1 for lower overhead timestamps
320  * and value 2 for strict timestamp with HW barriers.
321  *
322  * @see event_machine_helper.h
323  */
324 #ifndef EM_DEBUG_TIMESTAMP_ENABLE
325 #define EM_DEBUG_TIMESTAMP_ENABLE 0
326 #endif
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #pragma GCC visibility pop
333 #endif /* EVENT_MACHINE_CONFIG_H */