Skip to content

Commit 8ac9573

Browse files
committed
Auto merge of #1231 - dholroyd:mmsg-support, r=gnzlbg
Broader sendmmsg() / recvmmsg() support As a prerequisite for getting `sendmmsg()` / `recvmmsg()` into nix ( nix-rust/nix#1017 ), support for non-linux platforms needs to be added in libc. The initial commits in this PR will just be to test out target support via CI.
2 parents 1f63b26 + 0d3a600 commit 8ac9573

File tree

6 files changed

+33
-14
lines changed

6 files changed

+33
-14
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ s! {
190190
pub ss_size: ::size_t,
191191
pub ss_flags: ::c_int,
192192
}
193+
194+
pub struct mmsghdr {
195+
pub msg_hdr: ::msghdr,
196+
pub msg_len: ::ssize_t,
197+
}
193198
}
194199

195200
pub const SIGEV_THREAD_ID: ::c_int = 4;
@@ -1199,6 +1204,11 @@ extern {
11991204

12001205
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
12011206
pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
1207+
1208+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
1209+
flags: ::c_int) -> ::ssize_t;
1210+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
1211+
flags: ::c_int, timeout: *const ::timespec) -> ::ssize_t;
12021212
}
12031213

12041214
#[link(name = "util")]

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ s! {
332332
pub ar_pln: u8,
333333
pub ar_op: u16,
334334
}
335+
336+
pub struct mmsghdr {
337+
pub msg_hdr: ::msghdr,
338+
pub msg_len: ::c_uint,
339+
}
335340
}
336341

337342
pub const AT_FDCWD: ::c_int = -100;
@@ -1199,6 +1204,11 @@ extern {
11991204
pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
12001205

12011206
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
1207+
1208+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1209+
flags: ::c_int) -> ::c_int;
1210+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1211+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
12021212
}
12031213

12041214
#[link(name = "util")]

src/unix/notbsd/android/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,10 @@ extern {
17221722
f: extern fn(*mut ::c_void) -> *mut ::c_void,
17231723
value: *mut ::c_void) -> ::c_int;
17241724
pub fn __errno() -> *mut ::c_int;
1725+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint,
1726+
flags: ::c_int) -> ::c_int;
1727+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1728+
flags: ::c_int, timeout: *const ::timespec) -> ::c_int;
17251729
}
17261730

17271731
cfg_if! {

src/unix/notbsd/emscripten.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@ s! {
225225
pub msgseg: ::c_ushort,
226226
}
227227

228-
pub struct mmsghdr {
229-
pub msg_hdr: ::msghdr,
230-
pub msg_len: ::c_uint,
231-
}
232-
233228
pub struct sembuf {
234229
pub sem_num: ::c_ushort,
235230
pub sem_op: ::c_short,
@@ -1666,9 +1661,9 @@ extern {
16661661

16671662
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
16681663
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1669-
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1664+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
16701665
flags: ::c_int) -> ::c_int;
1671-
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1666+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
16721667
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
16731668
pub fn sync();
16741669
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;

src/unix/notbsd/linux/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ s! {
346346
pub msgseg: ::c_ushort,
347347
}
348348

349-
pub struct mmsghdr {
350-
pub msg_hdr: ::msghdr,
351-
pub msg_len: ::c_uint,
352-
}
353-
354349
pub struct sembuf {
355350
pub sem_num: ::c_ushort,
356351
pub sem_op: ::c_short,
@@ -2054,9 +2049,9 @@ extern {
20542049
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
20552050
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
20562051
pub fn vhangup() -> ::c_int;
2057-
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
2052+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
20582053
flags: ::c_int) -> ::c_int;
2059-
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
2054+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
20602055
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
20612056
pub fn sync();
20622057
pub fn syscall(num: ::c_long, ...) -> ::c_long;

src/unix/notbsd/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ s! {
228228
pub ar_pln: u8,
229229
pub ar_op: u16,
230230
}
231+
232+
pub struct mmsghdr {
233+
pub msg_hdr: ::msghdr,
234+
pub msg_len: ::c_uint,
235+
}
231236
}
232237

233238
// intentionally not public, only used for fd_set

0 commit comments

Comments
 (0)