autopad

Adds the autopad! proc macro, allowing for structs to be defined with fields at specified offsets.

```Rust autopad!(

[repr(C)] // Needed to preserve field orders

struct WithPadding { root: u8, // At offset 0x0 0x100 => partwayin: u32, afteroffset: u32, // At 0x104 0x200 => final_field: u8, }

); ```

The macro will fill the struct with appropriate padding arrays such that each field is properly offset in the result.

The intended use case for this is for structs that represent MMIO devices with sparsely allocated or large gaps between registers.

Limitations

Some of these are fixable, PRs are welcome.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.