summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-06-04 15:00:21 +0200
committerThomas Haller <thaller@redhat.com>2021-06-08 08:24:11 +0200
commit34a521e2d6471743692e60983b68b56fe35d85fc (patch)
tree37a5d56c37af19bdd9a8020470d20c9acdd102a5
parentdadaba9ab65eab1ba917a2c59bb6d519aa750abe (diff)
downloadNetworkManager-34a521e2d6471743692e60983b68b56fe35d85fc.tar.gz
std-aux: add NM_VA_ARGS_JOIN() helper macro
We have variadic macros like NM_UTILS_ENUM2STR() that create a switch statement. Their implementation relies on the way how __VA_ARGS__ gets expanded to a comma separated list. But that implementation is not great. Let's instead add (and later use) NM_VA_ARGS_JOIN() which can join variadic arguments by a configurable separator.
-rw-r--r--src/libnm-std-aux/nm-std-aux.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h
index 56ec7a1e4e..f14a81346a 100644
--- a/src/libnm-std-aux/nm-std-aux.h
+++ b/src/libnm-std-aux/nm-std-aux.h
@@ -618,6 +618,10 @@ nm_streq0(const char *s1, const char *s2)
/*****************************************************************************/
+#define NM_VA_ARGS_JOIN(sep, ...) NM_VA_ARGS_FOREACH(, , sep, _NM_MACRO_SELECT_FIRST, __VA_ARGS__)
+
+/*****************************************************************************/
+
#define _NM_IN_SET_EVAL_1(op, _x, y) (_x == (y))
#define _NM_IN_SET_EVAL_2(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_1(op, _x, __VA_ARGS__)
#define _NM_IN_SET_EVAL_3(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_2(op, _x, __VA_ARGS__)