]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
object: Add helper for callbacks with two void pointers
authorTobias Brunner <tobias@strongswan.org>
Wed, 20 May 2020 15:34:39 +0000 (17:34 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 20 Jul 2020 12:05:39 +0000 (14:05 +0200)
src/libstrongswan/utils/utils/object.h

index 24169dafcd83fc7168c10f9f900f61f905ff0d51..174ea812a14330a88bff2509ff45beb7614f5132 100644 (file)
        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_ @} */