shl: misc: add SHL_HAS_BITS() helper
authorDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 1 Oct 2012 10:21:10 +0000 (12:21 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 1 Oct 2012 10:21:10 +0000 (12:21 +0200)
This helper checks whether a bitmask has all the given bits set.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/shl_misc.h

index 724a7c0..47bee10 100644 (file)
@@ -38,6 +38,8 @@
 #include <stdlib.h>
 #include <xkbcommon/xkbcommon.h>
 
+#define SHL_HAS_BITS(_bitmask, _bits) (((_bitmask) & (_bits)) == (_bits))
+
 static inline int shl_strtou(const char *input, unsigned int *output)
 {
        unsigned long val;