Page MenuHomeFreeBSD

D6226.id15964.diff
No OneTemporary

D6226.id15964.diff

Index: sys/sys/_bitset.h
===================================================================
--- sys/sys/_bitset.h
+++ sys/sys/_bitset.h
@@ -58,4 +58,12 @@
#define BITSET_FSET(n) \
[ 0 ... ((n) - 1) ] = (-1L)
+/*
+ * 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_ */
Index: sys/sys/bitset.h
===================================================================
--- sys/sys/bitset.h
+++ sys/sys/bitset.h
@@ -185,5 +185,13 @@
__count += __bitcountl((p)->__bits[__i]); \
__count; \
})
-
+
+/*
+ * Dynamically allocate a bitset.
+ *
+ * NB: p must be cleaned by the caller by freeing it after use.
+ */
+#define BITSET_ALLOC(p, _s, mt, mf) \
+ p = malloc(__bitset_words(_s) * sizeof(long), mt, mf)
+
#endif /* !_SYS_BITSET_H_ */

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 20, 7:37 AM (18 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30007670
Default Alt Text
D6226.id15964.diff (994 B)

Event Timeline