diff options
author | Thomas Haller <thaller@redhat.com> | 2014-10-31 21:57:21 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-11-05 23:49:54 +0100 |
commit | 776f8e4d06869218f03db651117579e3c8be9387 (patch) | |
tree | f1a7db11d25c706fafaeafd5393a844a4c3e2575 | |
parent | fb78b671d71ec7b6a0bef5e1c1497a9aded687bc (diff) | |
download | NetworkManager-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.h | 15 |
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 |