diff --git a/sys/sys/_bitset.h b/sys/sys/_bitset.h index 86cf539c5abb..2f5301d58a5d 100644 --- a/sys/sys/_bitset.h +++ b/sys/sys/_bitset.h @@ -47,4 +47,12 @@ struct t { \ long __bits[__bitset_words((_s))]; \ } +/* + * Helper to declare a bitset without it's size being a constant. + * + * Sadly we cannot declare a bitset struct with '__bits[]', because it's + * the only member of the struct and the compiler complains. + */ +#define BITSET_DEFINE_VAR(t) BITSET_DEFINE(t, 1) + #endif /* !_SYS__BITSET_H_ */ diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index f1c7bf8e0e6d..723c39b0a2cf 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -199,4 +199,10 @@ #define BITSET_FSET(n) \ [ 0 ... ((n) - 1) ] = (-1L) +/* + * Dynamically allocate a bitset. + */ +#define BITSET_ALLOC(_s, mt, mf) \ + malloc(__bitset_words(_s) * sizeof(long), mt, (mf)) + #endif /* !_SYS_BITSET_H_ */