# std: fix msghdr and cmsghdr when using musl libc · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/062d17ccab495d63799e3ac8831eed485ca8cffe)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 062d17ccab495d63799e3ac8831eed485ca8cffe

Requested commit: 062d17ccab495d63799e3ac8831eed485ca8cffe

Commit: 062d17ccab495d63799e3ac8831eed485ca8cffe

Tree: 4699f832c8636c72644fe3b5fd3d1ef1f4e0ab42

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std: fix msghdr and cmsghdr when using musl libc

glibc and linux kernel use size_t for some field lengths while POSIX and
musl use int. This bug would have caused breakage the first time someone
tried to call sendmsg on a 64-bit big endian system when linking musl
libc.

my opinion:
* msghdr.iovlen: kernel and glibc have it right. This field should
  definitely be size_t. With int, the padding bytes are wasted for no
  reason.
* msghdr.controllen: POSIX and musl have it right. 4 bytes is plenty for
  the length, and it saves 4 bytes next to flags.
* cmsghdr.len: POSIX and musl have it right. 4 bytes is plenty for the
  length, and it saves 4 bytes since the other fields are also 32-bits
  each.

```

## Parents

- [96cf75977bd46ccf4d0626183bc1d9e3e5d80eac](https://git.cafe/gitcafe/zig/commit/96cf75977bd46ccf4d0626183bc1d9e3e5d80eac?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/062d17ccab495d63799e3ac8831eed485ca8cffe?format=markdown)
