128 #ifndef TOR_DISPATCH_MSG_H
129 #define TOR_DISPATCH_MSG_H
173 #define DECLARE_MESSAGE_COMMON__(messagename, typename, c_type) \
174 typedef c_type msg_arg_type__ ##messagename; \
175 typedef const c_type msg_arg_consttype__ ##messagename; \
176 ATTR_UNUSED static const char msg_arg_name__ ##messagename[] = # typename;
192 #define DECLARE_MESSAGE(messagename, typename, c_ptr_type) \
193 DECLARE_MESSAGE_COMMON__(messagename, typename, c_ptr_type) \
194 ATTR_UNUSED static inline c_ptr_type \
195 msg_arg_get__ ##messagename(msg_aux_data_t m) \
199 ATTR_UNUSED static inline void \
200 msg_arg_set__ ##messagename(msg_aux_data_t *m, c_ptr_type v) \
219 #define DECLARE_MESSAGE_INT(messagename, typename, c_type) \
220 DECLARE_MESSAGE_COMMON__(messagename, typename, c_type) \
221 ATTR_UNUSED static inline c_type \
222 msg_arg_get__ ##messagename(msg_aux_data_t m) \
224 return (c_type)m.u64; \
226 ATTR_UNUSED static inline void \
227 msg_arg_set__ ##messagename(msg_aux_data_t *m, c_type v) \
229 m->u64 = (uint64_t)v; \
245 #define DECLARE_PUBLISH(messagename) \
246 static pub_binding_t pub_binding__ ##messagename; \
248 publish_fn__ ##messagename(msg_arg_type__ ##messagename arg) \
250 msg_aux_data_t data; \
251 msg_arg_set__ ##messagename(&data, arg); \
252 pubsub_pub_(&pub_binding__ ##messagename, data); \
272 #define DECLARE_SUBSCRIBE(messagename, hookfn) \
273 static void hookfn(const msg_t *, \
274 const msg_arg_consttype__ ##messagename); \
275 static void recv_fn__ ## messagename(const msg_t *m) \
277 msg_arg_type__ ## messagename arg; \
278 arg = msg_arg_get__ ##messagename(m->aux_data__); \
287 #define DISPATCH__FAKE_USE_OF_PUBFN_(messagename) \
288 ( 0 ? (publish_fn__ ##messagename((msg_arg_type__##messagename)0), 1) \
294 #define DISPATCH_ADD_PUB_(connector, channel, messagename, flags) \
296 DISPATCH__FAKE_USE_OF_PUBFN_(messagename), \
297 pubsub_add_pub_((connector), \
298 &pub_binding__ ##messagename, \
299 get_channel_id(# channel), \
300 get_message_id(# messagename), \
301 get_msg_type_id(msg_arg_name__ ## messagename), \
313 #define DISPATCH_ADD_PUB(connector, channel, messagename) \
314 DISPATCH_ADD_PUB_(connector, channel, messagename, 0)
322 #define DISPATCH_ADD_PUB_EXCL(connector, channel, messagename) \
323 DISPATCH_ADD_PUB_(connector, channel, messagename, DISP_FLAG_EXCL)
328 #define DISPATCH_ADD_SUB_(connector, channel, messagename, flags) \
329 pubsub_add_sub_((connector), \
330 recv_fn__ ##messagename, \
331 get_channel_id(#channel), \
332 get_message_id(# messagename), \
333 get_msg_type_id(msg_arg_name__ ##messagename), \
343 #define DISPATCH_ADD_SUB(connector, channel, messagename) \
344 DISPATCH_ADD_SUB_(connector, channel, messagename, 0)
352 #define DISPATCH_ADD_SUB_EXCL(connector, channel, messagename) \
353 DISPATCH_ADD_SUB_(connector, channel, messagename, DISP_FLAG_EXCL)
359 #define PUBLISH(messagename, arg) \
360 publish_fn__ ##messagename(arg)
366 #define DISPATCH_REGISTER_TYPE(con, type, fns) \
367 pubsub_connector_register_type_((con), \
368 get_msg_type_id(#type), \
Utility macros to handle different features and behavior in different compilers.
Header for dispatch_naming.c.
Declaration of pub_binding_t.
Header for functions that add relationships to a pubsub builder.
Flags that can be set on publish/subscribe messages.
Header for pubsub_publish.c.