If you're referring to `__pad2` in the example, that trailing padding is there to ensure that the size of the struct is a multiple of its alignment, which is 8, so that if there's a contiguous span of those structures, each instance after the first one will remained properly aligned. Without `__pad2`, that struct would be 36-bytes, which would cause every other instance in an array/contiguous-span to be aligned on 4 bytes instead of 8.
In the example from the article, the "s_arc" member is a pointer (8 bytes) and requires an alignment at an 8-byte boundary. The ints are 4 bytes in size. The whole struct needs to be aligned on an 8-byte boundary, in order to preserve the alignment requirements of the pointers. The trailing "s_accept" member requires additional padding to make the size of the struct divisible by 8, and that would preserve the alignment of an eventual second adjacent struct, when having an array of these structs.
I would also generally like to avoid being on-call for a system that is being pushed to its limits or used outside the parameters it was designed for.
I am very curious to hear if anyone is shipping cosmopolitan-libc/Actually-portable-executable binaries, either internally or for consumption by end users. I would love to hear more about the experience!
If Justine didn't optimize struct padding, binaries would be a bit larger, but software would keep working. However, if a trivial library like left-pad is gone, it triggers global chaos of such monumental proportions that it warrants its own Wikipedia article https://en.wikipedia.org/wiki/Npm_left-pad_incident
Or there might be some unsung hero responsible for fixing a year 2038 bug in a bunch of ICBMs who prevented worldwide nuclear annihilation (or who caused it, if you have a more pessimistic view of the future).
Alos, don't go rearranging the members of your structs if they're made public to third-parties!
could you elaborate? who is pushing and what?
dynamic linking has it pitfalls, often it's a pain, but it has big big profits as well.
> could you elaborate? who is pushing and what?
I don't know of a more general movement, but Go developers seem very eager/proud about the single-binary thing. It can make deployments, particularly updates, much less issue prone.
Containers offer some tooling for resource management and such, though that is basically wrappers and other syntactic sugar dressing up OS facilities like resource groups so isn't anything you can't do with a statically linked binary too.
Also, not what you asked but certainly related, some lower-language levels (not just jit languages) can and do automatically re-arrange struct members (when not optionally fixed); e.g. by default rust will rearrange members as needed to optimize padding.