summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-10-31 21:57:21 +0100
committerThomas Haller <thaller@redhat.com>2014-11-05 23:49:54 +0100
commit776f8e4d06869218f03db651117579e3c8be9387 (patch)
treef1a7db11d25c706fafaeafd5393a844a4c3e2575
parentfb78b671d71ec7b6a0bef5e1c1497a9aded687bc (diff)
downloadNetworkManager-776f8e4d06869218f03db651117579e3c8be9387.tar.gz
all: add macro NM_IN_SET
Copied from systemd's macro IN_SET from /src/shared/macro.h Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--include/nm-utils-internal.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/nm-utils-internal.h b/include/nm-utils-internal.h
index 4f5850aace..69ab8391be 100644
--- a/include/nm-utils-internal.h
+++ b/include/nm-utils-internal.h
@@ -82,4 +82,19 @@
/********************************************************/
+#define NM_IN_SET(x, y, ...) \
+ ({ \
+ const typeof(y) _y = (y); \
+ typeof(_y) _x = (x); \
+ unsigned _i; \
+ gboolean _found = FALSE; \
+ for (_i = 0; _i < 1 + sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) { \
+ if (((typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \
+ _found = TRUE; \
+ break; \
+ } \
+ } \
+ _found; \
+ })
+
#endif