There are several instances of struct fields that POSIX defines as either int or socklen_t, but on Linux are size_t. glibc ignores POSIX, and uses the Linux kernel's definitions. musl on the other hand aims to be POSIX-ly correct, and defines those fields in a manner aligning with POSIX.
musl works around this incompatibility between the 64-bit Linux ABI and the POSIX specification by adding padding fields on either side depending on host endianness:
#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN int __pad2; #endif socklen_t msg_controllen; #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN int __pad2; #endif
To emulate this quirk of musl, the MuslOnlyPadding field is used in these structs
pad0: MuslOnlyPadding(.big) = 0, msg_controllen: socklen_t, pad1: MuslOnlyPadding(.little) = 0,
On 32-bit and non-musl systems, these fields will be zero sized, and ignored.
fn MuslOnlyPadding(endian: std.builtin.Endian) type
fn MuslOnlyPadding(endian: std.builtin.Endian) type {
return if (builtin.abi.isMusl() and @sizeOf(usize) == 8 and native_endian == endian) u32 else u0;
}