@@ -2855,6 +2855,9 @@ fn test_freebsd(target: &str) {
28552855 "CAP_UNUSED0_44" | "CAP_UNUSED0_57" | "CAP_UNUSED1_22" | "CAP_UNUSED1_57"
28562856 | "CAP_ALL0" | "CAP_ALL1" => true ,
28572857
2858+ // FIXME(freebsd): Removed in FreeBSD 15, deprecated in libc
2859+ "TCP_PCAP_OUT" | "TCP_PCAP_IN" => true ,
2860+
28582861 _ => false ,
28592862 }
28602863 } ) ;
@@ -3661,6 +3664,26 @@ fn test_vxworks(target: &str) {
36613664 cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
36623665}
36633666
3667+ fn config_gnu_bits ( target : & str , cfg : & mut ctest:: TestGenerator ) {
3668+ match env:: var ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS" ) {
3669+ Ok ( val) if val == "64" => {
3670+ if target. contains ( "gnu" )
3671+ && target. contains ( "linux" )
3672+ && !target. ends_with ( "x32" )
3673+ && !target. contains ( "riscv32" )
3674+ && env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) . unwrap ( ) == "32"
3675+ {
3676+ cfg. define ( "_FILE_OFFSET_BITS" , Some ( "64" ) ) ;
3677+ cfg. cfg ( "gnu_file_offset_bits64" , None ) ;
3678+ }
3679+ }
3680+ Ok ( val) if val != "32" => {
3681+ panic ! ( "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'" )
3682+ }
3683+ _ => { }
3684+ }
3685+ }
3686+
36643687fn test_linux ( target : & str ) {
36653688 assert ! ( target. contains( "linux" ) ) ;
36663689
@@ -3704,6 +3727,8 @@ fn test_linux(target: &str) {
37043727 // glibc versions older than 2.29.
37053728 cfg. define ( "__GLIBC_USE_DEPRECATED_SCANF" , None ) ;
37063729
3730+ config_gnu_bits ( target, & mut cfg) ;
3731+
37073732 headers ! { cfg:
37083733 "ctype.h" ,
37093734 "dirent.h" ,
@@ -4866,6 +4891,7 @@ fn test_linux_like_apis(target: &str) {
48664891 if linux || android || emscripten {
48674892 // test strerror_r from the `string.h` header
48684893 let mut cfg = ctest_cfg ( ) ;
4894+ config_gnu_bits ( target, & mut cfg) ;
48694895 cfg. skip_type ( |_| true ) . skip_static ( |_| true ) ;
48704896
48714897 headers ! { cfg: "string.h" }
@@ -4882,6 +4908,7 @@ fn test_linux_like_apis(target: &str) {
48824908 // test fcntl - see:
48834909 // http://man7.org/linux/man-pages/man2/fcntl.2.html
48844910 let mut cfg = ctest_cfg ( ) ;
4911+ config_gnu_bits ( target, & mut cfg) ;
48854912
48864913 if musl {
48874914 cfg. header ( "fcntl.h" ) ;
@@ -4911,6 +4938,7 @@ fn test_linux_like_apis(target: &str) {
49114938 if ( linux && !wali) || android {
49124939 // test termios
49134940 let mut cfg = ctest_cfg ( ) ;
4941+ config_gnu_bits ( target, & mut cfg) ;
49144942 cfg. header ( "asm/termbits.h" ) ;
49154943 cfg. header ( "linux/termios.h" ) ;
49164944 cfg. skip_type ( |_| true )
@@ -4935,6 +4963,7 @@ fn test_linux_like_apis(target: &str) {
49354963 if linux || android {
49364964 // test IPV6_ constants:
49374965 let mut cfg = ctest_cfg ( ) ;
4966+ config_gnu_bits ( target, & mut cfg) ;
49384967 headers ! {
49394968 cfg:
49404969 "linux/in6.h"
@@ -4966,6 +4995,7 @@ fn test_linux_like_apis(target: &str) {
49664995 // "resolve.h" defines a `p_type` macro that expands to `__p_type`
49674996 // making the tests for these fails when both are included.
49684997 let mut cfg = ctest_cfg ( ) ;
4998+ config_gnu_bits ( target, & mut cfg) ;
49694999 cfg. header ( "elf.h" ) ;
49705000 cfg. skip_fn ( |_| true )
49715001 . skip_static ( |_| true )
@@ -4985,6 +5015,7 @@ fn test_linux_like_apis(target: &str) {
49855015 if ( linux && !wali) || android {
49865016 // Test `ARPHRD_CAN`.
49875017 let mut cfg = ctest_cfg ( ) ;
5018+ config_gnu_bits ( target, & mut cfg) ;
49885019 cfg. header ( "linux/if_arp.h" ) ;
49895020 cfg. skip_fn ( |_| true )
49905021 . skip_static ( |_| true )
0 commit comments