summaryrefslogtreecommitdiff
path: root/src/shared/macro.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-12 22:26:22 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-12 22:26:22 +0100
commitdc36d78e116a7ce4a119a527299785025c925679 (patch)
tree5210b0fcf55650b6d6974e454a420c5a280b81f3 /src/shared/macro.h
parent0d292f5e7597a729365644edfbcdf2e5fac8beb4 (diff)
macro: make sure we can use IN_SET() also with complex function calls as first argument
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r--src/shared/macro.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 08a036b3b9..d53b07fea5 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -324,13 +324,14 @@ do { \
#define SET_FLAG(v, flag, b) \
(v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))
-#define IN_SET(x, ...) \
+#define IN_SET(x, y, ...) \
({ \
- const typeof(x) _x = (x); \
+ const typeof(y) _y = (y); \
+ const typeof(_y) _x = (x); \
unsigned _i; \
bool _found = false; \
- for (_i = 0; _i < sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \
- if (((const typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \
+ for (_i = 0; _i < 1 + sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \
+ if (((const typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \
_found = true; \
break; \
} \