From 146fa7e79e8fa39648c6d5baec7fe704502c59bd Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 6 Apr 2019 06:37:22 +0000 Subject: [PATCH] Add simple bitmap manipulation functions git-svn-id: https://svn.eduke32.com/eduke32@7475 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/compat.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 926e6639f..a49e2c5b5 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -1119,6 +1119,11 @@ static inline void append_ext_UNSAFE(char *outbuf, const char *ext) Bstrcpy(p, ext); } +////////// Bitfield manipulation ////////// + +static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n >> 3] |= 1 << (n & 7); } +static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n >> 3] &= ~(1 << (n & 7)); } +static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); } /* Begin dependence on compat.o object. */