feat: bitfield struct translate#34
Conversation
|
C structs cannot be translated as packed structs, instead bitfields that are part of the same host byte should be translated as a packed struct that is part of the larger struct: struct S {
int arr[4];
int a: 12;
int b: 12;
int :0;
int c: 12;
};pub const struct_S = extern struct {
arr: [4]c_int = @import("std").mem.zeroes([4]c_int),
bitfield: packed struct(c_int) {
a: i12 = 0,
b: i12 = 0,
_pad: u8 = 0,
} = .{},
bitfield1: packed struct(c_int) {
c: i12 = 0,
_pad: u20 = 0,
} = .{},
}; |
So is it. Any helpful reference could we have? or more testcases. |
|
ok i'm stupid, arocc already ship it. |
|
@GreyElaina incredible work, what is the status of that draft PR ? |
eh, i just borrowed these values from arocc itself. it's hard (and too busy for me) to write a comprehensive verifier to, at least, fuzz test it. |
Basically copied from https://github.com/mahkoh/repr-c/tree/master/repc/impl/src/builder.
Required to build a cross-verifier to fit existing behavior.