@@ -473,7 +473,7 @@ fn test_apple(target: &str) {
473473fn test_openbsd ( target : & str ) {
474474 assert ! ( target. contains( "openbsd" ) ) ;
475475
476- let mut cfg = ctest_cfg ( ) ;
476+ let mut cfg = ctest_next_cfg ( ) ;
477477 cfg. flag ( "-Wno-deprecated-declarations" ) ;
478478
479479 let x86_64 = target. contains ( "x86_64" ) ;
@@ -563,64 +563,76 @@ fn test_openbsd(target: &str) {
563563 "sys/param.h" ,
564564 }
565565
566- cfg. skip_const ( move |name| {
567- match name {
568- // Removed in OpenBSD 7.8
569- "CTL_FS" | "SO_NETPROC" => true ,
566+ cfg. rename_type ( |ty| match ty {
567+ // FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273
568+ "sighandler_t" => Some ( "sig_t" . to_string ( ) ) ,
569+ _ => None ,
570+ } ) ;
570571
571- _ => false ,
572+ cfg. rename_struct_ty ( move |ty| {
573+ match ty {
574+ // Just pass all these through, no need for a "struct" prefix
575+ "FILE" | "DIR" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => Some ( ty. to_string ( ) ) ,
576+
577+ _ => None ,
572578 }
573579 } ) ;
574580
575- cfg. skip_fn ( move |name| {
576- match name {
577- // futex() has volatile arguments, but that doesn't exist in Rust.
578- "futex" => true ,
581+ cfg. rename_struct_field ( |struct_, field_| {
582+ let struct_ = struct_. ident ( ) ;
583+ let replacement = match field_. ident ( ) {
584+ "st_birthtime" if struct_. starts_with ( "stat" ) => "__st_birthtime" . to_string ( ) ,
585+ "st_birthtime_nsec" if struct_. starts_with ( "stat" ) => "__st_birthtimensec" . to_string ( ) ,
579586
580- _ => false ,
581- }
587+ // Our stat *_nsec fields normally don't actually exist but are part
588+ // of a timeval struct
589+ s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
590+ s. replace ( "e_nsec" , ".tv_nsec" )
591+ }
592+
593+ "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
594+
595+ _ => return None ,
596+ } ;
597+ Some ( replacement)
582598 } ) ;
583599
584- cfg. type_name ( move |ty , is_struct , is_union | {
585- match ty {
586- // Just pass all these through, no need for a "struct" prefix
587- "FILE " | "DIR " | "Dl_info " | "Elf32_Phdr" | "Elf64_Phdr" => ty . to_string ( ) ,
600+ cfg. skip_const ( move |constant | {
601+ match constant . ident ( ) {
602+ // Removed in OpenBSD 7.7 (unused since 1991)
603+ "ATF_COM " | "ATF_PERM " | "ATF_PUBL " | "ATF_USETRAILERS" => true ,
588604
589- // OSX calls this something else
590- "sighandler_t" => "sig_t" . to_string ( ) ,
605+ // Removed in OpenBSD 7.8
606+ "CTL_FS" | "SO_NETPROC" => true ,
591607
592- t if is_union => format ! ( "union {t}" ) ,
593- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
594- t if is_struct => format ! ( "struct {t}" ) ,
595- t => t. to_string ( ) ,
608+ _ => false ,
596609 }
597610 } ) ;
598611
599- cfg. field_name ( move |struct_, field| match field {
600- "st_birthtime" if struct_. starts_with ( "stat" ) => "__st_birthtime" . to_string ( ) ,
601- "st_birthtime_nsec" if struct_. starts_with ( "stat" ) => "__st_birthtimensec" . to_string ( ) ,
602- s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => s. replace ( "e_nsec" , ".tv_nsec" ) ,
603- "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
604- s => s. to_string ( ) ,
605- } ) ;
612+ // Skip anonymous unions/structs.
613+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
614+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
606615
607- cfg. skip_field_type ( move |struct_, field| {
608- // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1
609- struct_ == "siginfo_t" && field == "si_addr"
610- } ) ;
616+ cfg. rename_struct_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
617+ cfg. rename_union_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
611618
612- cfg. skip_field ( |struct_, field| {
613- match ( struct_, field) {
619+ cfg. skip_struct_field ( move |struct_, field| {
620+ match ( struct_. ident ( ) , field. ident ( ) ) {
614621 // conflicting with `p_type` macro from <resolve.h>.
615622 ( "Elf32_Phdr" , "p_type" ) => true ,
616623 ( "Elf64_Phdr" , "p_type" ) => true ,
617- // ifr_ifru is defined is an union
624+
625+ // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1
626+ ( "siginfo_t" , "si_addr" ) => true ,
627+
628+ // ifr_ifru is an union
618629 ( "ifreq" , "ifr_ifru" ) => true ,
630+
619631 _ => false ,
620632 }
621633 } ) ;
622634
623- cfg. generate ( src_hotfix_dir ( ) . join ( " lib.rs") , "ctest_output.rs" ) ;
635+ ctest_next :: generate_test ( & mut cfg, "../src/ lib.rs", "ctest_output.rs" ) . unwrap ( ) ;
624636}
625637
626638fn test_cygwin ( target : & str ) {
0 commit comments