summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNODA, Kai <nodakai@gmail.com>2016-04-10 22:21:55 +0800
committerJulian Squires <julian@cipht.net>2017-05-02 07:46:52 -0400
commit61c23fb927140df428af414489729eccf53f8e0b (patch)
tree7be4b72cdf03ef30cabcf0f1fca5943c1060d246
parent5257dd8cc09df7d7763e6921de75cfcab47d7b3c (diff)
downloadrust-libc-61c23fb927140df428af414489729eccf53f8e0b.tar.gz
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 <nodakai@gmail.com>
-rw-r--r--libc-test/build.rs5
-rw-r--r--src/unix/notbsd/linux/mod.rs12
2 files changed, 17 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 28ac5a51b9..f855c8fe3a 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -404,6 +404,11 @@ fn main() {
"prlimit" | "prlimit64" | // non-int in 2nd arg
"strerror_r" if linux => true, // actually xpg-something-or-other
+ // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
+ // they match the interface defined by Linux verbatim, but they conflict with other
+ // send*/recv* syscalls
+ "sendmmsg" | "recvmmsg" if musl => true,
+
// typed 2nd arg on linux and android
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 3df6dabf09..3827207891 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -220,6 +220,11 @@ s! {
pub msgtql: ::c_int,
pub msgseg: ::c_ushort,
}
+
+ pub struct mmsghdr {
+ pub msg_hdr: ::msghdr,
+ pub msg_len: ::c_uint,
+ }
}
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -983,6 +988,13 @@ extern {
-> ::ssize_t;
}
+extern {
+ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ flags: ::c_int) -> ::c_int;
+ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
+}
+
cfg_if! {
if #[cfg(any(target_env = "musl",
target_os = "fuchsia",