[PATCH 3/4] libmultipath: enable defining a static bitfield

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

The STATIC_BITFIELD macro allows defining a static variable holding
a bitfield of constant length.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/util.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libmultipath/util.h b/libmultipath/util.h
index 79d9f32..5a44018 100644
--- a/libmultipath/util.h
+++ b/libmultipath/util.h
@@ -82,6 +82,16 @@ struct bitfield {
 	bitfield_t bits[];
 };
 
+#define STATIC_BITFIELD(name, length)					\
+	static struct {							\
+		unsigned int len;					\
+		bitfield_t bits[((length) - 1) / bits_per_slot + 1];	\
+	} __static__ ## name = {					\
+		.len = (length),					\
+		.bits = { 0, },						\
+	}; \
+	struct bitfield *name = (struct bitfield *)& __static__ ## name
+
 struct bitfield *alloc_bitfield(unsigned int maxbit);
 
 void _log_bitfield_overflow(const char *f, unsigned int bit, unsigned int len);
-- 
2.35.1


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux