From 941c1f929a871a674b430213e9e8fadcabe925f1 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 22 Mar 2011 23:18:03 +0100 Subject: [PATCH] Adds bit operation functions. --- util.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/util.h b/util.h index 2deb3533..6545aa40 100644 --- a/util.h +++ b/util.h @@ -94,6 +94,24 @@ void pathprint(char* str, size_t size, const char* format, ...); */ void pathslash(char* str, size_t size); +/****************************************************************************/ +/* bit */ + +static inline int bit_has(unsigned bit, unsigned mask) +{ + return (bit & mask) == mask; +} + +static inline unsigned bit_set(unsigned bit, unsigned mask) +{ + return bit | mask; +} + +static inline unsigned bit_clear(unsigned bit, unsigned mask) +{ + return bit & ~mask; +} + /****************************************************************************/ /* memory */