diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-20 15:36:20 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 91fc9294277db3702d72083279f20c4a10acff02 (patch) | |
tree | 133e33f3789856c175a9425d02159cc78827cc40 /src/basic/macro.h | |
parent | 370e2cb260e7d8d063e00f6917e76952131ec741 (diff) |
Add macro for checking if some flags are set
This way we don't need to repeat the argument twice.
I didn't replace all instances. I think it's better to leave out:
- asserts
- comparisons like x & y == x, which are mathematically equivalent, but
here we aren't checking if flags are set, but if the argument fits in the
flags.
Diffstat (limited to 'src/basic/macro.h')
-rw-r--r-- | src/basic/macro.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h index cd3ae8d3a..05f5e9fa6 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -357,6 +357,8 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { #define SET_FLAG(v, flag, b) \ (v) = (b) ? ((v) | (flag)) : ((v) & ~(flag)) +#define FLAGS_SET(v, flags) \ + (((v) & (flags)) == (flags)) #define CASE_F(X) case X: #define CASE_F_1(CASE, X) CASE_F(X) |