@@ -52,7 +52,10 @@ fn do_cc() {
52
52
fn do_ctest ( ) {
53
53
match & env:: var ( "TARGET" ) . unwrap ( ) {
54
54
t if t. contains ( "android" ) => test_android ( t) ,
55
- t if t. contains ( "apple" ) => test_apple ( t) ,
55
+ t if t. contains ( "apple" ) => {
56
+ test_apple_next ( t) ;
57
+ test_apple ( t) ;
58
+ }
56
59
t if t. contains ( "dragonfly" ) => test_dragonflybsd ( t) ,
57
60
t if t. contains ( "emscripten" ) => test_emscripten ( t) ,
58
61
t if t. contains ( "freebsd" ) => test_freebsd ( t) ,
@@ -77,7 +80,6 @@ fn ctest_cfg() -> ctest::TestGenerator {
77
80
ctest:: TestGenerator :: new ( )
78
81
}
79
82
80
- #[ expect( unused) ]
81
83
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
82
84
ctest_next:: TestGenerator :: new ( )
83
85
}
@@ -495,6 +497,263 @@ fn test_apple(target: &str) {
495
497
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
496
498
}
497
499
500
+ fn test_apple_next ( target : & str ) {
501
+ assert ! ( target. contains( "apple" ) ) ;
502
+ let x86_64 = target. contains ( "x86_64" ) ;
503
+ let i686 = target. contains ( "i686" ) ;
504
+
505
+ let mut cfg = ctest_next_cfg ( ) ;
506
+ cfg. skip_private ( true ) ;
507
+ cfg. flag ( "-Wno-deprecated-declarations" ) ;
508
+ cfg. define ( "__APPLE_USE_RFC_3542" , None ) ;
509
+
510
+ headers ! { cfg:
511
+ "aio.h" ,
512
+ "CommonCrypto/CommonCrypto.h" ,
513
+ "CommonCrypto/CommonRandom.h" ,
514
+ "copyfile.h" ,
515
+ "crt_externs.h" ,
516
+ "ctype.h" ,
517
+ "dirent.h" ,
518
+ "dlfcn.h" ,
519
+ "errno.h" ,
520
+ "execinfo.h" ,
521
+ "fcntl.h" ,
522
+ "fnmatch.h" ,
523
+ "getopt.h" ,
524
+ "glob.h" ,
525
+ "grp.h" ,
526
+ "iconv.h" ,
527
+ "ifaddrs.h" ,
528
+ "langinfo.h" ,
529
+ "libgen.h" ,
530
+ "libproc.h" ,
531
+ "limits.h" ,
532
+ "locale.h" ,
533
+ "malloc/malloc.h" ,
534
+ "net/bpf.h" ,
535
+ "net/dlil.h" ,
536
+ "net/if.h" ,
537
+ "net/if_arp.h" ,
538
+ "net/if_dl.h" ,
539
+ "net/if_mib.h" ,
540
+ "net/if_utun.h" ,
541
+ "net/if_var.h" ,
542
+ "net/ndrv.h" ,
543
+ "net/route.h" ,
544
+ "netdb.h" ,
545
+ "netinet/if_ether.h" ,
546
+ "netinet/in.h" ,
547
+ "netinet/ip.h" ,
548
+ "netinet/tcp.h" ,
549
+ "netinet/udp.h" ,
550
+ "netinet6/in6_var.h" ,
551
+ "os/clock.h" ,
552
+ "os/lock.h" ,
553
+ "os/signpost.h" ,
554
+ // FIXME(macos): Requires the macOS 14.4 SDK.
555
+ //"os/os_sync_wait_on_address.h",
556
+ "poll.h" ,
557
+ "pthread.h" ,
558
+ "pthread_spis.h" ,
559
+ "pthread/introspection.h" ,
560
+ "pthread/spawn.h" ,
561
+ "pthread/stack_np.h" ,
562
+ "pwd.h" ,
563
+ "regex.h" ,
564
+ "resolv.h" ,
565
+ "sched.h" ,
566
+ "semaphore.h" ,
567
+ "signal.h" ,
568
+ "spawn.h" ,
569
+ "stddef.h" ,
570
+ "stdint.h" ,
571
+ "stdio.h" ,
572
+ "stdlib.h" ,
573
+ "string.h" ,
574
+ "sysdir.h" ,
575
+ "sys/appleapiopts.h" ,
576
+ "sys/attr.h" ,
577
+ "sys/clonefile.h" ,
578
+ "sys/event.h" ,
579
+ "sys/file.h" ,
580
+ "sys/ioctl.h" ,
581
+ "sys/ipc.h" ,
582
+ "sys/kern_control.h" ,
583
+ "sys/mman.h" ,
584
+ "sys/mount.h" ,
585
+ "sys/proc_info.h" ,
586
+ "sys/ptrace.h" ,
587
+ "sys/quota.h" ,
588
+ "sys/random.h" ,
589
+ "sys/resource.h" ,
590
+ "sys/sem.h" ,
591
+ "sys/shm.h" ,
592
+ "sys/socket.h" ,
593
+ "sys/stat.h" ,
594
+ "sys/statvfs.h" ,
595
+ "sys/sys_domain.h" ,
596
+ "sys/sysctl.h" ,
597
+ "sys/time.h" ,
598
+ "sys/times.h" ,
599
+ "sys/timex.h" ,
600
+ "sys/types.h" ,
601
+ "sys/uio.h" ,
602
+ "sys/un.h" ,
603
+ "sys/utsname.h" ,
604
+ "sys/vsock.h" ,
605
+ "sys/wait.h" ,
606
+ "sys/xattr.h" ,
607
+ "syslog.h" ,
608
+ "termios.h" ,
609
+ "time.h" ,
610
+ "unistd.h" ,
611
+ "util.h" ,
612
+ "utime.h" ,
613
+ "utmpx.h" ,
614
+ "wchar.h" ,
615
+ "xlocale.h" ,
616
+ [ x86_64] : "crt_externs.h" ,
617
+ }
618
+
619
+ // Skip anonymous unions/structs.
620
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
621
+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
622
+
623
+ cfg. skip_struct ( |s| {
624
+ match s. ident ( ) {
625
+ // FIXME(union): actually a union
626
+ "sigval" => true ,
627
+ // FIXME(macos): The size is changed in recent macOSes.
628
+ "malloc_zone_t" => true ,
629
+ // it is a moving target, changing through versions
630
+ // also contains bitfields members
631
+ "tcp_connection_info" => true ,
632
+ // FIXME(macos): The size is changed in recent macOSes.
633
+ "malloc_introspection_t" => true ,
634
+ // sonoma changes the padding `rmx_filler` field.
635
+ "rt_metrics" => true ,
636
+ _ => false ,
637
+ }
638
+ } ) ;
639
+
640
+ cfg. skip_alias ( |ty| ty. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
641
+ cfg. skip_alias ( |ty| {
642
+ match ty. ident ( ) {
643
+ // FIXME(macos): Requires the macOS 14.4 SDK.
644
+ "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true ,
645
+
646
+ // FIXME(macos): "'__uint128' undeclared" in C
647
+ "__uint128" => true ,
648
+
649
+ _ => false ,
650
+ }
651
+ } ) ;
652
+
653
+ cfg. skip_const ( move |constant| {
654
+ match constant. ident ( ) {
655
+ // These OSX constants are removed in Sierra.
656
+ // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
657
+ "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true ,
658
+ // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000).
659
+ "SF_SETTABLE" => true ,
660
+
661
+ // FIXME(macos): XCode 13.1 doesn't have it.
662
+ "TIOCREMOTE" => true ,
663
+
664
+ // FIXME(macos): Requires the macOS 14.4 SDK.
665
+ "OS_SYNC_WAKE_BY_ADDRESS_NONE"
666
+ | "OS_SYNC_WAKE_BY_ADDRESS_SHARED"
667
+ | "OS_SYNC_WAIT_ON_ADDRESS_NONE"
668
+ | "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true ,
669
+
670
+ _ => false ,
671
+ }
672
+ } ) ;
673
+
674
+ cfg. skip_fn ( move |func| {
675
+ // skip those that are manually verified
676
+ match func. ident ( ) {
677
+ // close calls the close_nocancel system call
678
+ "close" => true ,
679
+
680
+ // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766
681
+ "res_init" => true ,
682
+
683
+ // FIXME(macos): remove once the target in CI is updated
684
+ "pthread_jit_write_freeze_callbacks_np" => true ,
685
+
686
+ // FIXME(macos): ABI has been changed on recent macOSes.
687
+ "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true ,
688
+
689
+ // FIXME(macos): Once the SDK get updated to Ventura's level
690
+ "freadlink" | "mknodat" | "mkfifoat" => true ,
691
+
692
+ // FIXME(macos): Requires the macOS 14.4 SDK.
693
+ "os_sync_wake_by_address_any"
694
+ | "os_sync_wake_by_address_all"
695
+ | "os_sync_wake_by_address_flags_t"
696
+ | "os_sync_wait_on_address"
697
+ | "os_sync_wait_on_address_flags_t"
698
+ | "os_sync_wait_on_address_with_deadline"
699
+ | "os_sync_wait_on_address_with_timeout" => true ,
700
+
701
+ _ => false ,
702
+ }
703
+ } ) ;
704
+
705
+ cfg. skip_struct_field ( move |struct_, field| {
706
+ match ( struct_. ident ( ) , field. ident ( ) ) {
707
+ // FIXME(union): actually a union
708
+ ( "sigevent" , "sigev_value" ) => true ,
709
+ // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]).
710
+ ( "statfs" , "f_reserved" ) => true ,
711
+ ( "__darwin_arm_neon_state64" , "__v" ) => true ,
712
+
713
+ ( "ifreq" , "ifr_ifru" ) => true ,
714
+ ( "in6_ifreq" , "ifr_ifru" ) => true ,
715
+ ( "ifkpi" , "ifk_data" ) => true ,
716
+ ( "ifconf" , "ifc_ifcu" ) => true ,
717
+ _ => false ,
718
+ }
719
+ } ) ;
720
+
721
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
722
+
723
+ cfg. rename_struct_ty ( move |ty| {
724
+ // Just pass all these through, no need for a "struct" prefix
725
+ [ "FILE" , "DIR" , "Dl_info" ]
726
+ . contains ( & ty)
727
+ . then_some ( ty. to_string ( ) )
728
+ } ) ;
729
+ cfg. rename_type ( |ty| ( ty == "sighandler_t" ) . then_some ( "sig_t" . to_string ( ) ) ) ;
730
+ cfg. rename_struct_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
731
+ cfg. rename_union_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
732
+
733
+ cfg. rename_struct_field ( |s, f| {
734
+ match f. ident ( ) {
735
+ n if n. ends_with ( "_nsec" ) && s. ident ( ) . starts_with ( "stat" ) => {
736
+ n. replace ( "e_nsec" , "espec.tv_nsec" ) . into ( )
737
+ }
738
+ // FIXME(macos): sigaction actually contains a union with two variants:
739
+ // a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
740
+ // a sa_handler with type sig_t
741
+ "sa_sigaction" if s. ident ( ) == "sigaction" => "sa_handler" . to_string ( ) . into ( ) ,
742
+ _ => None ,
743
+ }
744
+ } ) ;
745
+
746
+ cfg. skip_roundtrip ( move |s| match s {
747
+ // FIXME(macos): this type has the wrong ABI
748
+ "max_align_t" if i686 => true ,
749
+ // Can't return an array from a C function.
750
+ "uuid_t" | "vol_capabilities_set_t" => true ,
751
+ _ => false ,
752
+ } ) ;
753
+
754
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "main_next.rs" ) . unwrap ( ) ;
755
+ }
756
+
498
757
fn test_openbsd ( target : & str ) {
499
758
assert ! ( target. contains( "openbsd" ) ) ;
500
759
0 commit comments