Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Type Function

MuslOnlyPadding

Private Type Function
std.c.MuslOnlyPadding
fn MuslOnlyPadding(endian: std.builtin.Endian) type

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.

File

c.zig:4175
4175
4176
4177
fn MuslOnlyPadding(endian: std.builtin.Endian) type {
    return if (builtin.abi.isMusl() and @sizeOf(usize) == 8 and native_endian == endian) u32 else u0;
}