Skip to content

Commit 61c23fb

Browse files
nodakaitokenrove
authored andcommitted
Add Linux-specific recvmmsg(2) and sendmmsg(2)
There is a compatibility issue regarding the type of a flag parameter: int vs uint. Linux does declare the syscall to use uint and musl followed it, but it is incompatible with other POSIX recv*/send* syscalls. So it seems to be wise to follow the glibc version of prototypes with int. Signed-off-by: NODA, Kai <[email protected]>
1 parent 5257dd8 commit 61c23fb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

libc-test/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ fn main() {
404404
"prlimit" | "prlimit64" | // non-int in 2nd arg
405405
"strerror_r" if linux => true, // actually xpg-something-or-other
406406

407+
// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
408+
// they match the interface defined by Linux verbatim, but they conflict with other
409+
// send*/recv* syscalls
410+
"sendmmsg" | "recvmmsg" if musl => true,
411+
407412
// typed 2nd arg on linux and android
408413
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
409414

src/unix/notbsd/linux/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ s! {
220220
pub msgtql: ::c_int,
221221
pub msgseg: ::c_ushort,
222222
}
223+
224+
pub struct mmsghdr {
225+
pub msg_hdr: ::msghdr,
226+
pub msg_len: ::c_uint,
227+
}
223228
}
224229

225230
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -983,6 +988,13 @@ extern {
983988
-> ::ssize_t;
984989
}
985990

991+
extern {
992+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
993+
flags: ::c_int) -> ::c_int;
994+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
995+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
996+
}
997+
986998
cfg_if! {
987999
if #[cfg(any(target_env = "musl",
9881000
target_os = "fuchsia",

0 commit comments

Comments
 (0)