@@ -73,6 +73,7 @@ fn do_ctest() {
73
73
}
74
74
}
75
75
76
+ #[ expect( unused) ]
76
77
fn ctest_old_cfg ( ) -> ctest_old:: TestGenerator {
77
78
let mut cfg = ctest_old:: TestGenerator :: new ( ) ;
78
79
let libc_cfgs = [ "libc_thread_local" ] ;
@@ -5236,11 +5237,11 @@ fn which_freebsd() -> Option<i32> {
5236
5237
fn test_haiku ( target : & str ) {
5237
5238
assert ! ( target. contains( "haiku" ) ) ;
5238
5239
5239
- let mut cfg = ctest_old_cfg ( ) ;
5240
+ let mut cfg = ctest_cfg ( ) ;
5240
5241
cfg. flag ( "-Wno-deprecated-declarations" ) ;
5241
5242
cfg. define ( "__USE_GNU" , Some ( "1" ) ) ;
5242
5243
cfg. define ( "_GNU_SOURCE" , None ) ;
5243
- cfg. language ( ctest_old :: Lang :: CXX ) ;
5244
+ cfg. language ( ctest :: Language :: CXX ) ;
5244
5245
5245
5246
// POSIX API
5246
5247
headers ! { cfg:
@@ -5375,11 +5376,12 @@ fn test_haiku(target: &str) {
5375
5376
"support/TypeConstants.h"
5376
5377
}
5377
5378
5378
- cfg. skip_struct ( move |ty| {
5379
- if ty. starts_with ( "__c_anonymous_" ) {
5379
+ cfg. skip_union ( |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
5380
+ cfg. skip_struct ( move |struct_| {
5381
+ if struct_. ident ( ) . starts_with ( "__c_anonymous_" ) {
5380
5382
return true ;
5381
5383
}
5382
- match ty {
5384
+ match struct_ . ident ( ) {
5383
5385
// FIXME(union): actually a union
5384
5386
"sigval" => true ,
5385
5387
// FIXME(haiku): locale_t does not exist on Haiku
@@ -5409,8 +5411,8 @@ fn test_haiku(target: &str) {
5409
5411
}
5410
5412
} ) ;
5411
5413
5412
- cfg. skip_type ( move |ty| {
5413
- match ty {
5414
+ cfg. skip_alias ( move |ty| {
5415
+ match ty. ident ( ) {
5414
5416
// FIXME(haiku): locale_t does not exist on Haiku
5415
5417
"locale_t" => true ,
5416
5418
// These cause errors, to be reviewed in the future
@@ -5423,12 +5425,12 @@ fn test_haiku(target: &str) {
5423
5425
}
5424
5426
} ) ;
5425
5427
5426
- cfg. skip_fn ( move |name | {
5428
+ cfg. skip_fn ( move |func | {
5427
5429
// skip those that are manually verified
5428
- match name {
5430
+ match func . ident ( ) {
5429
5431
// FIXME(haiku): https://github.com/rust-lang/libc/issues/1272
5430
5432
"execv" | "execve" | "execvp" | "execvpe" => true ,
5431
- // FIXME: does not exist on haiku
5433
+ // FIXME(haiku) : does not exist on haiku
5432
5434
"open_wmemstream" => true ,
5433
5435
"mlockall" | "munlockall" => true ,
5434
5436
"tcgetsid" => true ,
@@ -5450,8 +5452,8 @@ fn test_haiku(target: &str) {
5450
5452
}
5451
5453
} ) ;
5452
5454
5453
- cfg. skip_const ( move |name | {
5454
- match name {
5455
+ cfg. skip_const ( move |constant | {
5456
+ match constant . ident ( ) {
5455
5457
// FIXME(haiku): these constants do not exist on Haiku
5456
5458
"DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
5457
5459
| "DT_SOCK" => true ,
@@ -5476,8 +5478,8 @@ fn test_haiku(target: &str) {
5476
5478
}
5477
5479
} ) ;
5478
5480
5479
- cfg. skip_field ( move |struct_, field| {
5480
- match ( struct_, field) {
5481
+ cfg. skip_struct_field ( move |struct_, field| {
5482
+ match ( struct_. ident ( ) , field. ident ( ) ) {
5481
5483
// FIXME(time): the stat struct actually has timespec members, whereas
5482
5484
// the current representation has these unpacked.
5483
5485
( "stat" , "st_atime" ) => true ,
@@ -5513,7 +5515,14 @@ fn test_haiku(target: &str) {
5513
5515
_ => false ,
5514
5516
} ) ;
5515
5517
5516
- cfg. type_name ( move |ty, is_struct, is_union| {
5518
+ let c_enums = [
5519
+ "directory_which" ,
5520
+ "path_base_directory" ,
5521
+ "cpu_platform" ,
5522
+ "cpu_vendor" ,
5523
+ ] ;
5524
+ cfg. alias_is_c_enum ( move |e| c_enums. contains ( & e) ) ;
5525
+ cfg. rename_struct_ty ( move |ty| {
5517
5526
match ty {
5518
5527
// Just pass all these through, no need for a "struct" prefix
5519
5528
"area_info"
@@ -5537,36 +5546,31 @@ fn test_haiku(target: &str) {
5537
5546
| "cpu_topology_node_info"
5538
5547
| "cpu_topology_root_info"
5539
5548
| "cpu_topology_package_info"
5540
- | "cpu_topology_core_info" => ty. to_string ( ) ,
5541
-
5542
- // enums don't need a prefix
5543
- "directory_which" | "path_base_directory" | "cpu_platform" | "cpu_vendor" => {
5544
- ty. to_string ( )
5545
- }
5549
+ | "cpu_topology_core_info" => Some ( ty. to_string ( ) ) ,
5546
5550
5547
5551
// is actually a union
5548
- "sigval" => "union sigval" . to_string ( ) ,
5549
- t if is_union => format ! ( "union {t}" ) ,
5550
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
5551
- t if is_struct => format ! ( "struct {t}" ) ,
5552
- t => t. to_string ( ) ,
5552
+ "sigval" => Some ( "union sigval" . to_string ( ) ) ,
5553
+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
5554
+ _ => None ,
5553
5555
}
5554
5556
} ) ;
5555
5557
5556
- cfg. field_name ( move |struct_, field| {
5557
- match field {
5558
+ cfg. rename_struct_field ( move |struct_, field| {
5559
+ let struct_ = struct_. ident ( ) ;
5560
+ match field. ident ( ) {
5558
5561
// Field is named `type` in C but that is a Rust keyword,
5559
5562
// so these fields are translated to `type_` in the bindings.
5560
- "type_" if struct_ == "object_wait_info" => "type" . to_string ( ) ,
5561
- "type_" if struct_ == "sem_t" => "type" . to_string ( ) ,
5562
- "type_" if struct_ == "attr_info" => "type" . to_string ( ) ,
5563
- "type_" if struct_ == "index_info" => "type" . to_string ( ) ,
5564
- "type_" if struct_ == "cpu_topology_node_info" => "type" . to_string ( ) ,
5565
- "image_type" if struct_ == "image_info" => "type" . to_string ( ) ,
5566
- s => s . to_string ( ) ,
5563
+ "type_" if struct_ == "object_wait_info" => Some ( "type" . to_string ( ) ) ,
5564
+ "type_" if struct_ == "sem_t" => Some ( "type" . to_string ( ) ) ,
5565
+ "type_" if struct_ == "attr_info" => Some ( "type" . to_string ( ) ) ,
5566
+ "type_" if struct_ == "index_info" => Some ( "type" . to_string ( ) ) ,
5567
+ "type_" if struct_ == "cpu_topology_node_info" => Some ( "type" . to_string ( ) ) ,
5568
+ "image_type" if struct_ == "image_info" => Some ( "type" . to_string ( ) ) ,
5569
+ _ => None ,
5567
5570
}
5568
5571
} ) ;
5569
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
5572
+
5573
+ ctest:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
5570
5574
}
5571
5575
5572
5576
fn test_aix ( target : & str ) {
0 commit comments