Skip to content

Commit

Permalink
unix: fix send/recvmmsg when using musl
Browse files Browse the repository at this point in the history
This one is great. The whole unix world uses an int for the flags, and
documents it as such. But musl uses an unsigned int there [1], while
still documenting a signed int.

This API is cursed.

[1]: https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h?id=39838619bb8b65a8897abcfda8c17ad6de0115d8#n70
  • Loading branch information
Tuetuopay committed Feb 8, 2024
1 parent 338edb2 commit b8670dc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,16 @@ pub(crate) fn recvmmsg(
msgs.inner.len() as u32
}
},
flags,
{
#[cfg(target_env = "musl")]
{
flags as u32
}
#[cfg(not(target_env = "musl"))]
{
flags as i32
}
},
ptr::null_mut()
))
.map(|n| n as usize)
Expand Down Expand Up @@ -1195,7 +1204,16 @@ pub(crate) fn sendmmsg(fd: Socket, msgs: &MmsgHdr<'_, '_, '_>, flags: c_int) ->
msgs.inner.len() as u32
}
},
flags
{
#[cfg(target_env = "musl")]
{
flags as u32
}
#[cfg(not(target_env = "musl"))]
{
flags as i32
}
},
))
.map(|n| n as usize)
}
Expand Down

0 comments on commit b8670dc

Please sign in to comment.