From: Tobias Brunner Date: Wed, 20 May 2020 15:34:39 +0000 (+0200) Subject: object: Add helper for callbacks with two void pointers X-Git-Tag: 5.9.0rc1~8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d3d5235aaaa48fc6aeb5d81e2a21cdab54f804f;p=thirdparty%2Fstrongswan.git object: Add helper for callbacks with two void pointers --- diff --git a/src/libstrongswan/utils/utils/object.h b/src/libstrongswan/utils/utils/object.h index 24169dafcd..174ea812a1 100644 --- a/src/libstrongswan/utils/utils/object.h +++ b/src/libstrongswan/utils/utils/object.h @@ -123,4 +123,15 @@ static typeof(_cb_##name) *name = (typeof(_cb_##name)*)_cb_##name; \ static ret _cb_##name(param1, ##__VA_ARGS__) +/** + * Same as CALLBACK(), but for two void* arguments (e.g. for comparisons). + */ +#define CALLBACK2(name, ret, param1, param2, ...) \ + static ret _cb_##name(union {void *_generic; param1;} \ + __attribute__((transparent_union)), \ + union {void *_generic; param2;} \ + __attribute__((transparent_union)), ##__VA_ARGS__); \ + static typeof(_cb_##name) *name = (typeof(_cb_##name)*)_cb_##name; \ + static ret _cb_##name(param1, param2, ##__VA_ARGS__) + #endif /** OBJECT_H_ @} */