aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils.h
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2010-01-21 14:42:08 +0100
committerMartin Willi <martin@strongswan.org>2010-01-21 14:42:08 +0100
commit23d2bf84a3741a375050d390fa99afeca43a07c4 (patch)
tree6eda2fd488e9801fdd10335d18634bde4eccbec9 /src/libstrongswan/utils.h
parent47498044c34356199db5bdc63ca9facca0e39403 (diff)
downloadstrongswan-23d2bf84a3741a375050d390fa99afeca43a07c4.tar.bz2
strongswan-23d2bf84a3741a375050d390fa99afeca43a07c4.tar.xz
Added a METHOD2() macro that implements a method for two different interfaces
Diffstat (limited to 'src/libstrongswan/utils.h')
-rw-r--r--src/libstrongswan/utils.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h
index e744f39a5..964cbd1d2 100644
--- a/src/libstrongswan/utils.h
+++ b/src/libstrongswan/utils.h
@@ -123,7 +123,17 @@
* _name is provided a function pointer, but will get optimized out by GCC.
*/
#define METHOD(iface, name, ret, this, ...) \
- static ret name(union {iface *_public; this;} __attribute__((transparent_union)), ##__VA_ARGS__); \
+ static ret name(union {iface *_public; this;} \
+ __attribute__((transparent_union)), ##__VA_ARGS__); \
+ const static typeof(name) *_##name = (const typeof(name)*)name; \
+ static ret name(this, ##__VA_ARGS__)
+
+/**
+ * Same as METHOD(), but is defined for two public interfaces.
+ */
+#define METHOD2(iface1, iface2, name, ret, this, ...) \
+ static ret name(union {iface1 *_public1; iface2 *_public2; this;} \
+ __attribute__((transparent_union)), ##__VA_ARGS__); \
const static typeof(name) *_##name = (const typeof(name)*)name; \
static ret name(this, ##__VA_ARGS__)