zig
zig copied to clipboard
Introduce `std.mem.readPackedInt` and improve bitcasting of packed memory layouts
Packed memory has a well-defined layout that doesn't require actually using a BigInt to read from. Let's use it :-)
Included changes:
- Adds
readPackedInt
,writePackedInt
and friends tostd.mem
- Adds support for casting to packed enums and vectors
- (follow-up to #13124)
- Fixes bitcasting to/from vectors outside of a packed struct
- Adds a fast path for bitcasting <= u/i64
- Fixes bug when bitcasting f80 which would clear following fields
So far writePackedIntLittle and writePackedIntBig have no test coverage testing them against another and it would be nice to reverse the ints with byteswap to ensure both work as expected. At least, if that is feasible.
I think this is already covered. writePackedIntLittle/Big
are tested through writePackedInt
, including foreign endianness with byte swaps.