summaryrefslogtreecommitdiff
path: root/backport-include/backport/magic.h
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2017-11-21 12:59:41 +0000
committerDominik Sliwa <dominik.sliwa@toradex.com>2017-12-22 09:40:23 +0000
commite34cb44ac7c08783b98a16eec70125e205e6eb12 (patch)
tree1101d23f1a73e5627ae187b07c7a0cf8826e10d1 /backport-include/backport/magic.h
initial commit
Generated againts 4.14 kernel source with git backports 1d8cc151d365582b42be00af776270b834a7a37d
Diffstat (limited to 'backport-include/backport/magic.h')
-rw-r--r--backport-include/backport/magic.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/backport-include/backport/magic.h b/backport-include/backport/magic.h
new file mode 100644
index 0000000..d7e7cc9
--- /dev/null
+++ b/backport-include/backport/magic.h
@@ -0,0 +1,16 @@
+/*
+ * These tricks are taken from
+ * http://efesx.com/2010/07/17/variadic-macro-to-count-number-of-arguments/
+ * and
+ * http://efesx.com/2010/08/31/overloading-macros/
+ */
+
+#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 6,5,4,3,2,1)
+#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,_6,N,...) N
+
+#define macro_dispatcher(func, ...) \
+ macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
+#define macro_dispatcher_(func, nargs) \
+ macro_dispatcher__(func, nargs)
+#define macro_dispatcher__(func, nargs) \
+ func ## nargs