On 12/05/2011 04:41 PM, Bill Meier wrote:
For example: Given struct radiotap_override { guint8 field; guint align:4, size:4; } aaa;struct radiotap_override { guint8 field; guint8 align:4, size:4; } bbb; It turns out that: sizeof(aaa) = 8 sizeof(bbb) = 2 Apparently the alignment of the start of the bitfield depends upon the (largest ?) bitfield type;
In the 'aaa' structure the compiler will (normally) insert 3 bytes of padding between 'field' and the bitfields so that the guint is 4-byte aligned; improper alignment isn't allowed on some CPUs (like SPARC) and is slow (often/always? requiring 2 memory access cycles to read) on others.
___________________________________________________________________________ Sent via: Wireshark-dev mailing list <[email protected]> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:[email protected]?subject=unsubscribe
