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

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

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

Visibility: public

Requested revision: 961961cf85618083702799ef60f9f77dec806774

Requested commit: 961961cf85618083702799ef60f9f77dec806774

Commit: 961961cf85618083702799ef60f9f77dec806774

Tree: e1d9725761771c3ad79379c1e4a526796f5a6487

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

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

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