diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2016-08-18 00:03:29 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2016-08-18 00:03:29 +0000 |
commit | 7f937e3781f36538d9864fa841822eecdaf0bf27 (patch) | |
tree | 318eb592dae2bbf59d094f5df140c24a4b6184c9 /src/include/gnunet_mq_lib.h | |
parent | 94a717fab18ed25e6bec4b349526212045f6ca70 (diff) | |
download | gnunet-7f937e3781f36538d9864fa841822eecdaf0bf27.tar.gz gnunet-7f937e3781f36538d9864fa841822eecdaf0bf27.zip |
Use statement exprs instead of local function
This change lets us compile with clang again.
Diffstat (limited to 'src/include/gnunet_mq_lib.h')
-rw-r--r-- | src/include/gnunet_mq_lib.h | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index d383adbb5..86144abca 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -323,27 +323,26 @@ struct GNUNET_MQ_MessageHandler | |||
323 | * const struct GNUNET_MessageTest *msg) | 323 | * const struct GNUNET_MessageTest *msg) |
324 | * { ... } | 324 | * { ... } |
325 | * | 325 | * |
326 | * GNUNET_MQ_hd_fixed_size(test_message, | ||
327 | * GNUNET_MESSAGE_TYPE_TEST, | ||
328 | * struct GNUNET_MessageTest); | ||
329 | * struct GNUNET_MQ_MessageHandler handlers[] = { | 326 | * struct GNUNET_MQ_MessageHandler handlers[] = { |
330 | * make_test_message_handler (NULL), | 327 | * GNUNET_MQ_hd_fixed_size(test_message, |
328 | * GNUNET_MESSAGE_TYPE_TEST, | ||
329 | * struct GNUNET_MessageTest, | ||
330 | * "context"), | ||
331 | * GNUNET_MQ_handler_end() | 331 | * GNUNET_MQ_handler_end() |
332 | * }; | 332 | * }; |
333 | * | 333 | * |
334 | * @param name unique basename for the functions | 334 | * @param name unique basename for the functions |
335 | * @param code message type constant | 335 | * @param code message type constant |
336 | * @param str type of the message (a struct) | 336 | * @param str type of the message (a struct) |
337 | * @param ctx context for the callbacks | ||
337 | */ | 338 | */ |
338 | #define GNUNET_MQ_hd_fixed_size(name,code,str) \ | 339 | #define GNUNET_MQ_hd_fixed_size(name,code,str,ctx) \ |
339 | struct GNUNET_MQ_MessageHandler \ | 340 | ({ \ |
340 | make_##name##_handler (void *cls) { \ | 341 | void (*_cb)(void *cls, const str *msg) = &handle_##name; \ |
341 | void (*cb)(void *cls, const str *msg) = &handle_##name; \ | 342 | ((struct GNUNET_MQ_MessageHandler) { \ |
342 | struct GNUNET_MQ_MessageHandler mh = { \ | 343 | NULL, (GNUNET_MQ_MessageCallback) _cb, \ |
343 | NULL, (GNUNET_MQ_MessageCallback) cb, \ | 344 | (ctx), (code), sizeof (str) }); \ |
344 | cls, code, sizeof (str) }; \ | 345 | }) |
345 | return mh; \ | ||
346 | } | ||
347 | 346 | ||
348 | 347 | ||
349 | /** | 348 | /** |
@@ -356,9 +355,6 @@ struct GNUNET_MQ_MessageHandler | |||
356 | * The macro is to be used as follows: | 355 | * The macro is to be used as follows: |
357 | * <code> | 356 | * <code> |
358 | * struct GNUNET_MessageTest { ... }; // can be variable size | 357 | * struct GNUNET_MessageTest { ... }; // can be variable size |
359 | * GNUNET_MQ_hd_var_size(test_message, | ||
360 | * GNUNET_MESSAGE_TYPE_TEST, | ||
361 | * struct GNUNET_MessageTest); | ||
362 | * static int | 358 | * static int |
363 | * check_test (void *cls, | 359 | * check_test (void *cls, |
364 | * const struct GNUNET_MessageTest *msg) | 360 | * const struct GNUNET_MessageTest *msg) |
@@ -377,25 +373,27 @@ struct GNUNET_MQ_MessageHandler | |||
377 | * } | 373 | * } |
378 | * | 374 | * |
379 | * struct GNUNET_MQ_MessageHandler handlers[] = { | 375 | * struct GNUNET_MQ_MessageHandler handlers[] = { |
380 | * make_test_message_handler ("context"), | 376 | * GNUNET_MQ_hd_var_size(test_message, |
377 | * GNUNET_MESSAGE_TYPE_TEST, | ||
378 | * struct GNUNET_MessageTest, | ||
379 | * "context"), | ||
381 | * GNUNET_MQ_handler_end() | 380 | * GNUNET_MQ_handler_end() |
382 | * }; | 381 | * }; |
383 | * | 382 | * |
384 | * @param name unique basename for the functions | 383 | * @param name unique basename for the functions |
385 | * @param code message type constant | 384 | * @param code message type constant |
386 | * @param str type of the message (a struct) | 385 | * @param str type of the message (a struct) |
387 | */ | 386 | * @param ctx context for the callbacks |
388 | #define GNUNET_MQ_hd_var_size(name,code,str) \ | 387 | */ |
389 | struct GNUNET_MQ_MessageHandler \ | 388 | #define GNUNET_MQ_hd_var_size(name,code,str,ctx) \ |
390 | make_##name##_handler (void *ctx) { \ | 389 | ({ \ |
391 | int (*mv)(void *cls, const str *msg) = &check_##name; \ | 390 | int (*_mv)(void *cls, const str *msg) = &check_##name; \ |
392 | void (*cb)(void *cls, const str *msg) = &handle_##name;\ | 391 | void (*_cb)(void *cls, const str *msg) = &handle_##name; \ |
393 | struct GNUNET_MQ_MessageHandler mh = \ | 392 | ((struct GNUNET_MQ_MessageHandler) \ |
394 | { (GNUNET_MQ_MessageValidationCallback) mv, \ | 393 | { (GNUNET_MQ_MessageValidationCallback) _mv, \ |
395 | (GNUNET_MQ_MessageCallback) cb, \ | 394 | (GNUNET_MQ_MessageCallback) _cb, \ |
396 | ctx, code, sizeof (str) }; \ | 395 | (ctx), (code), sizeof (str) }); \ |
397 | return mh; \ | 396 | }) |
398 | } | ||
399 | 397 | ||
400 | 398 | ||
401 | /** | 399 | /** |