Skip to content

Commit 89f7e49

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 9a9e2e0 + d3c0eec commit 89f7e49

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
@@ -133,6 +133,11 @@ s! {
133133
pub ss_size: ::size_t,
134134
pub ss_flags: ::c_int,
135135
}
136+
137+
pub struct mmsghdr {
138+
pub msg_hdr: ::msghdr,
139+
pub msg_len: ::ssize_t,
140+
}
136141
}
137142

138143
s_no_extra_traits! {
@@ -1203,6 +1208,11 @@ extern {
12031208

12041209
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
12051210
pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
1211+
1212+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
1213+
flags: ::c_int) -> ::ssize_t;
1214+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::size_t,
1215+
flags: ::c_int, timeout: *const ::timespec) -> ::ssize_t;
12061216
}
12071217

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ s! {
266266
pub sdl_slen: ::uint8_t,
267267
pub sdl_data: [::c_char; 12],
268268
}
269+
270+
pub struct mmsghdr {
271+
pub msg_hdr: ::msghdr,
272+
pub msg_len: ::c_uint,
273+
}
269274
}
270275

271276
s_no_extra_traits! {
@@ -1236,6 +1241,11 @@ extern {
12361241
pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
12371242

12381243
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
1244+
1245+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1246+
flags: ::c_int) -> ::c_int;
1247+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1248+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
12391249
}
12401250

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

src/unix/notbsd/android/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,10 @@ extern {
19521952
f: extern fn(*mut ::c_void) -> *mut ::c_void,
19531953
value: *mut ::c_void) -> ::c_int;
19541954
pub fn __errno() -> *mut ::c_int;
1955+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint,
1956+
flags: ::c_int) -> ::c_int;
1957+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1958+
flags: ::c_int, timeout: *const ::timespec) -> ::c_int;
19551959
}
19561960

19571961
cfg_if! {

src/unix/notbsd/emscripten/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ s! {
167167
pub msgseg: ::c_ushort,
168168
}
169169

170-
pub struct mmsghdr {
171-
pub msg_hdr: ::msghdr,
172-
pub msg_len: ::c_uint,
173-
}
174-
175170
pub struct sembuf {
176171
pub sem_num: ::c_ushort,
177172
pub sem_op: ::c_short,
@@ -1648,9 +1643,9 @@ extern {
16481643

16491644
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
16501645
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1651-
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1646+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
16521647
flags: ::c_int) -> ::c_int;
1653-
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1648+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
16541649
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
16551650
pub fn sync();
16561651
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
@@ -189,11 +189,6 @@ s! {
189189
pub msgseg: ::c_ushort,
190190
}
191191

192-
pub struct mmsghdr {
193-
pub msg_hdr: ::msghdr,
194-
pub msg_len: ::c_uint,
195-
}
196-
197192
pub struct sembuf {
198193
pub sem_num: ::c_ushort,
199194
pub sem_op: ::c_short,
@@ -2086,9 +2081,9 @@ extern {
20862081
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
20872082
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
20882083
pub fn vhangup() -> ::c_int;
2089-
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
2084+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
20902085
flags: ::c_int) -> ::c_int;
2091-
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
2086+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
20922087
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
20932088
pub fn sync();
20942089
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
@@ -207,6 +207,11 @@ s! {
207207
pub ar_pln: u8,
208208
pub ar_op: u16,
209209
}
210+
211+
pub struct mmsghdr {
212+
pub msg_hdr: ::msghdr,
213+
pub msg_len: ::c_uint,
214+
}
210215
}
211216

212217
s_no_extra_traits!{

0 commit comments

Comments
 (0)