3 ms·
In TXR Lisp's FFI, I developed detailed support for bitfields, alignment and packing. You can comply with any kind of struct type no matter how it's declared.
by kazinator 9y ago
In TXR Lisp's FFI, I developed detailed support for bitfields, alignment and packing. You can comply with any kind of struct type no matter how it's declared.
In the reference manual, I added a section on what I believe are the bitfield allocation rules used by GCC, as I empirically reverse engineered them.
https://www.nongnu.org/txr/txr-manpage.html#N-027D075C https://www.nongnu.org/txr/txr-manpage.html#N-027D075C
Hope someone finds it useful.
Endian considerations are not covered in that section because that topic is documented elsewhere in the document.
In a nutshell, on big endian, bitfields are packed from the most significant end of the storage word, and on little endian, from the least significant end of the storage word. Thus the lowest addressed byte of the storage unit is filled first, and so on.