5 ms·
Why is struct ip_weight padded.. is it to make it word aligned on 64-bit platforms?
by senatorobama 8y ago
Why is struct ip_weight padded.. is it to make it word aligned on 64-bit platforms?
- blattimwind 8y agoin_addr_t is a 32 bit integer. On 64 bit archs this will usually result in a 32 bit padding for word alignment.
- deleted 8y ago[deleted]
- pandaman 8y agoTo align 'weight' member on its size.
- senatorobama 8y agoso the pad will be before the 'weight' member in memory?
- tardo99 8y agoYes. See here: https://stackoverflow.com/questions/4306186/structure-padding-and-packing https://stackoverflow.com/questions/4306186/structure-paddin...
- bluecalm 8y agoPadding is needed for two reasons: 8 bytes element need to start at multiple of 8 bytes address and to make the whole struct size multiple of the biggest member. This is needed for alignment once those structs are need to each other for example in an array.