@@ -37,14 +37,22 @@ fn main() {
37
37
}
38
38
39
39
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) => {
41
46
$cfg. header( $header) ;
42
47
} ;
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, ) * ) ;
45
53
} ;
46
- ( $cfg: ident: $( $header : expr, ) * ) => {
47
- $ ( headers!( $cfg: $header) ; ) *
54
+ ( $cfg: ident: $( $ ( [ $c : expr] : ) * $header : literal ) , * ) => {
55
+ headers!( $( $ cfg: $( [ $c ] : ) * $ header, ) * ) ;
48
56
} ;
49
57
}
50
58
@@ -135,10 +143,7 @@ fn test_apple(target: &str) {
135
143
"utmpx.h" ,
136
144
"wchar.h" ,
137
145
"xlocale.h" ,
138
- }
139
-
140
- if x86_64 {
141
- headers ! { cfg: "crt_externs.h" }
146
+ [ x86_64] : "crt_externs.h" ,
142
147
}
143
148
144
149
cfg. skip_struct ( move |ty| {
@@ -386,12 +391,8 @@ fn test_windows(target: &str) {
386
391
"sys/utime.h" ,
387
392
"time.h" ,
388
393
"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" ,
395
396
}
396
397
397
398
cfg. type_name ( move |ty, is_struct, is_union| {
@@ -1304,16 +1305,10 @@ fn test_android(target: &str) {
1304
1305
"utmp.h" ,
1305
1306
"wchar.h" ,
1306
1307
"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" ,
1317
1312
}
1318
1313
1319
1314
cfg. type_name ( move |ty, is_struct, is_union| {
@@ -2000,7 +1995,7 @@ fn test_linux(target: &str) {
2000
1995
let x86_32 = target. contains ( "i686" ) ;
2001
1996
let x32 = target. contains ( "x32" ) ;
2002
1997
let mips = target. contains ( "mips" ) ;
2003
- let mips32 = mips && !target. contains ( "64" ) ;
1998
+ let mips32_musl = mips && !target. contains ( "64" ) && musl ;
2004
1999
2005
2000
let mut cfg = ctest:: TestGenerator :: new ( ) ;
2006
2001
cfg. define ( "_GNU_SOURCE" , None ) ;
@@ -2064,7 +2059,8 @@ fn test_linux(target: &str) {
2064
2059
"sys/prctl.h" ,
2065
2060
"sys/ptrace.h" ,
2066
2061
"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" ,
2068
2064
"sys/reboot.h" ,
2069
2065
"sys/resource.h" ,
2070
2066
"sys/sem.h" ,
@@ -2096,29 +2092,17 @@ fn test_linux(target: &str) {
2096
2092
"utmpx.h" ,
2097
2093
"wchar.h" ,
2098
2094
"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" ,
2122
2106
}
2123
2107
2124
2108
// Include linux headers at the end:
@@ -2130,7 +2114,8 @@ fn test_linux(target: &str) {
2130
2114
"linux/fs.h" ,
2131
2115
"linux/futex.h" ,
2132
2116
"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" ,
2134
2119
"linux/if_addr.h" ,
2135
2120
"linux/if_alg.h" ,
2136
2121
"linux/if_ether.h" ,
@@ -2154,10 +2139,11 @@ fn test_linux(target: &str) {
2154
2139
}
2155
2140
2156
2141
// 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" ,
2161
2147
}
2162
2148
2163
2149
cfg. type_name ( move |ty, is_struct, is_union| {
@@ -2243,17 +2229,15 @@ fn test_linux(target: &str) {
2243
2229
// structs.
2244
2230
"termios2" => true ,
2245
2231
2232
+ // FIXME: musl version using by mips build jobs 1.0.15 is ancient:
2233
+ "ifmap" | "ifreq" | "ifconf" if mips32_musl => true ,
2234
+
2246
2235
_ => false ,
2247
2236
}
2248
2237
} ) ;
2249
2238
2250
2239
cfg. skip_const ( move |name| {
2251
2240
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
-
2257
2241
// These constants are not available if gnu headers have been included
2258
2242
// and can therefore not be tested here
2259
2243
//
@@ -2281,7 +2265,7 @@ fn test_linux(target: &str) {
2281
2265
//
2282
2266
// Require Linux kernel 5.x:
2283
2267
| "MSG_COPY"
2284
- => true ,
2268
+ if musl => true ,
2285
2269
2286
2270
// The musl version 1.0.22 used in CI does not
2287
2271
// contain these glibc constants yet:
@@ -2304,6 +2288,11 @@ fn test_linux(target: &str) {
2304
2288
// FIXME: on musl the pthread types are defined a little differently
2305
2289
// - these constants are used by the glibc implementation.
2306
2290
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
+
2307
2296
_ => false ,
2308
2297
}
2309
2298
} ) ;
@@ -2320,7 +2309,8 @@ fn test_linux(target: &str) {
2320
2309
//
2321
2310
// An XSI-compliant version provided if:
2322
2311
//
2323
- // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
2312
+ // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
2313
+ // && ! _GNU_SOURCE
2324
2314
//
2325
2315
// and a GNU specific version provided if _GNU_SOURCE is defined.
2326
2316
//
@@ -2341,7 +2331,6 @@ fn test_linux(target: &str) {
2341
2331
}
2342
2332
} ) ;
2343
2333
2344
- // FIXME: is this necessary?
2345
2334
cfg. skip_field_type ( move |struct_, field| {
2346
2335
// This is a weird union, don't check the type.
2347
2336
( struct_ == "ifaddrs" && field == "ifa_ifu" ) ||
@@ -2351,12 +2340,22 @@ fn test_linux(target: &str) {
2351
2340
( struct_ == "utmpx" && field == "ut_tv" ) ||
2352
2341
// sigval is actually a union, but we pretend it's a struct
2353
2342
( struct_ == "sigevent" && field == "sigev_value" ) ||
2354
- // aio_buf is "volatile void*" and Rust doesn't understand volatile
2355
- ( struct_ == "aiocb" && field == "aio_buf" ) ||
2356
2343
// this one is an anonymous union
2357
2344
( struct_ == "ff_effect" && field == "u" )
2358
2345
} ) ;
2359
2346
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
+
2360
2359
cfg. skip_field ( move |struct_, field| {
2361
2360
// this is actually a union on linux, so we can't represent it well and
2362
2361
// just insert some padding.
0 commit comments