X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fnotmuch-private.h;h=b86897c2031195a6bfa9d85ab4a5602204335315;hp=36cc12b0df123c7a0eb79c0d81f8b40db9650d79;hb=d99491f27440d83f937131a861ca547bffb8bdf1;hpb=d9f5da00bb7707f3244654b4e44df2284e3634be diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 36cc12b0..b86897c2 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -63,6 +63,17 @@ NOTMUCH_BEGIN_DECLS #define STRNCMP_LITERAL(var, literal) \ strncmp ((var), (literal), sizeof (literal) - 1) +/* Robust bit test/set/reset macros */ +#define NOTMUCH_TEST_BIT(val, bit) \ + (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? 0 \ + : !!((val) & (1ull << (bit)))) +#define NOTMUCH_SET_BIT(valp, bit) \ + (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \ + : (*(valp) |= (1ull << (bit)))) +#define NOTMUCH_CLEAR_BIT(valp, bit) \ + (((bit) < 0 || (bit) >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \ + : (*(valp) &= ~(1ull << (bit)))) + #define unused(x) x __attribute__ ((unused)) #ifdef __cplusplus