@@ -473,7 +473,7 @@ fn test_apple(target: &str) {
473
473
fn test_openbsd ( target : & str ) {
474
474
assert ! ( target. contains( "openbsd" ) ) ;
475
475
476
- let mut cfg = ctest_cfg ( ) ;
476
+ let mut cfg = ctest_next_cfg ( ) ;
477
477
cfg. flag ( "-Wno-deprecated-declarations" ) ;
478
478
479
479
let x86_64 = target. contains ( "x86_64" ) ;
@@ -563,64 +563,76 @@ fn test_openbsd(target: &str) {
563
563
"sys/param.h" ,
564
564
}
565
565
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
+ } ) ;
570
571
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 ,
572
578
}
573
579
} ) ;
574
580
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 ( ) ,
579
586
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)
582
598
} ) ;
583
599
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 ,
588
604
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 ,
591
607
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 ,
596
609
}
597
610
} ) ;
598
611
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_" ) ) ;
606
615
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 ( ) ) ) ;
611
618
612
- cfg. skip_field ( |struct_, field| {
613
- match ( struct_, field) {
619
+ cfg. skip_struct_field ( move |struct_, field| {
620
+ match ( struct_. ident ( ) , field. ident ( ) ) {
614
621
// conflicting with `p_type` macro from <resolve.h>.
615
622
( "Elf32_Phdr" , "p_type" ) => true ,
616
623
( "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
618
629
( "ifreq" , "ifr_ifru" ) => true ,
630
+
619
631
_ => false ,
620
632
}
621
633
} ) ;
622
634
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 ( ) ;
624
636
}
625
637
626
638
fn test_cygwin ( target : & str ) {
0 commit comments