@@ -37,14 +37,22 @@ fn main() {
3737}
3838
3939macro_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.
0 commit comments