Skip to content

Commit 1a3d152

Browse files
committed
[breaking change] sendmmsg/recvmmsg flag argument is an unsigned integer on MUSL
1 parent 2543b7c commit 1a3d152

File tree

13 files changed

+95
-80
lines changed

13 files changed

+95
-80
lines changed

ci/docker/mips-unknown-linux-musl/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
77
RUN mkdir /toolchain
88

99
# Note that this originally came from:
10-
# https://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-sdk-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz
11-
RUN curl --retry 5 -L https://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-sdk-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz | \
12-
tar xf -J - -C /toolchain --strip-components=1
10+
# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
11+
RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
12+
tar xjf - -C /toolchain --strip-components=1
1313

14-
ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-7.4.0_musl.Linux-x86_64/bin \
14+
ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \
1515
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
1616
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \
17-
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-7.4.0_musl.Linux-x86_64"
17+
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15"

libc-test/build.rs

+64-65
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,22 @@ fn main() {
3737
}
3838

3939
macro_rules! headers {
40-
($cfg:ident: $header:expr) => {
40+
($cfg:ident: [$m:expr]: $header:literal) => {
41+
if $m {
42+
$cfg.header($header);
43+
}
44+
};
45+
($cfg:ident: $header:literal) => {
4146
$cfg.header($header);
4247
};
43-
($cfg:ident: $($header:expr),*) => {
44-
$(headers!($cfg: $header);)*
48+
($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => {
49+
$(headers!($cfg: $([$c]:)* $header);)*
50+
};
51+
($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => {
52+
headers!($($cfg: $([$c]:)* $header,)*);
4553
};
46-
($cfg:ident: $($header:expr,)*) => {
47-
$(headers!($cfg: $header);)*
54+
($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => {
55+
headers!($($cfg: $([$c]:)* $header,)*);
4856
};
4957
}
5058

@@ -135,10 +143,7 @@ fn test_apple(target: &str) {
135143
"utmpx.h",
136144
"wchar.h",
137145
"xlocale.h",
138-
}
139-
140-
if x86_64 {
141-
headers! { cfg: "crt_externs.h" }
146+
[x86_64]: "crt_externs.h",
142147
}
143148

144149
cfg.skip_struct(move |ty| {
@@ -386,12 +391,8 @@ fn test_windows(target: &str) {
386391
"sys/utime.h",
387392
"time.h",
388393
"wchar.h",
389-
}
390-
391-
if gnu {
392-
headers! { cfg: "ws2tcpip.h" }
393-
} else {
394-
headers! { cfg: "Winsock2.h" };
394+
[gnu]: "ws2tcpip.h",
395+
[!gnu]: "Winsock2.h",
395396
}
396397

397398
cfg.type_name(move |ty, is_struct, is_union| {
@@ -1304,16 +1305,10 @@ fn test_android(target: &str) {
13041305
"utmp.h",
13051306
"wchar.h",
13061307
"xlocale.h",
1307-
}
1308-
1309-
if target_pointer_width == 32 {
1310-
// time64_t is not defined for 64-bit targets If included it will
1311-
// generate the error 'Your time_t is already 64-bit'
1312-
cfg.header("time64.h");
1313-
}
1314-
1315-
if x86 {
1316-
cfg.header("sys/reg.h");
1308+
// time64_t is not defined for 64-bit targets If included it will
1309+
// generate the error 'Your time_t is already 64-bit'
1310+
[target_pointer_width == 32]: "time64.h",
1311+
[x86]: "sys/reg.h",
13171312
}
13181313

13191314
cfg.type_name(move |ty, is_struct, is_union| {
@@ -2000,7 +1995,7 @@ fn test_linux(target: &str) {
20001995
let x86_32 = target.contains("i686");
20011996
let x32 = target.contains("x32");
20021997
let mips = target.contains("mips");
2003-
let mips32 = mips && !target.contains("64");
1998+
let mips32_musl = mips && !target.contains("64") && musl;
20041999

20052000
let mut cfg = ctest::TestGenerator::new();
20062001
cfg.define("_GNU_SOURCE", None);
@@ -2064,7 +2059,8 @@ fn test_linux(target: &str) {
20642059
"sys/prctl.h",
20652060
"sys/ptrace.h",
20662061
"sys/quota.h",
2067-
"sys/random.h",
2062+
// FIXME: the mips-musl CI build jobs use ancient musl 1.0.15:
2063+
[!mips32_musl]: "sys/random.h",
20682064
"sys/reboot.h",
20692065
"sys/resource.h",
20702066
"sys/sem.h",
@@ -2096,29 +2092,17 @@ fn test_linux(target: &str) {
20962092
"utmpx.h",
20972093
"wchar.h",
20982094
"errno.h",
2099-
}
2100-
2101-
// `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit ARM:
2102-
// https://bugzilla.redhat.com/show_bug.cgi?id=1116162
2103-
if x86_64 || x86_32 || arm {
2104-
headers! { cfg: "sys/io.h" }
2105-
}
2106-
2107-
// `sys/reg.h` is only available on x86 and x86_64
2108-
if x86_64 || x86_32 {
2109-
headers! { cfg: "sys/reg.h" }
2110-
}
2111-
2112-
// sysctl system call is deprecated and not available on musl
2113-
// It is also unsupported in x32:
2114-
if !(x32 || musl) {
2115-
headers! { cfg: "sys/sysctl.h"}
2116-
}
2117-
2118-
// <execinfo.h> is not supported by musl:
2119-
// https://www.openwall.com/lists/musl/2015/04/09/3
2120-
if !musl {
2121-
headers! { cfg: "execinfo.h" }
2095+
// `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit
2096+
// ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162
2097+
[x86_64 || x86_32 || arm]: "sys/io.h",
2098+
// `sys/reg.h` is only available on x86 and x86_64
2099+
[x86_64 || x86_32]: "sys/reg.h",
2100+
// sysctl system call is deprecated and not available on musl
2101+
// It is also unsupported in x32:
2102+
[!(x32 || musl)]: "sys/sysctl.h",
2103+
// <execinfo.h> is not supported by musl:
2104+
// https://www.openwall.com/lists/musl/2015/04/09/3
2105+
[!musl]: "execinfo.h",
21222106
}
21232107

21242108
// Include linux headers at the end:
@@ -2130,7 +2114,8 @@ fn test_linux(target: &str) {
21302114
"linux/fs.h",
21312115
"linux/futex.h",
21322116
"linux/genetlink.h",
2133-
"linux/if.h",
2117+
// FIXME: musl version 1.0.15 used by mips build jobs is ancient
2118+
[!mips32_musl]: "linux/if.h",
21342119
"linux/if_addr.h",
21352120
"linux/if_alg.h",
21362121
"linux/if_ether.h",
@@ -2154,10 +2139,11 @@ fn test_linux(target: &str) {
21542139
}
21552140

21562141
// note: aio.h must be included before sys/mount.h
2157-
headers! { cfg:
2158-
"sys/xattr.h",
2159-
"sys/sysinfo.h",
2160-
"aio.h",
2142+
headers! {
2143+
cfg:
2144+
"sys/xattr.h",
2145+
"sys/sysinfo.h",
2146+
"aio.h",
21612147
}
21622148

21632149
cfg.type_name(move |ty, is_struct, is_union| {
@@ -2243,17 +2229,15 @@ fn test_linux(target: &str) {
22432229
// structs.
22442230
"termios2" => true,
22452231

2232+
// FIXME: musl version using by mips build jobs 1.0.15 is ancient:
2233+
"ifmap" | "ifreq" | "ifconf" if mips32_musl => true,
2234+
22462235
_ => false,
22472236
}
22482237
});
22492238

22502239
cfg.skip_const(move |name| {
22512240
match name {
2252-
// These are not available in the MUSL version used by the
2253-
// 32-bit mips build jobs:
2254-
| "AF_XDP"
2255-
| "PF_XDP" if musl && mips32 => true,
2256-
22572241
// These constants are not available if gnu headers have been included
22582242
// and can therefore not be tested here
22592243
//
@@ -2281,7 +2265,7 @@ fn test_linux(target: &str) {
22812265
//
22822266
// Require Linux kernel 5.x:
22832267
| "MSG_COPY"
2284-
=> true,
2268+
if musl => true,
22852269

22862270
// The musl version 1.0.22 used in CI does not
22872271
// contain these glibc constants yet:
@@ -2304,6 +2288,11 @@ fn test_linux(target: &str) {
23042288
// FIXME: on musl the pthread types are defined a little differently
23052289
// - these constants are used by the glibc implementation.
23062290
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
2291+
2292+
// FIXME: musl version 1.0.15 used by mips build jobs is ancient
2293+
t if mips32_musl && t.starts_with("IFF") => true,
2294+
"MFD_HUGETLB" | "AF_XDP" | "PF_XDP" if mips32_musl => true,
2295+
23072296
_ => false,
23082297
}
23092298
});
@@ -2320,7 +2309,8 @@ fn test_linux(target: &str) {
23202309
//
23212310
// An XSI-compliant version provided if:
23222311
//
2323-
// (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
2312+
// (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
2313+
// && ! _GNU_SOURCE
23242314
//
23252315
// and a GNU specific version provided if _GNU_SOURCE is defined.
23262316
//
@@ -2341,7 +2331,6 @@ fn test_linux(target: &str) {
23412331
}
23422332
});
23432333

2344-
// FIXME: is this necessary?
23452334
cfg.skip_field_type(move |struct_, field| {
23462335
// This is a weird union, don't check the type.
23472336
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
@@ -2351,12 +2340,22 @@ fn test_linux(target: &str) {
23512340
(struct_ == "utmpx" && field == "ut_tv") ||
23522341
// sigval is actually a union, but we pretend it's a struct
23532342
(struct_ == "sigevent" && field == "sigev_value") ||
2354-
// aio_buf is "volatile void*" and Rust doesn't understand volatile
2355-
(struct_ == "aiocb" && field == "aio_buf") ||
23562343
// this one is an anonymous union
23572344
(struct_ == "ff_effect" && field == "u")
23582345
});
23592346

2347+
cfg.volatile_item(|i| {
2348+
use ctest::VolatileItemKind::*;
2349+
match i {
2350+
// aio_buf is a volatile void** but since we cannot express that in
2351+
// Rust types, we have to explicitly tell the checker about it here:
2352+
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
2353+
true
2354+
}
2355+
_ => false,
2356+
}
2357+
});
2358+
23602359
cfg.skip_field(move |struct_, field| {
23612360
// this is actually a union on linux, so we can't represent it well and
23622361
// just insert some padding.

libc-test/test/linux_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_elf.rs"));
88

99
#[cfg(not(target_os = "linux"))]
10-
fn main() {}
10+
fn main() { println!("PASSED 0 tests"); }

libc-test/test/linux_fcntl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() {}
10+
fn main() { println!("PASSED 0 tests"); }

libc-test/test/linux_ipv6.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs"));
88

99
#[cfg(not(target_os = "linux"))]
10-
fn main() {}
10+
fn main() { println!("PASSED 0 tests"); }

libc-test/test/linux_strerror_r.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() {}
10+
fn main() { println!("PASSED 0 tests"); }

libc-test/test/linux_termios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_termios.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() {}
10+
fn main() { println!("PASSED 0 tests"); }

src/unix/notbsd/linux/mips/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,11 @@ f! {
907907

908908
#[link(name = "util")]
909909
extern {
910+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
911+
flags: ::c_int) -> ::c_int;
912+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
913+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
914+
910915
pub fn getrlimit64(resource: ::__rlimit_resource_t,
911916
rlim: *mut ::rlimit64) -> ::c_int;
912917
pub fn setrlimit64(resource: ::__rlimit_resource_t,

src/unix/notbsd/linux/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2326,10 +2326,6 @@ extern {
23262326
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
23272327
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
23282328
pub fn vhangup() -> ::c_int;
2329-
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
2330-
flags: ::c_int) -> ::c_int;
2331-
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
2332-
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
23332329
pub fn sync();
23342330
pub fn syscall(num: ::c_long, ...) -> ::c_long;
23352331
pub fn sched_getaffinity(pid: ::pid_t,

src/unix/notbsd/linux/musl/b32/mips.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub const RLIMIT_NOFILE: ::c_int = 5;
191191
pub const RLIMIT_AS: ::c_int = 6;
192192
pub const RLIMIT_NPROC: ::c_int = 8;
193193
pub const RLIMIT_MEMLOCK: ::c_int = 9;
194-
pub const RLIMIT_NLIMITS: ::c_int = 16;
194+
pub const RLIMIT_NLIMITS: ::c_int = 15;
195195

196196
pub const MCL_CURRENT: ::c_int = 0x0001;
197197
pub const MCL_FUTURE: ::c_int = 0x0002;

src/unix/notbsd/linux/musl/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ pub const SO_PEEK_OFF: ::c_int = 42;
332332
pub const SO_BUSY_POLL: ::c_int = 46;
333333

334334
extern {
335+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
336+
flags: ::c_uint) -> ::c_int;
337+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
338+
flags: ::c_uint, timeout: *mut ::timespec) -> ::c_int;
339+
335340
pub fn getrlimit64(resource: ::c_int,
336341
rlim: *mut ::rlimit64) -> ::c_int;
337342
pub fn setrlimit64(resource: ::c_int,

src/unix/notbsd/linux/other/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ f! {
950950
}
951951

952952
extern {
953+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
954+
flags: ::c_int) -> ::c_int;
955+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
956+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
957+
953958
pub fn getrlimit64(resource: ::__rlimit_resource_t,
954959
rlim: *mut ::rlimit64) -> ::c_int;
955960
pub fn setrlimit64(resource: ::__rlimit_resource_t,

src/unix/notbsd/linux/s390x/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,11 @@ pub const SYS_newfstatat: ::c_long = 293;
13171317

13181318
#[link(name = "util")]
13191319
extern {
1320+
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1321+
flags: ::c_int) -> ::c_int;
1322+
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
1323+
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
1324+
13201325
pub fn getrlimit64(resource: ::__rlimit_resource_t,
13211326
rlim: *mut ::rlimit64) -> ::c_int;
13221327
pub fn setrlimit64(resource: ::__rlimit_resource_t,

0 commit comments

Comments
 (0)