@@ -73,6 +73,7 @@ fn do_ctest() {
7373 }
7474}
7575
76+ #[ expect( unused) ]
7677fn ctest_old_cfg ( ) -> ctest_old:: TestGenerator {
7778 let mut cfg = ctest_old:: TestGenerator :: new ( ) ;
7879 let libc_cfgs = [ "libc_thread_local" ] ;
@@ -5236,11 +5237,11 @@ fn which_freebsd() -> Option<i32> {
52365237fn test_haiku ( target : & str ) {
52375238 assert ! ( target. contains( "haiku" ) ) ;
52385239
5239- let mut cfg = ctest_old_cfg ( ) ;
5240+ let mut cfg = ctest_cfg ( ) ;
52405241 cfg. flag ( "-Wno-deprecated-declarations" ) ;
52415242 cfg. define ( "__USE_GNU" , Some ( "1" ) ) ;
52425243 cfg. define ( "_GNU_SOURCE" , None ) ;
5243- cfg. language ( ctest_old :: Lang :: CXX ) ;
5244+ cfg. language ( ctest :: Language :: CXX ) ;
52445245
52455246 // POSIX API
52465247 headers ! { cfg:
@@ -5375,11 +5376,12 @@ fn test_haiku(target: &str) {
53755376 "support/TypeConstants.h"
53765377 }
53775378
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_" ) {
53805382 return true ;
53815383 }
5382- match ty {
5384+ match struct_ . ident ( ) {
53835385 // FIXME(union): actually a union
53845386 "sigval" => true ,
53855387 // FIXME(haiku): locale_t does not exist on Haiku
@@ -5409,8 +5411,8 @@ fn test_haiku(target: &str) {
54095411 }
54105412 } ) ;
54115413
5412- cfg. skip_type ( move |ty| {
5413- match ty {
5414+ cfg. skip_alias ( move |ty| {
5415+ match ty. ident ( ) {
54145416 // FIXME(haiku): locale_t does not exist on Haiku
54155417 "locale_t" => true ,
54165418 // These cause errors, to be reviewed in the future
@@ -5423,12 +5425,12 @@ fn test_haiku(target: &str) {
54235425 }
54245426 } ) ;
54255427
5426- cfg. skip_fn ( move |name | {
5428+ cfg. skip_fn ( move |func | {
54275429 // skip those that are manually verified
5428- match name {
5430+ match func . ident ( ) {
54295431 // FIXME(haiku): https://github.com/rust-lang/libc/issues/1272
54305432 "execv" | "execve" | "execvp" | "execvpe" => true ,
5431- // FIXME: does not exist on haiku
5433+ // FIXME(haiku) : does not exist on haiku
54325434 "open_wmemstream" => true ,
54335435 "mlockall" | "munlockall" => true ,
54345436 "tcgetsid" => true ,
@@ -5450,8 +5452,8 @@ fn test_haiku(target: &str) {
54505452 }
54515453 } ) ;
54525454
5453- cfg. skip_const ( move |name | {
5454- match name {
5455+ cfg. skip_const ( move |constant | {
5456+ match constant . ident ( ) {
54555457 // FIXME(haiku): these constants do not exist on Haiku
54565458 "DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
54575459 | "DT_SOCK" => true ,
@@ -5476,8 +5478,8 @@ fn test_haiku(target: &str) {
54765478 }
54775479 } ) ;
54785480
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 ( ) ) {
54815483 // FIXME(time): the stat struct actually has timespec members, whereas
54825484 // the current representation has these unpacked.
54835485 ( "stat" , "st_atime" ) => true ,
@@ -5513,7 +5515,14 @@ fn test_haiku(target: &str) {
55135515 _ => false ,
55145516 } ) ;
55155517
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| {
55175526 match ty {
55185527 // Just pass all these through, no need for a "struct" prefix
55195528 "area_info"
@@ -5537,36 +5546,31 @@ fn test_haiku(target: &str) {
55375546 | "cpu_topology_node_info"
55385547 | "cpu_topology_root_info"
55395548 | "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 ( ) ) ,
55465550
55475551 // 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 ,
55535555 }
55545556 } ) ;
55555557
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 ( ) {
55585561 // Field is named `type` in C but that is a Rust keyword,
55595562 // 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 ,
55675570 }
55685571 } ) ;
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 ( ) ;
55705574}
55715575
55725576fn test_aix ( target : & str ) {
0 commit comments