@@ -1790,7 +1790,7 @@ fn test_android(target: &str) {
1790
1790
let x86 = target. contains ( "i686" ) || target. contains ( "x86_64" ) ;
1791
1791
let aarch64 = target. contains ( "aarch64" ) ;
1792
1792
1793
- let mut cfg = ctest_old_cfg ( ) ;
1793
+ let mut cfg = ctest_cfg ( ) ;
1794
1794
cfg. define ( "_GNU_SOURCE" , None ) ;
1795
1795
1796
1796
headers ! { cfg:
@@ -1939,46 +1939,39 @@ fn test_android(target: &str) {
1939
1939
"android/set_abort_message.h"
1940
1940
}
1941
1941
1942
- cfg. type_name ( move |ty, is_struct, is_union| {
1943
- match ty {
1944
- // Just pass all these through, no need for a "struct" prefix
1945
- "FILE" | "fd_set" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => ty. to_string ( ) ,
1946
-
1947
- t if is_union => format ! ( "union {t}" ) ,
1948
-
1949
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
1950
-
1951
- "Ioctl" => "int" . to_string ( ) ,
1952
-
1953
- // put `struct` in front of all structs:.
1954
- t if is_struct => format ! ( "struct {t}" ) ,
1942
+ cfg. rename_type ( move |ty| match ty {
1943
+ "Ioctl" => Some ( "int" . to_string ( ) ) ,
1944
+ _ => None ,
1945
+ } ) ;
1955
1946
1956
- t => t. to_string ( ) ,
1957
- }
1947
+ cfg. rename_struct_ty ( |ty| match ty {
1948
+ // Just pass all these through, no need for a "struct" prefix
1949
+ "FILE" | "fd_set" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => Some ( ty. to_string ( ) ) ,
1950
+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
1951
+ _ => None ,
1958
1952
} ) ;
1959
1953
1960
- cfg. field_name ( move |struct_, field| {
1961
- match field {
1954
+ cfg. rename_struct_field ( move |struct_, field| {
1955
+ match field. ident ( ) {
1962
1956
// Our stat *_nsec fields normally don't actually exist but are part
1963
1957
// of a timeval struct
1964
- s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => s. to_string ( ) ,
1958
+ s if s. ends_with ( "_nsec" ) && struct_. ident ( ) . starts_with ( "stat" ) => Some ( s. to_string ( ) ) ,
1965
1959
// The following structs have a field called `type` in C,
1966
1960
// but `type` is a Rust keyword, so these fields are translated
1967
1961
// to `type_` in Rust.
1968
1962
"type_"
1969
- if struct_ == "input_event"
1970
- || struct_ == "input_mask"
1971
- || struct_ == "ff_effect" =>
1963
+ if struct_. ident ( ) == "input_event"
1964
+ || struct_. ident ( ) == "input_mask"
1965
+ || struct_. ident ( ) == "ff_effect" =>
1972
1966
{
1973
- "type" . to_string ( )
1967
+ Some ( "type" . to_string ( ) )
1974
1968
}
1975
-
1976
- s => s. to_string ( ) ,
1969
+ _ => None ,
1977
1970
}
1978
1971
} ) ;
1979
1972
1980
- cfg. skip_type ( move |ty| {
1981
- match ty {
1973
+ cfg. skip_alias ( move |ty| {
1974
+ match ty. ident ( ) {
1982
1975
// FIXME(android): `sighandler_t` type is incorrect, see:
1983
1976
// https://github.com/rust-lang/libc/issues/1359
1984
1977
"sighandler_t" => true ,
@@ -1999,11 +1992,11 @@ fn test_android(target: &str) {
1999
1992
}
2000
1993
} ) ;
2001
1994
2002
- cfg. skip_struct ( move |ty | {
2003
- if ty . starts_with ( "__c_anonymous_" ) {
1995
+ cfg. skip_struct ( move |struct_ | {
1996
+ if struct_ . ident ( ) . starts_with ( "__c_anonymous_" ) {
2004
1997
return true ;
2005
1998
}
2006
- match ty {
1999
+ match struct_ . ident ( ) {
2007
2000
// These are tested as part of the linux_fcntl tests since there are
2008
2001
// header conflicts when including them with all the other structs.
2009
2002
"termios2" => true ,
@@ -2027,8 +2020,8 @@ fn test_android(target: &str) {
2027
2020
}
2028
2021
} ) ;
2029
2022
2030
- cfg. skip_const ( move |name | {
2031
- match name {
2023
+ cfg. skip_const ( move |constant | {
2024
+ match constant . ident ( ) {
2032
2025
// The IPV6 constants are tested in the `linux_ipv6.rs` tests:
2033
2026
| "IPV6_FLOWINFO"
2034
2027
| "IPV6_FLOWLABEL_MGR"
@@ -2178,9 +2171,9 @@ fn test_android(target: &str) {
2178
2171
}
2179
2172
} ) ;
2180
2173
2181
- cfg. skip_fn ( move |name | {
2174
+ cfg. skip_fn ( move |func | {
2182
2175
// skip those that are manually verified
2183
- match name {
2176
+ match func . ident ( ) {
2184
2177
// FIXME(android): for unknown reasons linker unable to find "fexecve"
2185
2178
"fexecve" => true ,
2186
2179
@@ -2247,7 +2240,9 @@ fn test_android(target: &str) {
2247
2240
}
2248
2241
} ) ;
2249
2242
2250
- cfg. skip_field_type ( move |struct_, field| {
2243
+ cfg. skip_struct_field_type ( move |struct_, field| {
2244
+ let struct_ = struct_. ident ( ) ;
2245
+ let field = field. ident ( ) ;
2251
2246
// This is a weird union, don't check the type.
2252
2247
( struct_ == "ifaddrs" && field == "ifa_ifu" ) ||
2253
2248
// this one is an anonymous union
@@ -2261,8 +2256,8 @@ fn test_android(target: &str) {
2261
2256
( struct_ == "flock64" && ( field == "l_start" || field == "l_len" ) )
2262
2257
} ) ;
2263
2258
2264
- cfg. skip_field ( |struct_, field| {
2265
- match ( struct_, field) {
2259
+ cfg. skip_struct_field ( |struct_, field| {
2260
+ match ( struct_. ident ( ) , field. ident ( ) ) {
2266
2261
// conflicting with `p_type` macro from <resolve.h>.
2267
2262
( "Elf32_Phdr" , "p_type" ) => true ,
2268
2263
( "Elf64_Phdr" , "p_type" ) => true ,
@@ -2280,7 +2275,7 @@ fn test_android(target: &str) {
2280
2275
}
2281
2276
} ) ;
2282
2277
2283
- cfg. generate ( src_hotfix_dir ( ) . join ( " lib.rs") , "ctest_output.rs" ) ;
2278
+ ctest :: generate_test ( & mut cfg, "../src/ lib.rs", "ctest_output.rs" ) . unwrap ( ) ;
2284
2279
2285
2280
test_linux_like_apis ( target) ;
2286
2281
}
@@ -3377,6 +3372,8 @@ fn test_neutrino(target: &str) {
3377
3372
}
3378
3373
} ) ;
3379
3374
3375
+ cfg. skip_union ( move |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
3376
+
3380
3377
cfg. skip_const ( move |constant| {
3381
3378
match constant. ident ( ) {
3382
3379
// These signal "functions" are actually integer values that are casted to a fn ptr
0 commit comments