3 ms·
The implementation isn't endian friendly :(
by zgs 5y ago
The implementation isn't endian friendly :(
- alcover 5y ago(author) Is it because of bitfields ? Should I rather use a full 64bit data field and mask it to get to my flags ?
- zgs 5y agoThe first thing that stuck me was distinguishing the `SSO' part of the union from the rest. It requires the `ssolen' field to align to the later `type' field which isn't guaranteed. There might also be issues with the `data' field if padding gets introduced. Having the `type' field (as a uint8_t or char) first would solve this but loses some bits of storage. The other option would be making the type an array of char and bit bashing everything (and memcpy(2) multibyte fields since unaligned accesses aren't universal).