Commit e0a514df41

Silver <silver@silv.re>
2021-12-24 06:38:14
std: make IntegerBitSet and ArrayBitSet have defined memory layout
This is useful for wrapping C libraries and native interfaces that make use of bit sets
1 parent 67c4b16
Changed files (1)
lib
lib/std/bit_set.zig
@@ -50,7 +50,7 @@ pub fn StaticBitSet(comptime size: usize) type {
 /// This set is good for sets with a small size, but may generate
 /// inefficient code for larger sets, especially in debug mode.
 pub fn IntegerBitSet(comptime size: u16) type {
-    return struct {
+    return packed struct {
         const Self = @This();
 
         // TODO: Make this a comptime field once those are fixed
@@ -287,7 +287,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
             ", which contains padding bits.  Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
     }
 
-    return struct {
+    return extern struct {
         const Self = @This();
 
         // TODO: Make this a comptime field once those are fixed