diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2014-08-14 11:28:47 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-08-14 11:28:47 -0400 |
commit | 28744043fbaca39dfc9fd1666a8557fd6d8a690f (patch) | |
tree | f0cf30fe98f3e7e535be23c3954973ef02c58e49 /src/shared/macro.h | |
parent | 819fb6029dde2af3acf23b0fa25c1851b26ce102 (diff) |
src/shared: import many code cleanups from upstream
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared/macro.h')
-rw-r--r-- | src/shared/macro.h | 13 |
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 */ |