@@ -73,6 +73,7 @@ fn do_ctest() {
7373 }
7474}
7575
76+ #[ expect( unused) ]
7677fn ctest_old_cfg ( ) -> ctest_old:: TestGenerator {
7778 ctest_old:: TestGenerator :: new ( )
7879}
@@ -5077,11 +5078,11 @@ fn which_freebsd() -> Option<i32> {
50775078fn test_haiku ( target : & str ) {
50785079 assert ! ( target. contains( "haiku" ) ) ;
50795080
5080- let mut cfg = ctest_old_cfg ( ) ;
5081+ let mut cfg = ctest_cfg ( ) ;
50815082 cfg. flag ( "-Wno-deprecated-declarations" ) ;
50825083 cfg. define ( "__USE_GNU" , Some ( "1" ) ) ;
50835084 cfg. define ( "_GNU_SOURCE" , None ) ;
5084- cfg. language ( ctest_old :: Lang :: CXX ) ;
5085+ cfg. language ( ctest :: Language :: CXX ) ;
50855086
50865087 // POSIX API
50875088 headers ! { cfg:
@@ -5216,11 +5217,12 @@ fn test_haiku(target: &str) {
52165217 "support/TypeConstants.h"
52175218 }
52185219
5219- cfg. skip_struct ( move |ty| {
5220- if ty. starts_with ( "__c_anonymous_" ) {
5220+ cfg. skip_union ( |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
5221+ cfg. skip_struct ( move |struct_| {
5222+ if struct_. ident ( ) . starts_with ( "__c_anonymous_" ) {
52215223 return true ;
52225224 }
5223- match ty {
5225+ match struct_ . ident ( ) {
52245226 // FIXME(haiku): locale_t does not exist on Haiku
52255227 "locale_t" => true ,
52265228 // FIXME(haiku): rusage has a different layout on Haiku
@@ -5248,8 +5250,8 @@ fn test_haiku(target: &str) {
52485250 }
52495251 } ) ;
52505252
5251- cfg. skip_type ( move |ty| {
5252- match ty {
5253+ cfg. skip_alias ( move |ty| {
5254+ match ty. ident ( ) {
52535255 // FIXME(haiku): locale_t does not exist on Haiku
52545256 "locale_t" => true ,
52555257 // These cause errors, to be reviewed in the future
@@ -5262,9 +5264,9 @@ fn test_haiku(target: &str) {
52625264 }
52635265 } ) ;
52645266
5265- cfg. skip_fn ( move |name | {
5267+ cfg. skip_fn ( move |func | {
52665268 // skip those that are manually verified
5267- match name {
5269+ match func . ident ( ) {
52685270 // FIXME(haiku): does not exist on haiku
52695271 "open_wmemstream" => true ,
52705272 "mlockall" | "munlockall" => true ,
@@ -5287,8 +5289,8 @@ fn test_haiku(target: &str) {
52875289 }
52885290 } ) ;
52895291
5290- cfg. skip_const ( move |name | {
5291- match name {
5292+ cfg. skip_const ( move |constant | {
5293+ match constant . ident ( ) {
52925294 // FIXME(haiku): these constants do not exist on Haiku
52935295 "DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
52945296 | "DT_SOCK" => true ,
@@ -5313,8 +5315,8 @@ fn test_haiku(target: &str) {
53135315 }
53145316 } ) ;
53155317
5316- cfg. skip_field ( move |struct_, field| {
5317- match ( struct_, field) {
5318+ cfg. skip_struct_field ( move |struct_, field| {
5319+ match ( struct_. ident ( ) , field. ident ( ) ) {
53185320 // FIXME(time): the stat struct actually has timespec members, whereas
53195321 // the current representation has these unpacked.
53205322 ( "stat" , "st_atime" ) => true ,
@@ -5348,7 +5350,14 @@ fn test_haiku(target: &str) {
53485350 _ => false ,
53495351 } ) ;
53505352
5351- cfg. type_name ( move |ty, is_struct, is_union| {
5353+ let c_enums = [
5354+ "directory_which" ,
5355+ "path_base_directory" ,
5356+ "cpu_platform" ,
5357+ "cpu_vendor" ,
5358+ ] ;
5359+ cfg. alias_is_c_enum ( move |e| c_enums. contains ( & e) ) ;
5360+ cfg. rename_struct_ty ( move |ty| {
53525361 match ty {
53535362 // Just pass all these through, no need for a "struct" prefix
53545363 "area_info"
@@ -5372,34 +5381,29 @@ fn test_haiku(target: &str) {
53725381 | "cpu_topology_node_info"
53735382 | "cpu_topology_root_info"
53745383 | "cpu_topology_package_info"
5375- | "cpu_topology_core_info" => ty. to_string ( ) ,
5376-
5377- // enums don't need a prefix
5378- "directory_which" | "path_base_directory" | "cpu_platform" | "cpu_vendor" => {
5379- ty. to_string ( )
5380- }
5384+ | "cpu_topology_core_info" => Some ( ty. to_string ( ) ) ,
53815385
5382- t if is_union => format ! ( "union {t}" ) ,
5383- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
5384- t if is_struct => format ! ( "struct {t}" ) ,
5385- t => t. to_string ( ) ,
5386+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
5387+ _ => None ,
53865388 }
53875389 } ) ;
53885390
5389- cfg. field_name ( move |struct_, field| {
5390- match field {
5391+ cfg. rename_struct_field ( move |struct_, field| {
5392+ let struct_ = struct_. ident ( ) ;
5393+ match field. ident ( ) {
53915394 // Field is named `type` in C but that is a Rust keyword,
53925395 // so these fields are translated to `type_` in the bindings.
5393- "type_" if struct_ == "object_wait_info" => "type" . to_string ( ) ,
5394- "type_" if struct_ == "sem_t" => "type" . to_string ( ) ,
5395- "type_" if struct_ == "attr_info" => "type" . to_string ( ) ,
5396- "type_" if struct_ == "index_info" => "type" . to_string ( ) ,
5397- "type_" if struct_ == "cpu_topology_node_info" => "type" . to_string ( ) ,
5398- "image_type" if struct_ == "image_info" => "type" . to_string ( ) ,
5399- s => s . to_string ( ) ,
5396+ "type_" if struct_ == "object_wait_info" => Some ( "type" . to_string ( ) ) ,
5397+ "type_" if struct_ == "sem_t" => Some ( "type" . to_string ( ) ) ,
5398+ "type_" if struct_ == "attr_info" => Some ( "type" . to_string ( ) ) ,
5399+ "type_" if struct_ == "index_info" => Some ( "type" . to_string ( ) ) ,
5400+ "type_" if struct_ == "cpu_topology_node_info" => Some ( "type" . to_string ( ) ) ,
5401+ "image_type" if struct_ == "image_info" => Some ( "type" . to_string ( ) ) ,
5402+ _ => None ,
54005403 }
54015404 } ) ;
5402- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
5405+
5406+ ctest:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
54035407}
54045408
54055409fn test_aix ( target : & str ) {
0 commit comments