summaryrefslogtreecommitdiff
path: root/src/shared/macro.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r--src/shared/macro.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 2deaf04092..3e02d86b5c 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -173,6 +173,19 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
sizeof(type) <= 2 ? 5 : \
sizeof(type) <= 4 ? 10 : \
sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
+#define IN_SET(x, y, ...) \
+ ({ \
+ const typeof(y) _y = (y); \
+ const typeof(_y) _x = (x); \
+ unsigned _i; \
+ bool _found = false; \
+ 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; \
+ } \
+ _found; \
+ })
/* Define C11 thread_local attribute even on older gcc compiler
* version */